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
This commit is contained in:
parent
734ec176e1
commit
4f34bb9b15
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue