Fix some errors discovered by making GCC do format string/argument

cross-checking, and by replacing "proto_tree_add_item_format()" by
multiple routines to add items of various types.

Make the arguments of "proto_tree_add_bytes_format()" and
"proto_tree_add_string_format()" that specify the bytes or the string be
"const" pointers, so that one can pass a "const" pointer without
complaints from the compiler.

Squelch a (bogus, but the compiler isn't in a position to know that)
complaint about an uninitialized variable.

svn path=/trunk/; revision=1716
This commit is contained in:
Guy Harris 2000-03-14 06:03:26 +00:00
parent fae6516520
commit bdd64cb62b
7 changed files with 31 additions and 30 deletions

View File

@ -1,7 +1,7 @@
/* packet-ipv6.c
* Routines for IPv6 packet disassembly
*
* $Id: packet-ipv6.c,v 1.29 2000/03/12 04:47:40 gram Exp $
* $Id: packet-ipv6.c,v 1.30 2000/03/14 06:03:22 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -308,7 +308,7 @@ dissect_ipv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
proto_tree_add_ipv6_format(ipv6_tree, hf_ipv6_src,
offset + offsetof(struct ip6_hdr, ip6_src), 16,
&ipv6.ip6_src,
(guint8 *)&ipv6.ip6_src,
#ifdef INET6
"Source address: %s (%s)",
get_hostname6(&ipv6.ip6_src),
@ -319,7 +319,7 @@ dissect_ipv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
proto_tree_add_ipv6_format(ipv6_tree, hf_ipv6_dst,
offset + offsetof(struct ip6_hdr, ip6_dst), 16,
&ipv6.ip6_dst,
(guint8 *)&ipv6.ip6_dst,
#ifdef INET6
"Destination address: %s (%s)",
get_hostname6(&ipv6.ip6_dst),

View File

@ -7,7 +7,7 @@
* Laurent Cazalet <laurent.cazalet@mailclub.net>
* Thomas Parvais <thomas.parvais@advalvas.be>
*
* $Id: packet-l2tp.c,v 1.4 2000/03/12 04:47:41 gram Exp $
* $Id: packet-l2tp.c,v 1.5 2000/03/14 06:03:23 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -448,7 +448,7 @@ void dissect_l2tp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
memcpy(&long_type,(tmp_ptr+=8),sizeof(unsigned long));
long_type = htonl(long_type);
proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 6, 1,
rhcode, " TIE_BREAKER %l 0x%x", long_type,long_type );
rhcode, " TIE_BREAKER %lu 0x%lx", long_type,long_type );
break;
case FIRMWARE_REVISION:

View File

@ -2,7 +2,7 @@
* Routines for OSPF packet disassembly
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
* $Id: packet-ospf.c,v 1.20 2000/03/09 18:31:51 ashokn Exp $
* $Id: packet-ospf.c,v 1.21 2000/03/14 06:03:23 guy Exp $
*
* At this time, this module is able to analyze OSPF
* packets as specified in RFC2328. MOSPF (RFC1584) and other
@ -556,13 +556,13 @@ void dissect_ospf_lsa_mpls(const u_char *pd,
case MPLS_LINK_MAX_BW:
case MPLS_LINK_MAX_RES_BW:
ti = proto_tree_add_text(tlv_tree, offset+link_len, stlv_len+4,
"%s: %d", stlv_name,
"%s: %ld", stlv_name,
pieee_to_long(pd + offset + link_len + 4));
stlv_tree = proto_item_add_subtree(ti, ett_ospf_lsa_mpls_link_stlv);
proto_tree_add_text(stlv_tree, offset+link_len, 2,
"TLV Type: %d: %s", stlv_type, stlv_name);
proto_tree_add_text(stlv_tree, offset+link_len+2, 2, "TLV Length: %d", stlv_len);
proto_tree_add_text(stlv_tree, offset+link_len+4, 4, "%s: %d", stlv_name,
proto_tree_add_text(stlv_tree, offset+link_len+4, 4, "%s: %ld", stlv_name,
pieee_to_long(pd + offset + link_len + 4));
break;
@ -575,7 +575,7 @@ void dissect_ospf_lsa_mpls(const u_char *pd,
proto_tree_add_text(stlv_tree, offset+link_len+2, 2, "TLV Length: %d", stlv_len);
for (i=0; i<8; i++)
proto_tree_add_text(stlv_tree, offset+link_len+4+(i*4), 4,
"Pri %d: %d", i,
"Pri %d: %ld", i,
pieee_to_long(pd + offset + link_len + 4 + i*4));
break;

View File

@ -3,7 +3,7 @@
*
* (c) Copyright Ashok Narayanan <ashokn@cisco.com>
*
* $Id: packet-rsvp.c,v 1.17 2000/03/13 05:19:50 ashokn Exp $
* $Id: packet-rsvp.c,v 1.18 2000/03/14 06:03:24 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -961,8 +961,9 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
memcpy(&ip_addr, pd+offset2+8, 4);
proto_tree_add_text(rsvp_object_tree, offset2+8, 4,
"Extended Tunnel ID: %d (%s)",
ntohl(ip_addr), ip_to_str(pd+offset2+8));
"Extended Tunnel ID: %lu (%s)",
(unsigned long)ntohl(ip_addr),
ip_to_str(pd+offset2+8));
proto_tree_add_item_hidden(rsvp_object_tree, rsvp_filter[RSVPF_SESSION_EXT_TUNNEL_ID],
offset2+8, 4, ip_addr);
break;

16
proto.c
View File

@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
* $Id: proto.c,v 1.55 2000/03/12 04:47:54 gram Exp $
* $Id: proto.c,v 1.56 2000/03/14 06:03:25 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -106,11 +106,11 @@ proto_tree_add_pi(proto_tree *tree, int hfindex, gint start, gint length,
static void
proto_tree_set_value(field_info *fi, gint length, va_list ap);
static void
proto_tree_set_bytes(field_info *fi, guint8* start_ptr, gint length);
proto_tree_set_bytes(field_info *fi, const guint8* start_ptr, gint length);
static void
proto_tree_set_time(field_info *fi, struct timeval *value_ptr);
static void
proto_tree_set_string(field_info *fi, char* value);
proto_tree_set_string(field_info *fi, const char* value);
static void
proto_tree_set_ether(field_info *fi, guint8* value);
static void
@ -463,7 +463,7 @@ proto_tree_add_protocol_format(proto_tree *tree, int hfindex, gint start, gint l
/* Add a FT_BYTES to a proto_tree */
proto_item *
proto_tree_add_bytes_format(proto_tree *tree, int hfindex, gint start, gint length,
guint8 *start_ptr, const char *format, ...)
const guint8 *start_ptr, const char *format, ...)
{
proto_item *pi;
va_list ap;
@ -487,7 +487,7 @@ proto_tree_add_bytes_format(proto_tree *tree, int hfindex, gint start, gint leng
/* Set the FT_BYTES value */
static void
proto_tree_set_bytes(field_info *fi, guint8* start_ptr, gint length)
proto_tree_set_bytes(field_info *fi, const guint8* start_ptr, gint length)
{
/* This g_malloc'ed memory is freed in
@ -629,7 +629,7 @@ proto_tree_set_ipv6(field_info *fi, guint8* value_ptr)
/* Add a FT_STRING to a proto_tree */
proto_item *
proto_tree_add_string_format(proto_tree *tree, int hfindex, gint start, gint length,
char* value, const char *format, ...)
const char* value, const char *format, ...)
{
proto_item *pi;
va_list ap;
@ -653,7 +653,7 @@ proto_tree_add_string_format(proto_tree *tree, int hfindex, gint start, gint len
/* Set the FT_STRING value */
static void
proto_tree_set_string(field_info *fi, char* value)
proto_tree_set_string(field_info *fi, const char* value)
{
/* This g_strdup'ed memory is freed in proto_tree_free_node() */
fi->value.string = g_strdup(value);
@ -760,7 +760,7 @@ proto_item *
proto_tree_add_uint_format(proto_tree *tree, int hfindex, gint start, gint length,
guint32 value, const char *format, ...)
{
proto_item *pi;
proto_item *pi = NULL;
va_list ap;
field_info *new_fi;
header_field_info *hfinfo;

10
proto.h
View File

@ -1,7 +1,7 @@
/* proto.h
* Definitions for protocol display
*
* $Id: proto.h,v 1.24 2000/03/12 04:47:54 gram Exp $
* $Id: proto.h,v 1.25 2000/03/14 06:03:26 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -208,12 +208,12 @@ proto_tree_add_protocol_format(proto_tree *tree, int hfindex, gint start,
#if __GNUC__ == 2
proto_item *
proto_tree_add_bytes_format(proto_tree *tree, int hfindex, gint start,
gint length, guint8* start_ptr, const char *format, ...)
gint length, const guint8* start_ptr, const char *format, ...)
__attribute__((format (printf, 6, 7)));
#else
proto_item *
proto_tree_add_bytes_format(proto_tree *tree, int hfindex, gint start,
gint length, guint8* start_ptr, const char *format, ...);
gint length, const guint8* start_ptr, const char *format, ...);
#endif
#if __GNUC__ == 2
@ -274,12 +274,12 @@ proto_tree_add_ether_format(proto_tree *tree, int hfindex, gint start,
#if __GNUC__ == 2
proto_item *
proto_tree_add_string_format(proto_tree *tree, int hfindex, gint start,
gint length, char* value, const char *format, ...)
gint length, const char* value, const char *format, ...)
__attribute__((format (printf, 6, 7)));
#else
proto_item *
proto_tree_add_string_format(proto_tree *tree, int hfindex, gint start,
gint length, char* value, const char *format, ...);
gint length, const char* value, const char *format, ...);
#endif
#if __GNUC__ == 2

10
xdlc.c
View File

@ -2,7 +2,7 @@
* Routines for use by various SDLC-derived protocols, such as HDLC
* and its derivatives LAPB, IEEE 802.2 LLC, etc..
*
* $Id: xdlc.c,v 1.12 2000/03/12 04:47:55 gram Exp $
* $Id: xdlc.c,v 1.13 2000/03/14 06:03:26 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -251,7 +251,7 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
if (is_extended) {
tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control,
offset, 2,
frame_type,
control,
"Control field: %s (0x%04X)", info, control);
control_tree = proto_item_add_subtree(tc, ett_xdlc_control);
proto_tree_add_text(control_tree, offset, 2,
@ -272,7 +272,7 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
} else {
tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control,
offset, 1,
frame_type,
control,
"Control field: %s (0x%02X)", info, control);
control_tree = proto_item_add_subtree(tc, ett_xdlc_control);
proto_tree_add_text(control_tree, offset, 1,
@ -325,7 +325,7 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
if (xdlc_tree) {
tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control,
offset, 1,
frame_type,
control,
"Control field: %s (0x%02X)", info, control);
control_tree = proto_item_add_subtree(tc, ett_xdlc_control);
if (control & XDLC_P_F) {
@ -368,7 +368,7 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
if (xdlc_tree) {
tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control,
offset, (is_extended) ? 2 : 1,
frame_type,
control,
(is_extended) ? "Control field: %s (0x%04X)"
: "Control field: %s (0x%02X)",
info, control);