diff options
author | Ulf Lamping <ulf.lamping@web.de> | 2005-08-08 18:50:39 +0000 |
---|---|---|
committer | Ulf Lamping <ulf.lamping@web.de> | 2005-08-08 18:50:39 +0000 |
commit | 0dc9fb3d4ab00d14bf45c597471e10e601efd4d4 (patch) | |
tree | ae44175ca8fd23548fcec5833098b535af5e372c /plugins | |
parent | f3407856f4fd97caf90655205cdb2c66991e75ba (diff) |
various code cleanup:
-use g_snprintf instead of sprintf and snprintf
-use g_strdup_printf where appropriate
-remove #include "snprintf.h" (as only g_snprintf should be used)
-replace some more alloc/realloc/calloc/free with their glib pendants
svn path=/trunk/; revision=15264
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/asn1/packet-asn1.c | 44 | ||||
-rw-r--r-- | plugins/ciscosm/packet-sm.c | 4 | ||||
-rw-r--r-- | plugins/docsis/packet-vendor.c | 4 | ||||
-rw-r--r-- | plugins/irda/packet-ircomm.c | 3 | ||||
-rw-r--r-- | plugins/irda/packet-irda.c | 8 | ||||
-rw-r--r-- | plugins/opsi/packet-opsi.c | 4 | ||||
-rw-r--r-- | plugins/rlm/packet-rlm.c | 4 | ||||
-rw-r--r-- | plugins/v5ua/packet-v5ua.c | 4 |
8 files changed, 24 insertions, 51 deletions
diff --git a/plugins/asn1/packet-asn1.c b/plugins/asn1/packet-asn1.c index 22b54558d0..1e965e00cb 100644 --- a/plugins/asn1/packet-asn1.c +++ b/plugins/asn1/packet-asn1.c @@ -624,7 +624,7 @@ checklength(int len, int def, int cls, int tag, char *lenstr, int strmax) int newlen = len; if ( ! def) { - snprintf(lenstr, strmax, "indefinite"); + g_snprintf(lenstr, strmax, "indefinite"); return len; } @@ -694,9 +694,9 @@ checklength(int len, int def, int cls, int tag, char *lenstr, int strmax) if (newlen != len) { /* a change was needed.... */ - snprintf(lenstr, strmax, "%d(changed from %d)", newlen, len); + g_snprintf(lenstr, strmax, "%d(changed from %d)", newlen, len); } else { - snprintf(lenstr, strmax, "%d", len); + g_snprintf(lenstr, strmax, "%d", len); } return newlen; } @@ -750,7 +750,7 @@ dissect_asn1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { offstr[0] = 0; if ((first_pdu_offset > 0) && !reassembled) { boffset = first_pdu_offset; - snprintf(offstr, sizeof(offstr), " at %d", boffset); + g_snprintf(offstr, sizeof(offstr), " at %d", boffset); } /* open BER decoding */ @@ -769,9 +769,9 @@ dissect_asn1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { if (asn1_debug) { - snprintf(tagstr, sizeof(tagstr), "%ctag%d", tag_class[cls], tag); + g_snprintf(tagstr, sizeof(tagstr), "%ctag%d", tag_class[cls], tag); - snprintf(headstr, sizeof(headstr), "first%s: (%s)%s %d %s, %s, %s, len=%s, off=%d, size=%d ", + g_snprintf(headstr, sizeof(headstr), "first%s: (%s)%s %d %s, %s, %s, len=%s, off=%d, size=%d ", offstr, tname, name, @@ -785,10 +785,10 @@ dissect_asn1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ); } else { if (props.flags & OUT_FLAG_noname) { - snprintf(tagstr, sizeof(tagstr), "%ctag%d", tag_class[cls], tag); + g_snprintf(tagstr, sizeof(tagstr), "%ctag%d", tag_class[cls], tag); name = ((cls == ASN1_UNI) && (tag < 32)) ? asn1_tag[tag] : tagstr; } - snprintf(headstr, sizeof(headstr), "first pdu%s: (%s)%s ", offstr, tname, name ); + g_snprintf(headstr, sizeof(headstr), "first pdu%s: (%s)%s ", offstr, tname, name ); } /* Set the info column */ @@ -837,9 +837,9 @@ dissect_asn1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { if (asn1_debug) { - snprintf(tagstr, sizeof(tagstr), "%ctag%d", tag_class[cls], tag); + g_snprintf(tagstr, sizeof(tagstr), "%ctag%d", tag_class[cls], tag); - snprintf(headstr, sizeof(headstr), "%s, %s, %s, len=%s, off=%d, remaining=%d", + g_snprintf(headstr, sizeof(headstr), "%s, %s, %s, len=%s, off=%d, remaining=%d", asn1_cls[cls], asn1_con[con], ((cls == ASN1_UNI) && (tag < 32)) ? asn1_tag[tag] : tagstr, @@ -865,7 +865,7 @@ dissect_asn1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { } } else { if (props.flags & OUT_FLAG_noname) { - snprintf(tagstr, sizeof(tagstr), "%ctag%d", tag_class[cls], tag); + g_snprintf(tagstr, sizeof(tagstr), "%ctag%d", tag_class[cls], tag); name = ((cls == ASN1_UNI) && (tag < 32)) ? asn1_tag[tag] : tagstr; } if (props.value_id == -1) @@ -985,14 +985,14 @@ decode_asn1_sequence(tvbuff_t *tvb, guint offset, guint tlen, proto_tree *pt, in if ((cls == ASN1_UNI) && ( tag < 32 )) { tagstr = asn1_tag[tag]; } else { - snprintf(tagbuf, sizeof(tagbuf), "%ctag%d", tag_class[cls], tag); + g_snprintf(tagbuf, sizeof(tagbuf), "%ctag%d", tag_class[cls], tag); tagstr = tagbuf; } len = checklength(len, def, cls, tag, lenbuf, sizeof(lenbuf)); if (def) { - snprintf(nnbuf, sizeof(nnbuf), "NN%d", len); + g_snprintf(nnbuf, sizeof(nnbuf), "NN%d", len); } else { strncpy(nnbuf, "NN-", sizeof(nnbuf)); /* make sure we get an exception if we run off the end! */ @@ -1737,11 +1737,11 @@ parse_tt3(tvbuff_t *tvb, guint offset, guint size, guint level, GNode *ptr) if ((cls == ASN1_UNI) && ( tag < 32 )) { tagstr = asn1_tag[tag]; } else { - snprintf(tagbuf, sizeof(tagbuf), "tag%d", tag); + g_snprintf(tagbuf, sizeof(tagbuf), "tag%d", tag); tagstr = tagbuf; } if (def) { - snprintf(lenbuf, sizeof(lenbuf), "%d", len); + g_snprintf(lenbuf, sizeof(lenbuf), "%d", len); } else { strncpy(lenbuf, "indefinite", sizeof(lenbuf)); len = tvb_length_remaining(tvb, offset); @@ -1817,7 +1817,7 @@ parse_tt3(tvbuff_t *tvb, guint offset, guint size, guint level, GNode *ptr) case ASN1_CTX: /* fprintf(stderr, "Context\n"); */ tagstr = tagbuf; - snprintf(tagbuf, sizeof(tagbuf), "TAG%d", tag); + g_snprintf(tagbuf, sizeof(tagbuf), "TAG%d", tag); if (def && !con) { /* defined length, not constructed, must be a string.... */ asn1_string_value_decode(&asn1, len, &octets); /* read value */ @@ -1863,11 +1863,11 @@ myLeaf(GNode *node, gpointer data) if ((cls == ASN1_UNI) && ( tag < 32 )) { tagstr = asn1_tag[tag]; } else { - snprintf(tagbuf, sizeof(tagbuf), "tag%d", tag); + g_snprintf(tagbuf, sizeof(tagbuf), "tag%d", tag); tagstr = tagbuf; } if (def) { - snprintf(lenbuf, sizeof(lenbuf), "%d", len); + g_snprintf(lenbuf, sizeof(lenbuf), "%d", len); } else { strncpy(lenbuf, "indefinite", sizeof(lenbuf)); } @@ -2907,7 +2907,7 @@ tbl_typeref(guint n, GNode *pdu, GNode *tree, guint fullindex) ss[0] = 0; if (p->tclass==CLASSREF) - snprintf(ss, 128, ", CLASSREF %d", p->tag); + g_snprintf(ss, 128, ", CLASSREF %d", p->tag); if (asn1_verbose) g_message("%*sno typeref tag%s", n*2, empty, ss); if (p->tclass==CLASSREF) { @@ -4863,13 +4863,13 @@ proto_register_asn1(void) { "ASN.1 messages will be read", 10, &global_sctp_port_asn1); #else - snprintf(tmpstr, sizeof(tmpstr), "%u", TCP_PORT_ASN1); + g_snprintf(tmpstr, sizeof(tmpstr), "%u", TCP_PORT_ASN1); range_convert_str(&global_tcp_ports_asn1, tmpstr, 65535); - snprintf(tmpstr, sizeof(tmpstr), "%u", UDP_PORT_ASN1); + g_snprintf(tmpstr, sizeof(tmpstr), "%u", UDP_PORT_ASN1); range_convert_str(&global_udp_ports_asn1, tmpstr, 65535); - snprintf(tmpstr, sizeof(tmpstr), "%u", SCTP_PORT_ASN1); + g_snprintf(tmpstr, sizeof(tmpstr), "%u", SCTP_PORT_ASN1); range_convert_str(&global_sctp_ports_asn1, tmpstr, 65535); prefs_register_range_preference(asn1_module, "tcp_ports", diff --git a/plugins/ciscosm/packet-sm.c b/plugins/ciscosm/packet-sm.c index fb719a053e..6dc593729e 100644 --- a/plugins/ciscosm/packet-sm.c +++ b/plugins/ciscosm/packet-sm.c @@ -53,10 +53,6 @@ #include <stdlib.h> #include <string.h> -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif - #include <gmodule.h> #include <epan/packet.h> diff --git a/plugins/docsis/packet-vendor.c b/plugins/docsis/packet-vendor.c index 9bb56402c2..2e341a7dd5 100644 --- a/plugins/docsis/packet-vendor.c +++ b/plugins/docsis/packet-vendor.c @@ -61,10 +61,6 @@ #include <gmodule.h> -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif - #include <epan/packet.h> /* Define Vendor ID's here */ diff --git a/plugins/irda/packet-ircomm.c b/plugins/irda/packet-ircomm.c index 0148f89747..20f2c96ded 100644 --- a/plugins/irda/packet-ircomm.c +++ b/plugins/irda/packet-ircomm.c @@ -39,9 +39,6 @@ #include <epan/packet.h> #include <epan/proto.h> -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif /* * See diff --git a/plugins/irda/packet-irda.c b/plugins/irda/packet-irda.c index 53e50258d6..e3d607b010 100644 --- a/plugins/irda/packet-irda.c +++ b/plugins/irda/packet-irda.c @@ -44,10 +44,6 @@ #include <epan/conversation.h> #include <epan/xdlc.h> -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif - #include "irda-appl.h" /* @@ -838,7 +834,7 @@ static void dissect_iap_result(tvbuff_t* tvb, packet_info* pinfo, proto_tree* ro } ti = proto_tree_add_item(tree, hf_iap_list_entry, tvb, offset, 2 + 1 + attr_len, FALSE); - snprintf(buf, sizeof(buf) - 1, "%d", n + 1); + g_snprintf(buf, sizeof(buf) - 1, "%d", n + 1); proto_item_append_text(ti, buf); entry_tree = proto_item_add_subtree(ti, ett_iap_entry[n]); @@ -1770,7 +1766,7 @@ static void dissect_irlap(tvbuff_t* tvb, packet_info* pinfo, proto_tree* root) pinfo->circuit_id = a; /* initially set address columns to connection address */ - snprintf(addr, sizeof(addr)-1, "0x%02X", a >> 1); + g_snprintf(addr, sizeof(addr)-1, "0x%02X", a >> 1); if (check_col(pinfo->cinfo, COL_DEF_SRC)) col_add_str(pinfo->cinfo, COL_DEF_SRC, addr); if (check_col(pinfo->cinfo, COL_DEF_DST)) diff --git a/plugins/opsi/packet-opsi.c b/plugins/opsi/packet-opsi.c index b93e749bab..c18d368879 100644 --- a/plugins/opsi/packet-opsi.c +++ b/plugins/opsi/packet-opsi.c @@ -36,10 +36,6 @@ #include <glib.h> -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif - #include <epan/packet.h> #include <epan/dissectors/packet-tcp.h> #include <epan/prefs.h> diff --git a/plugins/rlm/packet-rlm.c b/plugins/rlm/packet-rlm.c index 8c9d9c6a5c..10f5a2d7b6 100644 --- a/plugins/rlm/packet-rlm.c +++ b/plugins/rlm/packet-rlm.c @@ -55,10 +55,6 @@ #include <stdlib.h> #include <string.h> -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif - #include <gmodule.h> #include <epan/packet.h> diff --git a/plugins/v5ua/packet-v5ua.c b/plugins/v5ua/packet-v5ua.c index bdf0c494d6..f02901605b 100644 --- a/plugins/v5ua/packet-v5ua.c +++ b/plugins/v5ua/packet-v5ua.c @@ -50,10 +50,6 @@ G_MODULE_EXPORT const gchar version[] = VERSION; #include "sctpppids.h" /* include V5UA payload protocol ID */ -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif - #include <epan/packet.h> |