aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2009-03-18 15:03:46 +0000
committerBill Meier <wmeier@newsguy.com>2009-03-18 15:03:46 +0000
commit4f34bb9b15615f1b5a5fd3d6cf403179a37b0ccf (patch)
tree794701a6faa040c73f71d8f12b5569a3c1780499
parent734ec176e151c2b4e735d46d3b40a6b44afbe32e (diff)
From Jakub Zawadzki: g_gnprintf & etc: Use size of buffer [not size -1];
- As suggested actually use sizeof(...) rather than a numeric constant. - g_snprintf() and g_vsnprintf() since glib 1.3.12 do not return -1. svn path=/trunk/; revision=27772
-rw-r--r--epan/dissectors/packet-isakmp.c6
-rw-r--r--epan/expert.c5
-rw-r--r--gtk/mac_lte_stat_dlg.c6
-rw-r--r--plugins/mate/mate_util.c2
4 files changed, 8 insertions, 11 deletions
diff --git a/epan/dissectors/packet-isakmp.c b/epan/dissectors/packet-isakmp.c
index 5e369cb102..bf6076af83 100644
--- a/epan/dissectors/packet-isakmp.c
+++ b/epan/dissectors/packet-isakmp.c
@@ -2661,7 +2661,7 @@ situation2str(guint32 type)
if (type & SIT_IDENTITY) {
ret = g_snprintf(msg, SIT_MSG_NUM-n, "%sIDENTITY", sep);
- if (ret == -1 || ret >= SIT_MSG_NUM-n) {
+ if (ret >= SIT_MSG_NUM-n) {
/* Truncated. */
return msg;
}
@@ -2674,7 +2674,7 @@ situation2str(guint32 type)
return msg;
}
ret = g_snprintf(msg, SIT_MSG_NUM-n, "%sSECRECY", sep);
- if (ret == -1 || ret >= SIT_MSG_NUM-n) {
+ if (ret >= SIT_MSG_NUM-n) {
/* Truncated. */
return msg;
}
@@ -2687,7 +2687,7 @@ situation2str(guint32 type)
return msg;
}
ret = g_snprintf(msg, SIT_MSG_NUM-n, "%sINTEGRITY", sep);
- if (ret == -1 || ret >= SIT_MSG_NUM-n) {
+ if (ret >= SIT_MSG_NUM-n) {
/* Truncated. */
return msg;
}
diff --git a/epan/expert.c b/epan/expert.c
index 99080f74ff..ab7d9d845d 100644
--- a/epan/expert.c
+++ b/epan/expert.c
@@ -150,7 +150,6 @@ static void
expert_set_info_vformat(
packet_info *pinfo, proto_item *pi, int group, int severity, const char *format, va_list ap)
{
- int ret; /*tmp return value */
char formatted[300];
expert_info_t *ei;
proto_tree *tree;
@@ -167,9 +166,7 @@ packet_info *pinfo, proto_item *pi, int group, int severity, const char *format,
}
/* XXX - use currently nonexistant se_vsnprintf instead */
- ret = g_vsnprintf(formatted, sizeof(formatted), format, ap);
- if ((ret == -1) || (ret >= (int)sizeof(formatted)))
- formatted[sizeof(formatted) - 1] = '\0';
+ g_vsnprintf(formatted, sizeof(formatted), format, ap);
ei = ep_alloc(sizeof(expert_info_t));
ei->packet_num = pinfo->fd->num;
diff --git a/gtk/mac_lte_stat_dlg.c b/gtk/mac_lte_stat_dlg.c
index b73693dee9..4cb2aeb6ea 100644
--- a/gtk/mac_lte_stat_dlg.c
+++ b/gtk/mac_lte_stat_dlg.c
@@ -186,12 +186,12 @@ mac_lte_stat_reset(void *phs)
/* Set the title */
if (mac_lte_stat_dlg_w != NULL) {
- g_snprintf (title, 255, "Wireshark: LTE MAC Traffic Statistics: %s",
+ g_snprintf (title, sizeof(title), "Wireshark: LTE MAC Traffic Statistics: %s",
cf_get_display_name(&cfile));
gtk_window_set_title(GTK_WINDOW(mac_lte_stat_dlg_w), title);
}
- g_snprintf(title, 255, "UL/DL-SCH data");
+ g_snprintf(title, sizeof(title), "UL/DL-SCH data");
gtk_frame_set_label(GTK_FRAME(mac_lte_stat_ues_lb), title);
memset(&common_stats, 0, sizeof(common_stats));
@@ -574,7 +574,7 @@ static void mac_lte_stat_dlg_create(void)
hs->number_of_packets = 0;
/* Set title */
- g_snprintf(title, 255, "Wireshark: LTE MAC Statistics: %s",
+ g_snprintf(title, sizeof(title), "Wireshark: LTE MAC Statistics: %s",
cf_get_display_name(&cfile));
mac_lte_stat_dlg_w = window_new_with_geom(GTK_WINDOW_TOPLEVEL, title, "LTE MAC Statistics");
diff --git a/plugins/mate/mate_util.c b/plugins/mate/mate_util.c
index caec284d16..ade8fb2285 100644
--- a/plugins/mate/mate_util.c
+++ b/plugins/mate/mate_util.c
@@ -242,7 +242,7 @@ gchar* scs_subscribe_printf(SCS_collection* c, gchar* fmt, ...) {
static gchar buf[SCS_HUGE_SIZE];
va_start( list, fmt );
- g_vsnprintf(buf, SCS_HUGE_SIZE-1 ,fmt, list);
+ g_vsnprintf(buf, SCS_HUGE_SIZE, fmt, list);
va_end( list );
return scs_subscribe(c,buf);