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:
Steve Karg
2022-12-25 21:43:51 -06:00
committed by GitHub
parent 0728bc4390
commit b91735af13
66 changed files with 990 additions and 847 deletions
+49 -54
View File
@@ -276,68 +276,69 @@ static void print_usage(char *filename)
static void print_help(char *filename)
{
printf("Send BACnet WhoIs service request to a device or multiple\n"
"devices, and wait for responses. Displays any devices found\n"
"and their network information.\n"
"\n"
"device-instance:\n"
"BACnet Device Object Instance number that you are trying\n"
"to send a Who-Is service request. The value should be in\n"
"the range of 0 to 4194303. A range of values can also be\n"
"specified by using a minimum value and a maximum value.\n"
"\n");
"devices, and wait for responses. Displays any devices found\n"
"and their network information.\n");
printf("\n");
printf("device-instance:\n"
"BACnet Device Object Instance number that you are trying\n"
"to send a Who-Is service request. The value should be in\n"
"the range of 0 to 4194303. A range of values can also be\n"
"specified by using a minimum value and a maximum value.\n");
printf("\n");
printf("--mac A\n"
"BACnet mac address."
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
"\n"
"--dnet N\n"
"BACnet network number N for directed requests.\n"
"Valid range is from 0 to 65535 where 0 is the local connection\n"
"and 65535 is network broadcast.\n"
"\n"
"--dadr A\n"
"BACnet mac address on the destination BACnet network number.\n"
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
"\n"
"--repeat\n"
"Send the message repeatedly until signalled to quit.\n"
"Default is disabled, using the APDU timeout as time to quit.\n"
"\n"
"--retry C\n"
"Send the message C number of times\n"
"Default is retry 0, only sending one time.\n"
"\n"
"--timeout T\n"
"Wait T milliseconds after sending before retry\n"
"Default delay is 3000ms.\n"
"\n"
"--delay M\n"
"Wait M milliseconds for responses after sending\n"
"Default delay is 100ms.\n"
"\n");
"BACnet mac address."
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
printf("\n");
printf("--dnet N\n"
"BACnet network number N for directed requests.\n"
"Valid range is from 0 to 65535 where 0 is the local connection\n"
"and 65535 is network broadcast.\n");
printf("\n");
printf("--dadr A\n"
"BACnet mac address on the destination BACnet network number.\n"
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
printf("\n");
printf("--repeat\n"
"Send the message repeatedly until signalled to quit.\n"
"Default is disabled, using the APDU timeout as time to quit.\n");
printf("\n");
printf("--retry C\n"
"Send the message C number of times\n"
"Default is retry 0, only sending one time.\n");
printf("\n");
printf("--timeout T\n"
"Wait T milliseconds after sending before retry\n"
"Default delay is 3000ms.\n");
printf("\n");
printf("--delay M\n"
"Wait M milliseconds for responses after sending\n"
"Default delay is 100ms.\n");
printf("\n");
printf("Example:\n");
printf("Send a WhoIs request to DNET 123:\n"
"%s --dnet 123\n",
"%s --dnet 123\n",
filename);
printf("Send a WhoIs request to MAC 10.0.0.1 DNET 123 DADR 05h:\n"
"%s --mac 10.0.0.1 --dnet 123 --dadr 05\n",
"%s --mac 10.0.0.1 --dnet 123 --dadr 05\n",
filename);
printf("Send a WhoIs request to MAC 10.1.2.3:47808:\n"
"%s --mac 10.1.2.3:47808\n",
"%s --mac 10.1.2.3:47808\n",
filename);
printf("Send a WhoIs request to Device 123:\n"
"%s 123\n",
"%s 123\n",
filename);
printf("Send a WhoIs request to Devices from 1000 to 9000:\n"
"%s 1000 9000\n",
"%s 1000 9000\n",
filename);
printf("Send a WhoIs request to Devices from 1000 to 9000 on DNET 123:\n"
"%s 1000 9000 --dnet 123\n",
"%s 1000 9000 --dnet 123\n",
filename);
printf("Send a WhoIs request to all devices:\n"
"%s\n",
"%s\n",
filename);
}
@@ -413,16 +414,10 @@ int main(int argc, char *argv[])
} else if (strcmp(argv[argi], "--timeout") == 0) {
if (++argi < argc) {
timeout_milliseconds = strtol(argv[argi], NULL, 0);
if (timeout_milliseconds < 0) {
timeout_milliseconds = 0;
}
}
} else if (strcmp(argv[argi], "--delay") == 0) {
if (++argi < argc) {
delay_milliseconds = strtol(argv[argi], NULL, 0);
if (delay_milliseconds < 0) {
delay_milliseconds = 0;
}
}
} else {
if (target_args == 0) {