Strip tabs and trailing white spaces, and fix end of files (#748)

* format: Strip trailing whitespaces

We want to get rid of trailing whitespaces completly as they make just git
noice. Much better to start using automated tools to get rid of them once and
not getting them back again. This way git history will be cleaner and review
easier.

Commit was generated with:

    pre-commit run --all-files trailing-whitespace

* format: Files should have exactly one new line end of them

It is good practice that every file has one new line. It is not now days so
mandatory but it also is not nice if file has lot of newlines end of it. We will
use pre-commit which takes automatically care about this so let's fix all.

Commit was generated with:

    pre-commit run --all-files end-of-file-fixer

* format: Convert tabs to spaces

Project mostly use spaces over tabs. When mixing tabs and spaces this usually
makes formatting issues and also when changing those in commits it will make lot
of git noise. We will force spaces most of the time and use pre-commit to fix.

Commit was generated with:

    pre-commit run --all-files remove-tabs

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
Kari Argillander
2024-08-25 22:13:57 +03:00
committed by GitHub
parent 9e0657424e
commit 369da70f2a
455 changed files with 7147 additions and 7249 deletions
+12 -12
View File
@@ -56,7 +56,7 @@ do
[0x82]="B/IPv6 (Annex X)"
}
local t_BACnetBIPV6_Functions = {
-- Annex X, PPR3 Draft 22
-- Annex X, PPR3 Draft 22
[0x00]="BVLC-Result",
[0x01]="Original-Unicast-NPDU",
[0x02]="Original-Broadcast-NPDU",
@@ -69,7 +69,7 @@ do
[0x09]="Register-Foreign-Device",
[0x0A]="Delete-Foreign-Device",
[0x0B]="Secure-BVLL",
[0x0C]="Distribute-Broadcast-To-Network"
[0x0C]="Distribute-Broadcast-To-Network"
}
local pf_BIPV6Data = ProtoField.bytes ("BIPV6.data", "B/IPV6 Data")
@@ -121,14 +121,14 @@ do
local ti_BIPV6 = {}
ti_BIPV6.ti = tree:add(p_BACnetBIPV6,buffer(0))
offset, v_BIPV6.Type, ti_BIPV6.Type = uint_dissector(ti_BIPV6.ti, pf_BIPV6.Type, buffer, offset, 1)
--if v_BIPV6.Type == 0x81 then
-- p_dissector_bipv4:call(buffer, pkt, tree)
-- elseif v_BIPV6 ~= 0x82 then
-- ti_BIPV6.Type:add_expert_info(PI_MALFORMED, PI_WARN, "Unknown BVLC Type")
--if v_BIPV6.Type == 0x81 then
-- p_dissector_bipv4:call(buffer, pkt, tree)
-- elseif v_BIPV6 ~= 0x82 then
-- ti_BIPV6.Type:add_expert_info(PI_MALFORMED, PI_WARN, "Unknown BVLC Type")
-- return
--end
--end
if v_BIPV6.Type ~= 0x82 then
ti_BIPV6.Type:add_expert_info(PI_MALFORMED, PI_WARN, "Unknown BVLC Type")
ti_BIPV6.Type:add_expert_info(PI_MALFORMED, PI_WARN, "Unknown BVLC Type")
return
end
offset, v_BIPV6.Function, ti_BIPV6.Function = uint_dissector(ti_BIPV6.ti, pf_BIPV6.Function, buffer, offset, 1)
@@ -148,7 +148,7 @@ do
p_dissector_bacnet:call(npduData:tvb(), pkt, tree)
end
end
-- CLB don't show the raw data
-- CLB don't show the raw data
-- if offset ~= buffer:len() then
-- ti_BIPV6.ti:add(pf_BIPV6Data,buffer(offset))
-- end
@@ -187,7 +187,7 @@ do
t_BACnetBIPV6_dissectors[0x04] = function(buffer,pkt,tree,offset,npdu)
offset = bytes_dissector(tree,pf_BIPV6.OriginalSourceVirtualAddress,buffer,offset,3)
offset = bytes_dissector(tree,pf_BIPV6.DestinationVirtualAddress,buffer,offset,3)
local subtree = tree:add(pf_BIPV6.OriginalSourceEffectiveAddress,buffer(offset,18))
local subtree = tree:add(pf_BIPV6.OriginalSourceEffectiveAddress,buffer(offset,18))
offset = bytes_dissector(subtree,pf_BIPV6.OriginalSourceEffectiveAddress_ip,buffer,offset,16)
offset = uint_dissector(subtree,pf_BIPV6.OriginalSourceEffectiveAddress_port,buffer,offset,2)
return offset
@@ -215,7 +215,7 @@ do
-- [0x08] Forwarded-NPDU
t_BACnetBIPV6_dissectors[0x08] = function(buffer,pkt,tree,offset,npdu)
offset = bytes_dissector(tree,pf_BIPV6.OriginalSourceVirtualAddress,buffer,offset,3)
local subtree = tree:add(pf_BIPV6.OriginalSourceEffectiveAddress,buffer(offset,18))
local subtree = tree:add(pf_BIPV6.OriginalSourceEffectiveAddress,buffer(offset,18))
offset = bytes_dissector(subtree,pf_BIPV6.OriginalSourceEffectiveAddress_ip,buffer,offset,16)
offset = uint_dissector(subtree,pf_BIPV6.OriginalSourceEffectiveAddress_port,buffer,offset,2)
return offset, buffer(offset)
@@ -243,7 +243,7 @@ do
-- [0x0C] Distribute-Broadcast-To-Network
t_BACnetBIPV6_dissectors[0x0C] = function(buffer,pkt,tree,offset,npdu)
offset = bytes_dissector(tree,pf_BIPV6.OriginalSourceVirtualAddress,buffer,offset,3)
local subtree = tree:add(pf_BIPV6.OriginalSourceEffectiveAddress,buffer(offset,18))
local subtree = tree:add(pf_BIPV6.OriginalSourceEffectiveAddress,buffer(offset,18))
offset = bytes_dissector(subtree,pf_BIPV6.OriginalSourceEffectiveAddress_ip,buffer,offset,16)
offset = uint_dissector(subtree,pf_BIPV6.OriginalSourceEffectiveAddress_port,buffer,offset,2)
return offset, buffer(offset)
+29 -29
View File
@@ -10,47 +10,47 @@
#define BACPORT_H
/* common unix sockets headers needed */
#include <sys/types.h> /* basic system data types */
#include <sys/time.h> /* timeval{} for select() */
#include <time.h> /* timespec{} for pselect() */
#include <netinet/in.h> /* sockaddr_in{} and other Internet defns */
#include <arpa/inet.h> /* inet(3) functions */
#include <fcntl.h> /* for nonblocking */
#include <netdb.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h> /* for S_xxx file mode constants */
#include <sys/uio.h> /* for iovec{} and readv/writev */
#include <unistd.h>
#include <sys/wait.h>
#include <sys/un.h> /* for Unix domain sockets */
#include <sys/types.h> /* basic system data types */
#include <sys/time.h> /* timeval{} for select() */
#include <time.h> /* timespec{} for pselect() */
#include <netinet/in.h> /* sockaddr_in{} and other Internet defns */
#include <arpa/inet.h> /* inet(3) functions */
#include <fcntl.h> /* for nonblocking */
#include <netdb.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h> /* for S_xxx file mode constants */
#include <sys/uio.h> /* for iovec{} and readv/writev */
#include <unistd.h>
#include <sys/wait.h>
#include <sys/un.h> /* for Unix domain sockets */
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h> /* for convenience */
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h> /* for convenience */
#endif
#ifdef HAVE_POLL_H
#include <poll.h> /* for convenience */
#ifdef HAVE_POLL_H
#include <poll.h> /* for convenience */
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h> /* for convenience */
#ifdef HAVE_STRINGS_H
#include <strings.h> /* for convenience */
#endif
/* Three headers are normally needed for socket/file ioctl's:
* <sys/ioctl.h>, <sys/filio.h>, and <sys/sockio.h>.
*/
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h>
#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h>
#endif
#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#endif
#include <pthread.h>
+1 -1
View File
@@ -25,7 +25,7 @@ static bool BIP6_Debug = false;
/**
* @brief Conditionally use the debug_printf function
*
*
* @param stream - file stream to print to
* @param format - printf format string
* @param ... - variable arguments
+1 -1
View File
@@ -118,7 +118,7 @@ static int timespec_subtract(
*
* @param ts - The time to which to add to.
* @param ns - The number of nanoseconds to add. Allowed range
* is -NS_PER_S..NS_PER_S (i.e., plus minus one second).
* is -NS_PER_S..NS_PER_S (i.e., plus minus one second).
*/
static void timespec_add_ns(struct timespec *ts, long ns)
{
+5 -5
View File
@@ -3,7 +3,7 @@ CC = gcc
BASEDIR = .
# -g for debugging with gdb
DEFINES = -DBIG_ENDIAN=0 -DBACDL_MSTP=1 -DTEST_DLMSTP
INCLUDES = -I. -I../../
INCLUDES = -I. -I../../
CFLAGS = -Wall $(INCLUDES) $(DEFINES) -g
SRCS = rs485.c \
@@ -16,17 +16,17 @@ OBJS = ${SRCS:.c=.o}
TARGET = dlmstp
all: ${TARGET}
${TARGET}: ${OBJS}
${CC} -pthread -o $@ ${OBJS}
${CC} -pthread -o $@ ${OBJS}
.c.o:
${CC} -c ${CFLAGS} $*.c -o $@
depend:
rm -f .depend
${CC} -MM ${CFLAGS} *.c >> .depend
clean:
rm -rf core ${TARGET} $(OBJS) *.bak *.1 *.ini
+1 -1
View File
@@ -1,2 +1,2 @@
This is a port to Linux for testing.
The unit tests can be run via the test.sh script.
The unit tests can be run via the test.sh script.