Skip to content

Commit

Permalink
Squelch 50 trivial warnings from Clang.
Browse files Browse the repository at this point in the history
Debian clang version 14.0.6

warning: flag ' ' results in undefined behavior with 'u' conversion
  specifier [-Wformat]
(sn_interface.c lines 497, 498, 499 and 500)

warning: passing 'unsigned char[16]' to parameter of type 'char *'
  converts between pointers to integer types where one is of the unique
  plain 'char' type and the other is not [-Wpointer-sign]
(sn_cfgfile.c lines 240, 256, 271, 287, 303, 304, 327, 328, 349, 365,
380, 396, 412, 413, 435 and 436)

warning: passing 'unsigned char *' to parameter of type 'const char *'
  converts between pointers to integer types where one is of the unique
  plain 'char' type and the other is not [-Wpointer-sign]
(sniffit.c lines 606, 615, 615, 645, 654, 654, 684, 693, 724, 724, 733,
733, 897, 908, 908, 938, 949, 949, 977, 986, 1014, 1014, 1023, 1023,
1762 and 1931)

warning: add explicit braces to avoid dangling else [-Wdangling-else]
(sniffit.c line 1806)

warning: format specifies type 'int' but the argument has type 'unsigned
  long' [-Wformat]
(sniffit.c line 1874)

warning: format specifies type 'unsigned long' but the argument has type
  '__uint32_t' (aka 'unsigned int') [-Wformat]
(sniffit.c lines 1158 and 1160)
  • Loading branch information
infrastation committed Sep 20, 2024
1 parent 3670ede commit 0b8fd17
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/sn_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,10 @@ static void packet_info_handler (int signum)
debug_msg("ALARM RANG");
#endif
screen_busy=1;
mvwprintw(packets_box.work_window,0,1,"IP packets/sec. : % 12u",(*IP_nr_of_packets)/INFO_TIMER);
mvwprintw(packets_box.work_window,1,1,"TCP packets/sec. : % 12u",(*TCP_nr_of_packets)/INFO_TIMER);
mvwprintw(packets_box.work_window,2,1,"ICMP packets/sec.: % 12u",(*ICMP_nr_of_packets)/INFO_TIMER);
mvwprintw(packets_box.work_window,3,1,"UDP packets/sec. : % 12u",(*UDP_nr_of_packets)/INFO_TIMER);
mvwprintw(packets_box.work_window,0,1,"IP packets/sec. : %12u",(*IP_nr_of_packets)/INFO_TIMER);
mvwprintw(packets_box.work_window,1,1,"TCP packets/sec. : %12u",(*TCP_nr_of_packets)/INFO_TIMER);
mvwprintw(packets_box.work_window,2,1,"ICMP packets/sec.: %12u",(*ICMP_nr_of_packets)/INFO_TIMER);
mvwprintw(packets_box.work_window,3,1,"UDP packets/sec. : %12u",(*UDP_nr_of_packets)/INFO_TIMER);
mvwprintw(packets_box.work_window,4,1,"bytes/sec. (TCP) : % 12ld",(*TCP_bytes_in_packets)/INFO_TIMER);
mvwprintw(packets_box.work_window,5,1,"bytes/sec. (UDP) : % 12ld",(*UDP_bytes_in_packets)/INFO_TIMER);
screen_busy=0;
Expand Down
2 changes: 1 addition & 1 deletion src/sn_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct file_info
/**** Global data (config) **************************************************/
struct cfg_file_contense
{
unsigned char host[16];
char host[16];
unsigned int priority;
unsigned char wildcard;
unsigned short port;
Expand Down
18 changes: 10 additions & 8 deletions src/sniffit.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ check_packet (_32_bit ipaddr,
unsigned int prior;
char selected;
int i; /* Wildcard stuff */
unsigned char *str_IP;
char *str_IP;
unsigned int n_s; /* strlen short notation for wc bugfix */

proto = unwrap_packet (sp, info);
Expand Down Expand Up @@ -1155,9 +1155,9 @@ packethandler (unsigned char *ipaddrpoint,
dummy = ntohs (tcphead.offset_flag);
printf ("\n");
printf ("TCP Packet ID (from_IP.port-to_IP.port): %s\n", filename);
printf (" SEQ (hex): %lX ", ntohl (tcphead.seq_nr));
printf (" SEQ (hex): %X ", ntohl (tcphead.seq_nr));
if (dummy & ACK)
printf ("ACK (hex): %lX\n", ntohl (tcphead.ACK_nr));
printf ("ACK (hex): %X\n", ntohl (tcphead.ACK_nr));
printf (" FLAGS: %c%c%c%c%c%c",
(dummy & URG) ? 'U' : '-', (dummy & ACK) ? 'A' : '-',
(dummy & PSH) ? 'P' : '-', (dummy & RST) ? 'R' : '-',
Expand Down Expand Up @@ -1516,9 +1516,9 @@ int main (int argc, char *argv[])
{
char *dev, forced_dev[20], buffer[SNAPLEN];
char ebuf[PCAP_ERRBUF_SIZE];
unsigned char *DUMPfile; /* file used for packed logging */
char *DUMPfile; /* file used for packed logging */
int c, i;
unsigned long memsize;
size_t memsize;
_32_bit ipaddr;
int flag = 0, doboth = 0, FORCE_DEV = 0, SUPPORTED = 0;
extern char *optarg;
Expand Down Expand Up @@ -1579,12 +1579,12 @@ int main (int argc, char *argv[])
case 'R': /* recording (not mixable) */
if(DUMPMODE) quit(argv[0]);
DUMPMODE=8;
DUMPfile=(unsigned char *)optarg;
DUMPfile=optarg;
break;
case 'r':
if(DUMPMODE&8) quit(argv[0]);
DUMPMODE|=16; /* reading (mixable) */
DUMPfile=(unsigned char *)optarg;
DUMPfile=optarg;
break;
case 'x':
if(DUMPMODE&8) quit(argv[0]);
Expand Down Expand Up @@ -1801,10 +1801,12 @@ int main (int argc, char *argv[])
}

if(!(DUMPMODE&16))
{
if ((dev_desc = pcap_open_live (dev, SNAPLEN, 1, MSDELAY, ebuf)) == NULL)
fprintf (stderr,"%s\n",ebuf), exit (0);
else
exit_func(close_pcapdev);
}
if(FORCE_DEV!=0) {free(dev);} /* no longer needed */

#ifdef PLUGIN0_INIT
Expand Down Expand Up @@ -1871,7 +1873,7 @@ if (Plugin_Active[9] == 1)
exit (0);
};
printf ("Entering Shared memory at %p\n", SHARED);
printf ("Shared %d\n", memsize);
printf ("Shared %zu\n", memsize);

timing = SHARED; /* set all pointers */
DATAlength = timing + sizeof (int);
Expand Down

0 comments on commit 0b8fd17

Please sign in to comment.