Bugfix/code clean using gcc warnings (#371)
* Enable extra GCC warnings to discover subtle bugs * convert c++ comments to c comments * cleanup pedantic compiler warnings * Compile apps with GNU89 GNU99 GNU11 and GNU17 Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -204,6 +204,7 @@ void bip_get_broadcast_address(BACNET_ADDRESS *dest)
|
||||
bool bip_set_addr(BACNET_IP_ADDRESS *addr)
|
||||
{
|
||||
/* not something we do within this driver */
|
||||
(void)addr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -230,6 +231,7 @@ bool bip_get_addr(BACNET_IP_ADDRESS *addr)
|
||||
bool bip_set_broadcast_addr(BACNET_IP_ADDRESS *addr)
|
||||
{
|
||||
/* not something we do within this driver */
|
||||
(void)addr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -255,6 +257,7 @@ bool bip_get_broadcast_addr(BACNET_IP_ADDRESS *addr)
|
||||
bool bip_set_subnet_prefix(uint8_t prefix)
|
||||
{
|
||||
/* not something we do within this driver */
|
||||
(void)prefix;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -336,7 +339,7 @@ uint16_t bip_receive(
|
||||
int max = 0;
|
||||
struct timeval select_timeout;
|
||||
struct sockaddr_in sin = { 0 };
|
||||
BACNET_IP_ADDRESS addr = { { 0 } };
|
||||
BACNET_IP_ADDRESS addr = { 0 };
|
||||
socklen_t sin_len = sizeof(sin);
|
||||
int received_bytes = 0;
|
||||
int offset = 0;
|
||||
@@ -657,6 +660,8 @@ static void parseRoutes(struct nlmsghdr *nlHdr, struct route_info *rtInfo)
|
||||
case RTA_DST:
|
||||
rtInfo->dstAddr = *(u_int *)RTA_DATA(rtAttr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,11 +117,11 @@ static struct timespec start;
|
||||
static int timespec_subtract(
|
||||
struct timespec *result, const struct timespec *l, const struct timespec *r)
|
||||
{
|
||||
#define NS_PER_S 1000000000 // nano-seconds per second
|
||||
#define NS_PER_S 1000000000 /* nano-seconds per second */
|
||||
struct timespec right = *r;
|
||||
int secs;
|
||||
|
||||
// Perform the carry for the later subtraction by updating y.
|
||||
/* Perform the carry for the later subtraction by updating y. */
|
||||
if (l->tv_nsec < right.tv_nsec) {
|
||||
secs = (right.tv_nsec - l->tv_nsec) / NS_PER_S + 1;
|
||||
right.tv_nsec -= NS_PER_S * secs;
|
||||
@@ -133,7 +133,7 @@ static int timespec_subtract(
|
||||
right.tv_sec -= secs;
|
||||
}
|
||||
|
||||
// Compute the time remaining. tv_nsec is certainly positive.
|
||||
/* Compute the time remaining. tv_nsec is certainly positive. */
|
||||
result->tv_sec = l->tv_sec - right.tv_sec;
|
||||
result->tv_nsec = l->tv_nsec - right.tv_nsec;
|
||||
|
||||
|
||||
+8
-7
@@ -632,7 +632,8 @@ void RS485_Print_Ports(void)
|
||||
bool valid_port = false;
|
||||
struct serial_struct serinfo;
|
||||
|
||||
// Scan through /sys/class/tty - it contains all tty-devices in the system
|
||||
/* Scan through /sys/class/tty -
|
||||
it contains all tty-devices in the system */
|
||||
n = scandir(sysdir, &namelist, NULL, NULL);
|
||||
if (n < 0) {
|
||||
perror("RS485: scandir");
|
||||
@@ -642,7 +643,7 @@ void RS485_Print_Ports(void)
|
||||
strcmp(namelist[n]->d_name, ".")) {
|
||||
snprintf(device_dir, sizeof(device_dir), "%s%s/device", sysdir,
|
||||
namelist[n]->d_name);
|
||||
// Stat the devicedir and handle it if it is a symlink
|
||||
/* Stat the devicedir and handle it if it is a symlink */
|
||||
if (lstat(device_dir, &st) == 0 && S_ISLNK(st.st_mode)) {
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
snprintf(device_dir, sizeof(device_dir),
|
||||
@@ -651,16 +652,16 @@ void RS485_Print_Ports(void)
|
||||
valid_port = false;
|
||||
driver_name = basename(buffer);
|
||||
if (strcmp(driver_name, "serial8250") == 0) {
|
||||
// serial8250-devices must be probed
|
||||
/* serial8250-devices must be probed */
|
||||
snprintf(device_dir, sizeof(device_dir), "/dev/%s",
|
||||
namelist[n]->d_name);
|
||||
fd = open(
|
||||
device_dir, O_RDWR | O_NONBLOCK | O_NOCTTY);
|
||||
if (fd >= 0) {
|
||||
// Get serial_info
|
||||
/* Get serial_info */
|
||||
if (ioctl(fd, TIOCGSERIAL, &serinfo) == 0) {
|
||||
// If device type is not PORT_UNKNOWN
|
||||
// we accept the port
|
||||
/* If device type is not PORT_UNKNOWN */
|
||||
/* we accept the port */
|
||||
if (serinfo.type != PORT_UNKNOWN) {
|
||||
valid_port = true;
|
||||
}
|
||||
@@ -671,7 +672,7 @@ void RS485_Print_Ports(void)
|
||||
valid_port = true;
|
||||
}
|
||||
if (valid_port) {
|
||||
// print full absolute file path
|
||||
/* print full absolute file path */
|
||||
printf("interface {value=/dev/%s}"
|
||||
"{display=MS/TP Capture on /dev/%s}\n",
|
||||
namelist[n]->d_name, namelist[n]->d_name);
|
||||
|
||||
Reference in New Issue
Block a user