Ethereal-dev: Re: [Ethereal-dev] LLDP Plug-in Submission

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <gharris@xxxxxxxxx>
Date: Thu, 15 Sep 2005 01:06:07 -0700
Jim Young wrote:

gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I./../.. -I./.. \
 -I/usr/local/include "-D_U_=__attribute__((unused))" -Wall \
 -W -g -O2 -I/usr/local/include -I/usr/include/glib-1.2 \
 -I/usr/lib/glib/include -MT packet-lldp.lo -MD -MP -MF .deps/packet-lldp.Tpo \
 -c packet-lldp.c -o packet-lldp.o
packet-lldp.c: In function `get_latitude_or_longitude':
packet-lldp.c:420: warning: integer constant is too large for "long" type
packet-lldp.c:430: warning: integer constant is too large for "long" type

Constants that don't fit in a "long" - on most platforms these days, that means all 64-bit constants - have to be handled with G_GINT64_CONSTANT(), because the suffix to specify such a constant is compiler-dependent.

packet-lldp.c:435: warning: unsigned int format, different type arg (arg 4)

To print 64-bit constants, you have to use the PRI[duoxX]64 #defines.

packet-lldp.c: In function `dissect_media_tlv':
packet-lldp.c:1530: warning: cast to pointer from integer of different size
packet-lldp.c:1531: warning: integer constant is too large for "long" type
packet-lldp.c:1535: warning: unsigned int format, different type arg (arg 7)
packet-lldp.c:1547: warning: cast to pointer from integer of different size
packet-lldp.c:1548: warning: integer constant is too large for "long" type
packet-lldp.c:1552: warning: unsigned int format, pointer arg (arg 6)
packet-lldp.c:1552: warning: too many arguments for format

Missing "%s" in a format string, plus some of the other problems mentioned above.

packet-lldp.c: At top level:
packet-lldp.c:798: warning: unused parameter 'pinfo'
packet-lldp.c:827: warning: unused parameter 'pinfo'
packet-lldp.c:862: warning: unused parameter 'pinfo'
packet-lldp.c:904: warning: unused parameter 'pinfo'
packet-lldp.c:1016: warning: unused parameter 'pinfo'
packet-lldp.c:1112: warning: unused parameter 'pinfo'
packet-lldp.c:1222: warning: unused parameter 'pinfo'
packet-lldp.c:1378: warning: unused parameter 'pinfo'
packet-lldp.c:1929: warning: unused parameter 'pinfo'

We might want to use _U_ on those parameters.

packet-lldp.c: In function `dissect_lldp_chassis_id':
packet-lldp.c:469: warning: 'mac_addr' might be used uninitialized in this function
packet-lldp.c: In function `dissect_lldp_port_id':
packet-lldp.c:658: warning: 'mac_addr' might be used uninitialized in this function

GCC's data flow analysis isn't sophisticated enough, so we have to initialize "mac_addr" to NULL in those cases.

I've checked in fixes for all but the "unused parameter" warnings.