Fix some errors discovered by making GCC do format string/argument
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 14 Mar 2000 06:03:26 +0000 (06:03 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 14 Mar 2000 06:03:26 +0000 (06:03 +0000)
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.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1716 f5534014-38df-0310-8fa8-9805f1628bb7

packet-ipv6.c
packet-l2tp.c
packet-ospf.c
packet-rsvp.c
proto.c
proto.h
xdlc.c

index d8c7e425a244541a81aab97e69c2d1ad747e9fea..9d7a1882bb8b134e7bd9fd80c217fead0231d5c3 100644 (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),
index c6a5556aabb2a4a3f071dc4543505e735fc1e2bc..80a12fed1a7ef0364680e10c11de48a89dd82987 100644 (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:
index 2ba07f91cec627023c567b7676edbb9f4fa6b20f..2bdd77771df39187b944daba46eeefea6f4a0e4d 100644 (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;
                    
index ac8e5726832bec44cbe94e5f128032f978a1bade..698666938d181797bf96517098266505ebd85282 100644 (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;
diff --git a/proto.c b/proto.c
index 6935f491dfa17fdcc2488cbc65acbd070ef42b3e..6abb4bfa085e5814c3969b0ea4fa97a679f7e81a 100644 (file)
--- a/proto.c
+++ b/proto.c
@@ -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;
diff --git a/proto.h b/proto.h
index 044cc3a9556d0ee89573f170d0ca567588360cb7..95f69088b5916941911e61759c2f2ef56294fb23 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -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
diff --git a/xdlc.c b/xdlc.c
index d6a99c9bb5f1b64f12932e499a5d65fbba60a4e0..1bbd6d5fa4394f413f402f93258ca2ae686f968b 100644 (file)
--- a/xdlc.c
+++ b/xdlc.c
@@ -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);