several times replacing:

sprintf -> g_snprintf
snprintf -> g_snprintf
vsnprintf -> g_vsnprintf
strdup -> g_strdup

svn path=/trunk/; revision=15412
This commit is contained in:
Ulf Lamping 2005-08-18 19:31:15 +00:00
parent e5af0106ac
commit 994496a184
18 changed files with 37 additions and 37 deletions

View File

@ -377,6 +377,6 @@ static void reset_h245_packet_info(h245_packet_info *pi)
pi->msg_type = H245_OTHER;
pi->frame_label[0] = '\0';
sprintf(pi->comment, "H245 ");
g_snprintf(pi->comment, sizeof(pi->comment), "H245 ");
}

View File

@ -198,7 +198,6 @@
#define NEED_GETOPT_H 1
#define NEED_STRPTIME_H 1
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define strcasecmp stricmp
#define strncasecmp strnicmp
#define open _open

View File

@ -252,7 +252,7 @@ col_add_fstr(column_info *cinfo, gint el, const gchar *format, ...) {
*/
cinfo->col_data[i] = cinfo->col_buf[i];
}
vsnprintf(&cinfo->col_buf[i][fence], max_len - fence, format, ap);
g_vsnprintf(&cinfo->col_buf[i][fence], max_len - fence, format, ap);
cinfo->col_buf[i][max_len - 1] = '\0';
}
}
@ -294,7 +294,7 @@ col_do_append_sep_va_fstr(column_info *cinfo, gint el, const gchar *separator,
len += sep_len;
}
}
vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap);
g_vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap);
cinfo->col_buf[i][max_len-1] = 0;
}
}
@ -357,7 +357,7 @@ col_prepend_fstr(column_info *cinfo, gint el, const gchar *format, ...)
orig_buf[max_len - 1] = '\0';
orig = orig_buf;
}
vsnprintf(cinfo->col_buf[i], max_len, format, ap);
g_vsnprintf(cinfo->col_buf[i], max_len, format, ap);
cinfo->col_buf[i][max_len - 1] = '\0';
/*

View File

@ -59,7 +59,7 @@ dfilter_fail(const char *format, ...)
va_start(args, format);
vsnprintf(dfilter_error_msg_buf, sizeof(dfilter_error_msg_buf),
g_vsnprintf(dfilter_error_msg_buf, sizeof(dfilter_error_msg_buf),
format, args);
dfilter_error_msg = dfilter_error_msg_buf;
va_end(args);

View File

@ -416,16 +416,16 @@ static gchar *print_tsap(const guchar *tsap, int length)
cur=ep_alloc(MAX_TSAP_LEN * 2 + 3);
cur[0] = '\0';
if (length <= 0 || length > MAX_TSAP_LEN)
sprintf(cur, "<unsupported TSAP length>");
g_snprintf(cur, MAX_TSAP_LEN * 2 + 3, "<unsupported TSAP length>");
else {
allprintable = is_all_printable(tsap,length);
if (!allprintable)
strcat(cur,"0x");
while (length != 0) {
if (allprintable)
sprintf(tmp, "%c", *tsap ++);
g_snprintf(tmp, sizeof(tmp), "%c", *tsap ++);
else
sprintf(tmp, "%02x", *tsap ++);
g_snprintf(tmp, sizeof(tmp), "%02x", *tsap ++);
strcat(cur, tmp);
length --;
}

View File

@ -1309,7 +1309,7 @@ static guchar*format_asn_value (struct variable_list *variable, subid_t *variabl
variable->type=mib_to_asn_type(subtree->type);
if (!sprint_realloc_by_type(&buf, &buf_len, &out_len, TRUE, variable, subtree->enums, subtree->hint, NULL))
sprintf(buf,"%s","sprint_realloc_by_type failed");
g_snprintf(buf,SPRINT_MAX_LEN,"%s","sprint_realloc_by_type failed");
return buf;
}
@ -1486,8 +1486,8 @@ static int decode_cops_pr_asn1_data(tvbuff_t *tvb, guint32 offset,
* to the end of the string.
*/
vb_display_string = g_malloc(4*vb_length);
buf = &vb_display_string[0];
len = sprintf(buf, "%03u", vb_octet_string[0]);
buf = vb_display_string;
len = g_snprintf(buf, 4*vb_length, "%03u", vb_octet_string[0]);
buf += len;
for (i = 1; i < vb_length; i++) {
len = sprintf(buf, ".%03u", vb_octet_string[i]);
@ -2657,7 +2657,7 @@ cops_transaction_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *st, guint8 op
val_to_str(code16,table_cops_dqos_transaction_id, "Unknown (0x%04x)"),code16);
/* Write the right data into the 'info field' on the Gui */
sprintf(info,"COPS %-20s - ",val_to_str(op_code,cops_op_code_vals, "Unknown"));
g_snprintf(info,sizeof(info),"COPS %-20s - ",val_to_str(op_code,cops_op_code_vals, "Unknown"));
strcat(info,val_to_str(code16,table_cops_dqos_transaction_id, "Unknown"));
if (check_col(pinfo->cinfo, COL_INFO)) {
@ -3053,7 +3053,7 @@ cops_mm_transaction_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *st, guint8
val_to_str(code16,table_cops_mm_transaction_id, "Unknown (0x%04x)"),code16);
/* Write the right data into the 'info field' on the Gui */
sprintf(info,"COPS %-20s - ",val_to_str(op_code,cops_op_code_vals, "Unknown"));
g_snprintf(info,sizeof(info),"COPS %-20s - ",val_to_str(op_code,cops_op_code_vals, "Unknown"));
strcat(info,val_to_str(code16,table_cops_mm_transaction_id, "Unknown"));
if (check_col(pinfo->cinfo, COL_INFO)) {

View File

@ -1069,7 +1069,7 @@ diameter_avp_get_name(guint32 avpCode, guint32 vendorId)
avpCode, vendorId);
/* If we don't find it, build a name string */
sprintf(buffer, "Unknown AVP:0x%08x", avpCode);
g_snprintf(buffer, sizeof(buffer), "Unknown AVP:0x%08x", avpCode);
return buffer;
} /* diameter_avp_get_name */
static const gchar *

View File

@ -734,7 +734,7 @@ rfc1867_angle(tvbuff_t *tvb, int offset, const char *nsew)
angle = angle / 60;
minutes = angle % 60;
degrees = angle / 60;
sprintf(buf, "%u deg %u min %u.%03u sec %c", degrees, minutes, secs,
g_snprintf(buf, sizeof(buf), "%u deg %u min %u.%03u sec %c", degrees, minutes, secs,
tsecs, direction);
return buf;
}

View File

@ -1151,7 +1151,7 @@ dissect_fcdns_zone_mbr (tvbuff_t *tvb, proto_tree *zmbr_tree, int offset)
8)));
break;
case FC_SWILS_ZONEMBR_DP:
sprintf(dpbuf, "0x%08x", tvb_get_ntohl (tvb, offset+4));
g_snprintf(dpbuf, sizeof(dpbuf), "0x%08x", tvb_get_ntohl (tvb, offset+4));
proto_tree_add_string (zmbr_tree, hf_fcdns_zone_mbrid, tvb,
offset+4, 4, dpbuf);
break;

View File

@ -1009,7 +1009,7 @@ dissect_swils_zone_mbr (tvbuff_t *tvb, proto_tree *zmbr_tree, int offset)
8)));
break;
case FC_SWILS_ZONEMBR_DP:
sprintf(dpbuf, "0x%08x", tvb_get_ntohl (tvb, offset+4));
g_snprintf(dpbuf, sizeof(dpbuf), "0x%08x", tvb_get_ntohl (tvb, offset+4));
proto_tree_add_string (zmbr_tree, hf_swils_zone_mbrid, tvb,
offset+4, 4, dpbuf);
break;
@ -1035,7 +1035,7 @@ dissect_swils_zone_mbr (tvbuff_t *tvb, proto_tree *zmbr_tree, int offset)
offset+12, 8, 0);
break;
case FC_SWILS_ZONEMBR_DP_LUN:
sprintf(dpbuf, "0x%08x", tvb_get_ntohl (tvb, offset+4));
g_snprintf(dpbuf, sizeof(dpbuf), "0x%08x", tvb_get_ntohl (tvb, offset+4));
proto_tree_add_string (zmbr_tree, hf_swils_zone_mbrid, tvb,
offset+4, 4, dpbuf);
proto_tree_add_item (zmbr_tree, hf_swils_zone_mbrid_lun, tvb,

View File

@ -219,35 +219,35 @@ fddifc_to_str(int fc)
switch (fc & FDDI_FC_CLFF) {
case FDDI_FC_MAC:
sprintf(strbuf, "MAC frame, control %x", fc & FDDI_FC_ZZZZ);
g_snprintf(strbuf, sizeof(strbuf), "MAC frame, control %x", fc & FDDI_FC_ZZZZ);
return strbuf;
case FDDI_FC_SMT:
sprintf(strbuf, "SMT frame, control %x", fc & FDDI_FC_ZZZZ);
g_snprintf(strbuf, sizeof(strbuf), "SMT frame, control %x", fc & FDDI_FC_ZZZZ);
return strbuf;
case FDDI_FC_LLC_ASYNC:
if (fc & FDDI_FC_ASYNC_R)
sprintf(strbuf, "Async LLC frame, control %x", fc & FDDI_FC_ZZZZ);
g_snprintf(strbuf, sizeof(strbuf), "Async LLC frame, control %x", fc & FDDI_FC_ZZZZ);
else
sprintf(strbuf, "Async LLC frame, priority %d",
g_snprintf(strbuf, sizeof(strbuf), "Async LLC frame, priority %d",
fc & FDDI_FC_ASYNC_PRI);
return strbuf;
case FDDI_FC_LLC_SYNC:
if (fc & FDDI_FC_ZZZZ) {
sprintf(strbuf, "Sync LLC frame, control %x", fc & FDDI_FC_ZZZZ);
g_snprintf(strbuf, sizeof(strbuf), "Sync LLC frame, control %x", fc & FDDI_FC_ZZZZ);
return strbuf;
} else
return "Sync LLC frame";
case FDDI_FC_IMP_ASYNC:
sprintf(strbuf, "Implementor async frame, control %x",
g_snprintf(strbuf, sizeof(strbuf), "Implementor async frame, control %x",
fc & FDDI_FC_ZZZZ);
return strbuf;
case FDDI_FC_IMP_SYNC:
sprintf(strbuf, "Implementor sync frame, control %x",
g_snprintf(strbuf, sizeof(strbuf), "Implementor sync frame, control %x",
fc & FDDI_FC_ZZZZ);
return strbuf;
break;

View File

@ -151,7 +151,7 @@ dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_clear(pinfo->cinfo, COL_INFO);
/* sprintf(header, fw1_header); */
/* g_snprintf(header, sizeof(header), fw1_header); */
/* fetch info to local variable */
direction = tvb_get_guint8(tvb, 0);

View File

@ -22837,6 +22837,6 @@ static void reset_h245_packet_info(h245_packet_info *pi)
pi->msg_type = H245_OTHER;
pi->frame_label[0] = '\0';
sprintf(pi->comment, "H245 ");
g_snprintf(pi->comment, sizeof(pi->comment), "H245 ");
}

View File

@ -414,7 +414,8 @@ static gchar *key_to_str( const iax_circuit_key *key )
/* why doesn't address_to_str take a const pointer?
cast the warnings into oblivion. */
sprintf(strp,"{%s:%i,%i}",
/* XXX - is this a case for ep_alloc? */
g_snprintf(strp, 80, "{%s:%i,%i}",
address_to_str((address *)&key->addr),
key->port,
key->callno);

View File

@ -327,9 +327,7 @@ static void dissect_ice_facet(proto_tree *tree, int hf_icep,
if ( Size == 0 ) {
if (tree) {
s = ep_alloc( strlen("(empty)") + 1 );
sprintf(s, "(empty)");
s[strlen("(empty)")] = '\0';
s = ep_strdup( "(empty)" );
/* display the 0x00 Size byte when click on a empty ice_string */
proto_tree_add_string(tree, hf_icep, tvb, offset - 1, 1, s);
}

View File

@ -403,7 +403,7 @@ char *get_plugins_global_dir(const char *plugin_dir)
/*
* Scan the plugin directory.
*/
return strdup(plugin_dir);
return g_strdup(plugin_dir);
#endif
}

View File

@ -525,7 +525,7 @@ proto_tree_free_node(proto_node *node, gpointer data _U_)
/* Is the parsing being done for a visible proto_tree or an invisible one?
* By setting this correctly, the proto_tree creation is sped up by not
* having to call vsnprintf and copy strings around.
* having to call g_vsnprintf and copy strings around.
*/
void
proto_tree_set_visible(proto_tree *tree, gboolean visible)
@ -2359,7 +2359,7 @@ proto_tree_set_representation(proto_item *pi, const char *format, va_list ap)
if (!PROTO_ITEM_IS_HIDDEN(pi)) {
ITEM_LABEL_NEW(fi->rep);
ret = vsnprintf(fi->rep->representation, ITEM_LABEL_LENGTH, format, ap);
ret = g_vsnprintf(fi->rep->representation, ITEM_LABEL_LENGTH, format, ap);
if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
fi->rep->representation[ITEM_LABEL_LENGTH - 1] = '\0';
}
@ -2416,7 +2416,7 @@ proto_item_append_text(proto_item *pi, const char *format, ...)
curlen = strlen(fi->rep->representation);
if (ITEM_LABEL_LENGTH > curlen) {
ret = vsnprintf(fi->rep->representation + curlen,
ret = g_vsnprintf(fi->rep->representation + curlen,
ITEM_LABEL_LENGTH - curlen, format, ap);
if ((ret == -1) || (ret >= (int)(ITEM_LABEL_LENGTH - curlen)))
fi->rep->representation[ITEM_LABEL_LENGTH - 1] = '\0';

View File

@ -41,6 +41,8 @@
#include <process.h> /* For spawning child process */
#endif
#include <glib.h>
#ifndef __set_errno
#define __set_errno(x) errno=(x)
#endif
@ -65,7 +67,7 @@ mkstemp (template)
return -1;
}
if (sprintf (&template[len - 5], "%.5u",
if (g_snprintf (&template[len - 5], 6, "%.5u",
(unsigned int) getpid () % 100000) != 5)
/* Inconceivable lossage. */
return -1;