epan: Convert to use stdio.h from GLib

Replace:
    g_snprintf() -> snprintf()
    g_vsnprintf() -> vsnprintf()
    g_strdup_printf() -> ws_strdup_printf()
    g_strdup_vprintf() -> ws_strdup_vprintf()

This is more portable, user-friendly and faster on platforms
where GLib does not like the native I/O.

Adjust the format string to use macros from intypes.h.
This commit is contained in:
João Valverde 2021-12-16 18:06:18 +00:00 committed by Wireshark GitLab Utility
parent 737d1dc125
commit c5a19582e4
59 changed files with 333 additions and 336 deletions

View File

@ -390,7 +390,7 @@ dnsserver_uat_fld_ip_chk_cb(void* r _U_, const char* ipaddr, guint len _U_, cons
return TRUE;
}
*err = g_strdup_printf("No valid IP address given.");
*err = ws_strdup_printf("No valid IP address given.");
return FALSE;
}
@ -952,7 +952,7 @@ enterprises_base_custom(char *buf, guint32 value)
if ((s = try_enterprises_lookup(value)) == NULL)
s = ITEM_LABEL_UNKNOWN_STR;
g_snprintf(buf, ITEM_LABEL_LENGTH, "%s (%u)", s, value);
snprintf(buf, ITEM_LABEL_LENGTH, "%s (%u)", s, value);
}
static void
@ -1006,9 +1006,9 @@ fill_dummy_ip4(const guint addr, hashipv4_t* volatile tp)
}
/* There are more efficient ways to do this, but this is safe if we
* trust g_snprintf and MAXNAMELEN
* trust snprintf and MAXNAMELEN
*/
g_snprintf(tp->name, MAXNAMELEN, "%s%s", subnet_entry.name, paddr);
snprintf(tp->name, MAXNAMELEN, "%s%s", subnet_entry.name, paddr);
} else {
/* XXX: This means we end up printing "1.2.3.4 (1.2.3.4)" in many cases */
ip_to_str_buf((const guint8 *)&addr, tp->name, MAXNAMELEN);
@ -1789,7 +1789,7 @@ eth_addr_resolve(hashether_t *tp) {
do {
/* Only the topmost 5 bytes participate fully */
if ((name = wka_name_lookup(addr, mask+40)) != NULL) {
g_snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x",
snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x",
name, addr[5] & (0xFF >> mask));
tp->status = HASHETHER_STATUS_RESOLVED_DUMMY;
return tp;
@ -1800,7 +1800,7 @@ eth_addr_resolve(hashether_t *tp) {
do {
/* Only the topmost 4 bytes participate fully */
if ((name = wka_name_lookup(addr, mask+32)) != NULL) {
g_snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x:%02x",
snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x:%02x",
name, addr[4] & (0xFF >> mask), addr[5]);
tp->status = HASHETHER_STATUS_RESOLVED_DUMMY;
return tp;
@ -1811,7 +1811,7 @@ eth_addr_resolve(hashether_t *tp) {
do {
/* Only the topmost 3 bytes participate fully */
if ((name = wka_name_lookup(addr, mask+24)) != NULL) {
g_snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x:%02x:%02x",
snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x:%02x:%02x",
name, addr[3] & (0xFF >> mask), addr[4], addr[5]);
tp->status = HASHETHER_STATUS_RESOLVED_DUMMY;
return tp;
@ -1821,7 +1821,7 @@ eth_addr_resolve(hashether_t *tp) {
/* Now try looking in the manufacturer table. */
manuf_value = manuf_name_lookup(addr);
if ((manuf_value != NULL) && (manuf_value->status != HASHETHER_STATUS_UNRESOLVED)) {
g_snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x:%02x:%02x",
snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x:%02x:%02x",
manuf_value->resolved_name, addr[3], addr[4], addr[5]);
tp->status = HASHETHER_STATUS_RESOLVED_DUMMY;
return tp;
@ -1833,7 +1833,7 @@ eth_addr_resolve(hashether_t *tp) {
do {
/* Only the topmost 2 bytes participate fully */
if ((name = wka_name_lookup(addr, mask+16)) != NULL) {
g_snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x:%02x:%02x:%02x",
snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x:%02x:%02x:%02x",
name, addr[2] & (0xFF >> mask), addr[3], addr[4],
addr[5]);
tp->status = HASHETHER_STATUS_RESOLVED_DUMMY;
@ -1845,7 +1845,7 @@ eth_addr_resolve(hashether_t *tp) {
do {
/* Only the topmost byte participates fully */
if ((name = wka_name_lookup(addr, mask+8)) != NULL) {
g_snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x:%02x:%02x:%02x:%02x",
snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x:%02x:%02x:%02x:%02x",
name, addr[1] & (0xFF >> mask), addr[2], addr[3],
addr[4], addr[5]);
tp->status = HASHETHER_STATUS_RESOLVED_DUMMY;
@ -1857,7 +1857,7 @@ eth_addr_resolve(hashether_t *tp) {
do {
/* Not even the topmost byte participates fully */
if ((name = wka_name_lookup(addr, mask)) != NULL) {
g_snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x:%02x:%02x:%02x:%02x:%02x",
snprintf(tp->resolved_name, MAXNAMELEN, "%s_%02x:%02x:%02x:%02x:%02x:%02x",
name, addr[0] & (0xFF >> mask), addr[1], addr[2],
addr[3], addr[4], addr[5]);
tp->status = HASHETHER_STATUS_RESOLVED_DUMMY;
@ -2109,7 +2109,7 @@ ipxnet_name_lookup(wmem_allocator_t *allocator, const guint addr)
if ( (ipxnet = get_ipxnetbyaddr(addr)) == NULL) {
/* unknown name */
g_snprintf(tp->name, MAXNAMELEN, "%X", addr);
snprintf(tp->name, MAXNAMELEN, "%X", addr);
} else {
(void) g_strlcpy(tp->name, ipxnet->name, MAXNAMELEN);
@ -2132,7 +2132,7 @@ parse_vlan_line(char *line, vlan_t *vlan)
if ((cp = strtok(line, " \t\n")) == NULL)
return -1;
if (sscanf(cp, "%" G_GUINT16_FORMAT, &id) == 1) {
if (sscanf(cp, "%" SCNu16, &id) == 1) {
vlan->id = id;
}
else {
@ -2253,7 +2253,7 @@ vlan_name_lookup(const guint id)
if ( (vlan = get_vlannamebyid(id)) == NULL) {
/* unknown name */
g_snprintf(tp->name, MAXVLANNAMELEN, "<%u>", id);
snprintf(tp->name, MAXVLANNAMELEN, "<%u>", id);
} else {
(void) g_strlcpy(tp->name, vlan->name, MAXVLANNAMELEN);
@ -3278,11 +3278,11 @@ port_with_resolution_to_str_buf(gchar *buf, gulong buf_size, port_type proto, gu
if (!gbl_resolv_flags.transport_name || (proto == PT_NONE)) {
/* No name resolution support, just return port string */
return g_snprintf(buf, buf_size, "%u", port);
return snprintf(buf, buf_size, "%u", port);
}
port_str = serv_name_lookup(proto, port);
ws_assert(port_str);
return g_snprintf(buf, buf_size, "%s (%u)", port_str, port);
return snprintf(buf, buf_size, "%s (%u)", port_str, port);
}
const gchar *

View File

@ -166,7 +166,7 @@ WS_DLL_PUBLIC gchar *port_with_resolution_to_str(wmem_allocator_t *scope,
/*
* port_with_resolution_to_str_buf() prints the "<resolved> (<numerical>)" port
* string to 'buf'. Return value is the same as g_snprintf().
* string to 'buf'. Return value is the same as snprintf().
*/
WS_DLL_PUBLIC int port_with_resolution_to_str_buf(gchar *buf, gulong buf_size,
port_type proto, guint port);

View File

@ -465,7 +465,7 @@ static int ax25_addr_to_str(const address* addr, gchar *buf, int buf_len _U_)
ssid = (addrdata[6] >> 1) & 0x0f;
if (ssid != 0) {
bufp += g_snprintf(bufp,buf_len-(int)(bufp-buf),"-%d",ssid);
bufp += snprintf(bufp,buf_len-(int)(bufp-buf),"-%d",ssid);
} else {
*bufp++ = '\0'; /* NULL terminate */
}

View File

@ -88,7 +88,7 @@ linux_get_memory(gsize *ptotal, gsize *prss)
if (fd < 0) {
char path[64];
g_snprintf(path, sizeof(path), "/proc/%d/statm", getpid());
snprintf(path, sizeof(path), "/proc/%d/statm", getpid());
fd = ws_open(path, O_RDONLY);

View File

@ -91,7 +91,7 @@ color_filters_add_tmp(GSList **cfl)
bg_colors = g_strsplit(prefs.gui_colorized_bg, ",", -1);
for ( i=1 ; i<=10 ; i++ ) {
name = g_strdup_printf("%s%02d",CONVERSATION_COLOR_PREFIX,i);
name = ws_strdup_printf("%s%02d",CONVERSATION_COLOR_PREFIX,i);
/* retrieve background and foreground colors */
cval = strtoul(fg_colors[i-1], NULL, 16);
@ -134,7 +134,7 @@ color_filters_get_tmp(guint8 filt_nr)
if (filt_nr < 1 || filt_nr > 10)
return NULL;
name = g_strdup_printf("%s%02d", CONVERSATION_COLOR_PREFIX, filt_nr);
name = ws_strdup_printf("%s%02d", CONVERSATION_COLOR_PREFIX, filt_nr);
cfl = g_slist_find_custom(color_filter_list, name, color_filters_find_by_name_cb);
colorf = (color_filter_t*)cfl->data;
@ -167,7 +167,7 @@ color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled, gc
if( i!=filt_nr && filter==NULL )
continue;
name = g_strdup_printf("%s%02d",CONVERSATION_COLOR_PREFIX,i);
name = ws_strdup_printf("%s%02d",CONVERSATION_COLOR_PREFIX,i);
cfl = g_slist_find_custom(color_filter_list, name, color_filters_find_by_name_cb);
colorf = (color_filter_t *)cfl->data;
@ -180,7 +180,7 @@ color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled, gc
*/
tmpfilter = ( (filter==NULL) || (i!=filt_nr) ) ? "frame" : filter;
if (!dfilter_compile(tmpfilter, &compiled_filter, &local_err_msg)) {
*err_msg = g_strdup_printf( "Could not compile color filter name: \"%s\" text: \"%s\".\n%s", name, filter, local_err_msg);
*err_msg = ws_strdup_printf( "Could not compile color filter name: \"%s\" text: \"%s\".\n%s", name, filter, local_err_msg);
g_free(local_err_msg);
g_free(name);
return FALSE;
@ -206,7 +206,7 @@ color_filters_tmp_color(guint8 filter_num) {
color_filter_t *colorf = NULL;
GSList *cfl;
name = g_strdup_printf("%s%02d", CONVERSATION_COLOR_PREFIX, filter_num);
name = ws_strdup_printf("%s%02d", CONVERSATION_COLOR_PREFIX, filter_num);
cfl = g_slist_find_custom(color_filter_list, name, color_filters_find_by_name_cb);
if (cfl) {
colorf = (color_filter_t *)cfl->data;
@ -316,7 +316,7 @@ color_filters_get(gchar** err_msg, color_filter_add_cb_func add_cb)
if ((f = ws_fopen(path, "r")) == NULL) {
if (errno != ENOENT) {
/* Error trying to open the file; give up. */
*err_msg = g_strdup_printf("Could not open filter file\n\"%s\": %s.", path,
*err_msg = ws_strdup_printf("Could not open filter file\n\"%s\": %s.", path,
g_strerror(errno));
g_free(path);
return FALSE;
@ -331,7 +331,7 @@ color_filters_get(gchar** err_msg, color_filter_add_cb_func add_cb)
*/
ret = read_filters_file(path, f, &color_filter_list, add_cb);
if (ret != 0) {
*err_msg = g_strdup_printf("Error reading filter file\n\"%s\": %s.",
*err_msg = ws_strdup_printf("Error reading filter file\n\"%s\": %s.",
path, g_strerror(errno));
fclose(f);
g_free(path);
@ -413,7 +413,7 @@ color_filter_compile_cb(gpointer filter_arg, gpointer err)
if (colorf->disabled) return;
if (!dfilter_compile(colorf->filter_text, &colorf->c_colorfilter, &local_err_msg)) {
*err_msg = g_strdup_printf("Could not compile color filter name: \"%s\" text: \"%s\".\n%s",
*err_msg = ws_strdup_printf("Could not compile color filter name: \"%s\" text: \"%s\".\n%s",
colorf->filter_name, colorf->filter_text, local_err_msg);
g_free(local_err_msg);
/* this filter was compilable before, so this should never happen */
@ -435,7 +435,7 @@ color_filter_validate_cb(gpointer filter_arg, gpointer err)
if (colorf->disabled) return;
if (!dfilter_compile(colorf->filter_text, &colorf->c_colorfilter, &local_err_msg)) {
*err_msg = g_strdup_printf("Disabling color filter name: \"%s\" filter: \"%s\".\n%s",
*err_msg = ws_strdup_printf("Disabling color filter name: \"%s\" filter: \"%s\".\n%s",
colorf->filter_name, colorf->filter_text, local_err_msg);
g_free(local_err_msg);
@ -716,7 +716,7 @@ color_filters_read_globals(gpointer user_data, gchar** err_msg, color_filter_add
if ((f = ws_fopen(path, "r")) == NULL) {
if (errno != ENOENT) {
/* Error trying to open the file; give up. */
*err_msg = g_strdup_printf("Could not open global filter file\n\"%s\": %s.", path,
*err_msg = ws_strdup_printf("Could not open global filter file\n\"%s\": %s.", path,
g_strerror(errno));
g_free(path);
return FALSE;
@ -732,7 +732,7 @@ color_filters_read_globals(gpointer user_data, gchar** err_msg, color_filter_add
ret = read_filters_file(path, f, user_data, add_cb);
if (ret != 0) {
*err_msg = g_strdup_printf("Error reading global filter file\n\"%s\": %s.",
*err_msg = ws_strdup_printf("Error reading global filter file\n\"%s\": %s.",
path, g_strerror(errno));
fclose(f);
g_free(path);
@ -752,14 +752,14 @@ color_filters_import(const gchar *path, gpointer user_data, gchar **err_msg, col
int ret;
if ((f = ws_fopen(path, "r")) == NULL) {
*err_msg = g_strdup_printf("Could not open filter file\n%s\nfor reading: %s.",
*err_msg = ws_strdup_printf("Could not open filter file\n%s\nfor reading: %s.",
path, g_strerror(errno));
return FALSE;
}
ret = read_filters_file(path, f, user_data, add_cb);
if (ret != 0) {
*err_msg = g_strdup_printf("Error reading filter file\n\"%s\": %s.",
*err_msg = ws_strdup_printf("Error reading filter file\n\"%s\": %s.",
path, g_strerror(errno));
fclose(f);
return FALSE;
@ -823,7 +823,7 @@ color_filters_write(GSList *cfl, gchar** err_msg)
/* Create the directory that holds personal configuration files,
if necessary. */
if (create_persconffile_dir(&pf_dir_path) == -1) {
*err_msg = g_strdup_printf("Can't create directory\n\"%s\"\nfor color files: %s.",
*err_msg = ws_strdup_printf("Can't create directory\n\"%s\"\nfor color files: %s.",
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
return FALSE;
@ -831,7 +831,7 @@ color_filters_write(GSList *cfl, gchar** err_msg)
path = get_persconffile_path(COLORFILTERS_FILE_NAME, TRUE);
if ((f = ws_fopen(path, "w+")) == NULL) {
*err_msg = g_strdup_printf("Could not open\n%s\nfor writing: %s.",
*err_msg = ws_strdup_printf("Could not open\n%s\nfor writing: %s.",
path, g_strerror(errno));
g_free(path);
return FALSE;
@ -849,7 +849,7 @@ color_filters_export(const gchar *path, GSList *cfl, gboolean only_marked, gchar
FILE *f;
if ((f = ws_fopen(path, "w+")) == NULL) {
*err_msg = g_strdup_printf("Could not open\n%s\nfor writing: %s.",
*err_msg = ws_strdup_printf("Could not open\n%s\nfor writing: %s.",
path, g_strerror(errno));
return FALSE;
}

View File

@ -438,9 +438,9 @@ col_snprint_port(gchar *buf, size_t buf_siz, port_type typ, guint16 val)
if (gbl_resolv_flags.transport_name &&
(str = try_serv_name_lookup(typ, val)) != NULL) {
snprintf(buf, buf_siz, "%s(%"G_GUINT16_FORMAT")", str, val);
snprintf(buf, buf_siz, "%s(%"PRIu16")", str, val);
} else {
snprintf(buf, buf_siz, "%"G_GUINT16_FORMAT, val);
snprintf(buf, buf_siz, "%"PRIu16, val);
}
}

View File

@ -747,21 +747,21 @@ get_custom_field_tooltip (gchar *custom_field, gint occurrence)
header_field_info *hfi = proto_registrar_get_byname(custom_field);
if (hfi == NULL) {
/* Not a valid field */
return g_strdup_printf("Unknown Field: %s", custom_field);
return ws_strdup_printf("Unknown Field: %s", custom_field);
}
if (hfi->parent == -1) {
/* Protocol */
return g_strdup_printf("%s (%s)", hfi->name, hfi->abbrev);
return ws_strdup_printf("%s (%s)", hfi->name, hfi->abbrev);
}
if (occurrence == 0) {
/* All occurrences */
return g_strdup_printf("%s\n%s (%s)", proto_get_protocol_name(hfi->parent), hfi->name, hfi->abbrev);
return ws_strdup_printf("%s\n%s (%s)", proto_get_protocol_name(hfi->parent), hfi->name, hfi->abbrev);
}
/* One given occurrence */
return g_strdup_printf("%s\n%s (%s#%d)", proto_get_protocol_name(hfi->parent), hfi->name, hfi->abbrev, occurrence);
return ws_strdup_printf("%s\n%s (%s#%d)", proto_get_protocol_name(hfi->parent), hfi->name, hfi->abbrev, occurrence);
}
gchar *

View File

@ -162,7 +162,7 @@ set_host_gui_data(const void *key _U_, void *value, void *userdata)
ui_info.group = REGISTER_STAT_GROUP_ENDPOINT_LIST;
ui_info.title = NULL; /* construct this from the protocol info? */
ui_info.cli_string = g_strdup_printf("%s,%s", HOSTLIST_TAP_PREFIX, proto_get_protocol_filter_name(table->proto_id));
ui_info.cli_string = ws_strdup_printf("%s,%s", HOSTLIST_TAP_PREFIX, proto_get_protocol_filter_name(table->proto_id));
ui_info.tap_init_cb = dissector_hostlist_init;
ui_info.nparams = 0;
ui_info.params = NULL;
@ -359,7 +359,7 @@ ct_port_to_str(endpoint_type etype, guint32 port)
case ENDPOINT_UDP:
case ENDPOINT_SCTP:
case ENDPOINT_NCP:
return g_strdup_printf("%d", port);
return ws_strdup_printf("%d", port);
default:
break;
}
@ -545,7 +545,7 @@ char *get_hostlist_filter(hostlist_talker_t *host)
src_addr = new_addr;
}
str = g_strdup_printf("%s==%s%s%s%s%s",
str = ws_strdup_printf("%s==%s%s%s%s%s",
hostlist_get_filter_name(host, CONV_FT_ANY_ADDRESS),
src_addr,
sport?" && ":"",

View File

@ -46,7 +46,7 @@ void register_decode_as(decode_as_t* reg)
static void next_proto_prompt(packet_info *pinfo _U_, gchar *result)
{
g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Next level protocol as");
snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Next level protocol as");
}
static gpointer next_proto_value(packet_info *pinfo _U_)
@ -340,7 +340,7 @@ decode_as_write_entry (const gchar *table_name, ftenum_t selector_type,
* but pre-1.10 releases are at end-of-life and won't
* be fixed.
*/
decode_as_row = g_strdup_printf(
decode_as_row = ws_strdup_printf(
DECODE_AS_ENTRY ": %s,%u,%s,%s\n",
table_name, GPOINTER_TO_UINT(key), initial_proto_name,
current_proto_name);
@ -351,7 +351,7 @@ decode_as_write_entry (const gchar *table_name, ftenum_t selector_type,
* FT_NONE dissector table uses a single uint value for
* a placeholder
*/
decode_as_row = g_strdup_printf(
decode_as_row = ws_strdup_printf(
DECODE_AS_ENTRY ": %s,0,%s,%s\n",
table_name, initial_proto_name,
current_proto_name);
@ -362,7 +362,7 @@ decode_as_write_entry (const gchar *table_name, ftenum_t selector_type,
case FT_UINT_STRING:
case FT_STRINGZPAD:
case FT_STRINGZTRUNC:
decode_as_row = g_strdup_printf(
decode_as_row = ws_strdup_printf(
DECODE_AS_ENTRY ": %s,%s,%s,%s\n",
table_name, (gchar *)key, initial_proto_name,
current_proto_name);
@ -398,7 +398,7 @@ save_decode_as_entries(gchar** err)
GList *decode_as_rows_list = NULL;
if (create_persconffile_dir(&pf_dir_path) == -1) {
*err = g_strdup_printf("Can't create directory\n\"%s\"\nfor recent file: %s.",
*err = ws_strdup_printf("Can't create directory\n\"%s\"\nfor recent file: %s.",
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
return -1;
@ -406,7 +406,7 @@ save_decode_as_entries(gchar** err)
daf_path = get_persconffile_path(DECODE_AS_ENTRIES_FILE_NAME, TRUE);
if ((da_file = ws_fopen(daf_path, "w")) == NULL) {
*err = g_strdup_printf("Can't open decode_as_entries file\n\"%s\": %s.",
*err = ws_strdup_printf("Can't open decode_as_entries file\n\"%s\": %s.",
daf_path, g_strerror(errno));
g_free(daf_path);
return -1;

View File

@ -107,12 +107,12 @@ static gchar* dfilter_macro_resolve(gchar* name, gchar** args, gchar** error) {
return wmem_strdup(NULL, e->repr);
} else {
if (error != NULL)
*error = g_strdup_printf("macro '%s' is unusable", name);
*error = ws_strdup_printf("macro '%s' is unusable", name);
return NULL;
}
} else {
if (error != NULL)
*error = g_strdup_printf("macro '%s' does not exist", name);
*error = ws_strdup_printf("macro '%s' does not exist", name);
return NULL;
}
}
@ -125,7 +125,7 @@ static gchar* dfilter_macro_resolve(gchar* name, gchar** args, gchar** error) {
if (argc != m->argc) {
if (error != NULL) {
*error = g_strdup_printf("wrong number of arguments for macro '%s', expecting %d instead of %d",
*error = ws_strdup_printf("wrong number of arguments for macro '%s', expecting %d instead of %d",
name, m->argc, argc);
}
return NULL;
@ -538,7 +538,7 @@ static gboolean macro_name_chk(void *mp, const char *in_name, guint name_len,
/* This a string field which is always NUL-terminated,
* so no need to check name_len. */
if (!g_strcmp0(in_name, macros[i].name)) {
*error = g_strdup_printf("macro '%s' already exists",
*error = ws_strdup_printf("macro '%s' already exists",
in_name);
return FALSE;
}

View File

@ -53,7 +53,7 @@ dfilter_vfail(dfwork_t *dfw, const char *format, va_list args)
if (dfw->error_message != NULL)
return;
dfw->error_message = g_strdup_vprintf(format, args);
dfw->error_message = ws_strdup_vprintf(format, args);
}
void
@ -357,7 +357,7 @@ dfilter_compile_real(const gchar *text, dfilter_t **dfp,
ws_noisy("Expanded text: %s", expanded_text);
if (df_lex_init(&scanner) != 0) {
dfw->error_message = g_strdup_printf("Can't initialize scanner: %s", g_strerror(errno));
dfw->error_message = ws_strdup_printf("Can't initialize scanner: %s", g_strerror(errno));
goto FAILURE;
}

View File

@ -15,7 +15,7 @@
#include <errno.h>
#include <stdlib.h>
#include <wsutil/ws_assert.h>
/* drange_node constructor */
drange_node*
@ -40,11 +40,11 @@ drange_str_to_gint32(const char *s, gint32 *pint, char **endptr, char **err_ptr)
integer = strtol(s, endptr, 0);
if (errno == EINVAL || *endptr == s) {
/* This isn't a valid number. */
*err_ptr = g_strdup_printf("\"%s\" is not a valid number.", s);
*err_ptr = ws_strdup_printf("\"%s\" is not a valid number.", s);
return FALSE;
}
if (errno == ERANGE || integer > G_MAXINT32 || integer < G_MININT32) {
*err_ptr = g_strdup_printf("\"%s\" causes an integer overflow.", s);
*err_ptr = ws_strdup_printf("\"%s\" causes an integer overflow.", s);
return FALSE;
}
*pint = (gint32)integer;
@ -116,7 +116,7 @@ drange_node_from_str(const char *range_str, char **err_ptr)
str++;
if (!ok || *str != '\0') {
*err_ptr = g_strdup_printf("\"%s\" is not a valid range.", range_str);
*err_ptr = ws_strdup_printf("\"%s\" is not a valid range.", range_str);
return NULL;
}
@ -125,7 +125,7 @@ drange_node_from_str(const char *range_str, char **err_ptr)
switch (end) {
case DRANGE_NODE_END_T_LENGTH:
if (upper <= 0) {
*err_ptr = g_strdup_printf("Range %s isn't valid "
*err_ptr = ws_strdup_printf("Range %s isn't valid "
"because length %d isn't positive",
range_str, upper);
drange_node_free(dn);
@ -135,14 +135,14 @@ drange_node_from_str(const char *range_str, char **err_ptr)
break;
case DRANGE_NODE_END_T_OFFSET:
if ((lower < 0 && upper > 0) || (lower > 0 && upper < 0)) {
*err_ptr = g_strdup_printf("Range %s isn't valid "
*err_ptr = ws_strdup_printf("Range %s isn't valid "
"because %d and %d have different signs",
range_str, lower, upper);
drange_node_free(dn);
return NULL;
}
if (upper <= lower) {
*err_ptr = g_strdup_printf("Range %s isn't valid "
*err_ptr = ws_strdup_printf("Range %s isn't valid "
"because %d is greater or equal than %d",
range_str, lower, upper);
drange_node_free(dn);

View File

@ -13,9 +13,7 @@
#ifndef __DRANGE_H__
#define __DRANGE_H__
#include <glib.h>
#include "ws_symbol_export.h"
#include "ws_attributes.h"
#include <wireshark.h>
/* Please don't directly manipulate these structs. Please use
* the methods provided. If you REALLY can't do what you need to

View File

@ -46,7 +46,7 @@ sttype_fvalue_tostr(const void *data, gboolean pretty)
if (pretty)
repr = g_strdup(s);
else
repr = g_strdup_printf("%s[%s]", fvalue_type_name(fvalue), s);
repr = ws_strdup_printf("%s[%s]", fvalue_type_name(fvalue), s);
g_free(s);
return repr;
}
@ -89,9 +89,9 @@ charconst_tostr(const void *data, gboolean pretty _U_)
}
if (g_ascii_isprint(num))
return g_strdup_printf("'%c'", (int)num);
return ws_strdup_printf("'%c'", (int)num);
out:
return g_strdup_printf("'\\x%02lx'", num);
return ws_strdup_printf("'\\x%02lx'", num);
}
void

View File

@ -81,7 +81,7 @@ range_tostr(const void *data, gboolean pretty)
char *repr, *drange_str;
drange_str = drange_tostr(range->drange);
repr = g_strdup_printf("%s[%s]",
repr = ws_strdup_printf("%s[%s]",
stnode_tostr(range->entity, pretty),
drange_str);
g_free(drange_str);

View File

@ -284,7 +284,7 @@ _node_tostr(stnode_t *node, gboolean pretty)
repr = s;
}
else {
repr = g_strdup_printf("%s<%s>", stnode_type_name(node), s);
repr = ws_strdup_printf("%s<%s>", stnode_type_name(node), s);
g_free(s);
}
@ -304,7 +304,7 @@ stnode_tostr(stnode_t *node, gboolean pretty)
return node->repr_token;
}
node->repr_display = g_strdup_printf("\"%s\"", node->repr_token);
node->repr_display = ws_strdup_printf("\"%s\"", node->repr_token);
return node->repr_display;
}

View File

@ -726,7 +726,7 @@ ddict_open(const char* system_directory, const char* filename)
FILE* fh;
char* fname;
if (system_directory) {
fname = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
fname = ws_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
system_directory,filename);
} else {
fname = g_strdup(filename);

View File

@ -181,7 +181,7 @@ save_protos_list(char **pref_path_return, int *errno_return, const char* filenam
/* Write to "XXX.new", and rename if that succeeds.
That means we don't trash the file if we fail to write it out
completely. */
ff_path_new = g_strdup_printf("%s.new", ff_path);
ff_path_new = ws_strdup_printf("%s.new", ff_path);
if ((ff = ws_fopen(ff_path_new, "w")) == NULL) {
*pref_path_return = ff_path;
@ -809,7 +809,7 @@ save_disabled_heur_dissector_list(char **pref_path_return, int *errno_return)
/* Write to "XXX.new", and rename if that succeeds.
That means we don't trash the file if we fail to write it out
completely. */
ff_path_new = g_strdup_printf("%s.new", ff_path);
ff_path_new = ws_strdup_printf("%s.new", ff_path);
if ((ff = ws_fopen(ff_path_new, "w")) == NULL) {
*pref_path_return = ff_path;

View File

@ -196,7 +196,7 @@ newline \n
<OUTSIDE>{entity_start} { BEGIN IN_ENTITY; }
<IN_ENTITY>{name} { yyextra->entity_name = g_strdup_printf("%%%s;",yytext); BEGIN NAMED_ENTITY; }
<IN_ENTITY>{name} { yyextra->entity_name = ws_strdup_printf("%%%s;",yytext); BEGIN NAMED_ENTITY; }
<NAMED_ENTITY>{quote} { yyextra->current = g_string_new(dtd_location(yyextra)); BEGIN IN_QUOTE; }
<IN_QUOTE>{quote} { g_hash_table_insert(yyextra->entities,yyextra->entity_name,yyextra->current); BEGIN ENTITY_DONE; }
<IN_QUOTE>{percent} |
@ -238,7 +238,7 @@ const gchar* dtd_location(Dtd_PreParse_scanner_state_t* state) {
if (!state) return NULL;
loc = g_strdup_printf("<? wireshark:location %s:%u ?>", state->filename, state->linenum);
loc = ws_strdup_printf("<? wireshark:location %s:%u ?>", state->filename, state->linenum);
return loc;
}
@ -250,7 +250,7 @@ static gboolean free_gstring_hash_items(gpointer k,gpointer v,gpointer p _U_) {
}
extern GString* dtd_preparse(const gchar* dname,const gchar* fname, GString* err) {
gchar* fullname = g_strdup_printf("%s%c%s",dname,G_DIR_SEPARATOR,fname);
gchar* fullname = ws_strdup_printf("%s%c%s",dname,G_DIR_SEPARATOR,fname);
FILE *in;
yyscan_t scanner;
Dtd_PreParse_scanner_state_t state;

View File

@ -18,7 +18,7 @@
/*
* Modified to support throwing an exception with a null message pointer,
* and to have the message not be const (as we generate messages with
* "g_strdup_sprintf()", which means they need to be freed; using
* "ws_strdup_printf()", which means they need to be freed; using
* a null message means that we don't have to use a special string
* for exceptions with no message, and don't have to worry about
* not freeing that).
@ -303,7 +303,7 @@ WS_NORETURN void except_throwd(long group, long code, const char *msg, void *dat
}
/*
* XXX - should we use g_strdup_sprintf() here, so we're not limited by
* XXX - should we use ws_strdup_printf() here, so we're not limited by
* XCEPT_BUFFER_SIZE? We could then just use this to generate formatted
* messages.
*/
@ -312,7 +312,7 @@ WS_NORETURN void except_vthrowf(long group, long code, const char *fmt,
{
char *buf = (char *)except_alloc(XCEPT_BUFFER_SIZE);
g_vsnprintf(buf, XCEPT_BUFFER_SIZE, fmt, vl);
vsnprintf(buf, XCEPT_BUFFER_SIZE, fmt, vl);
except_throwd(group, code, buf, buf);
}

View File

@ -21,7 +21,7 @@
* Portable Exception Handling for ANSI C.<BR>
* Modified to support throwing an exception with a null message pointer,
* and to have the message not be const (as we generate messages with
* "g_strdup_sprintf()", which means they need to be freed; using
* "ws_strdup_printf()", which means they need to be freed; using
* a null message means that we don't have to use a special string
* for exceptions with no message, and don't have to worry about
* not freeing that).

View File

@ -123,7 +123,7 @@ static gboolean uat_expert_update_cb(void *r, char **err)
expert_level_entry_t *rec = (expert_level_entry_t *)r;
if (expert_registrar_get_byname(rec->field) == NULL) {
*err = g_strdup_printf("Expert Info field doesn't exist");
*err = ws_strdup_printf("Expert Info field doesn't exist");
return FALSE;
}
return TRUE;

View File

@ -189,7 +189,7 @@ byte_array_from_unparsed(const char *s, gchar **err_msg)
if (!res) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid byte string.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid byte string.", s);
g_byte_array_free(bytes, TRUE);
return NULL;
}
@ -219,7 +219,7 @@ byte_array_from_charconst(unsigned long num, gchar **err_msg)
{
if (num > UINT8_MAX) {
if (err_msg) {
*err_msg = g_strdup_printf("%lu is too large for a byte value", num);
*err_msg = ws_strdup_printf("%lu is too large for a byte value", num);
}
return NULL;
}
@ -258,14 +258,14 @@ ax25_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value, gc
if (bytes_from_unparsed(fv, s, TRUE, NULL)) {
if (fv->value.bytes->len > FT_AX25_ADDR_LEN) {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("\"%s\" contains too many bytes to be a valid AX.25 address.",
*err_msg = ws_strdup_printf("\"%s\" contains too many bytes to be a valid AX.25 address.",
s);
}
return FALSE;
}
else if (fv->value.bytes->len < FT_AX25_ADDR_LEN && !allow_partial_value) {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("\"%s\" contains too few bytes to be a valid AX.25 address.",
*err_msg = ws_strdup_printf("\"%s\" contains too few bytes to be a valid AX.25 address.",
s);
}
return FALSE;
@ -306,7 +306,7 @@ ax25_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value, gc
* http://www.itu.int/ITU-R/terrestrial/docs/fixedmobile/fxm-art19-sec3.pdf
*/
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid AX.25 address.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid AX.25 address.", s);
return FALSE;
}
@ -321,14 +321,14 @@ vines_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value, g
if (bytes_from_unparsed(fv, s, TRUE, NULL)) {
if (fv->value.bytes->len > FT_VINES_ADDR_LEN) {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("\"%s\" contains too many bytes to be a valid Vines address.",
*err_msg = ws_strdup_printf("\"%s\" contains too many bytes to be a valid Vines address.",
s);
}
return FALSE;
}
else if (fv->value.bytes->len < FT_VINES_ADDR_LEN && !allow_partial_value) {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("\"%s\" contains too few bytes to be a valid Vines address.",
*err_msg = ws_strdup_printf("\"%s\" contains too few bytes to be a valid Vines address.",
s);
}
return FALSE;
@ -340,7 +340,7 @@ vines_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value, g
/* XXX - need better validation of Vines address */
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid Vines address.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid Vines address.", s);
return FALSE;
}
@ -355,14 +355,14 @@ ether_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value, g
if (bytes_from_unparsed(fv, s, TRUE, NULL)) {
if (fv->value.bytes->len > FT_ETHER_LEN) {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("\"%s\" contains too many bytes to be a valid Ethernet address.",
*err_msg = ws_strdup_printf("\"%s\" contains too many bytes to be a valid Ethernet address.",
s);
}
return FALSE;
}
else if (fv->value.bytes->len < FT_ETHER_LEN && !allow_partial_value) {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("\"%s\" contains too few bytes to be a valid Ethernet address.",
*err_msg = ws_strdup_printf("\"%s\" contains too few bytes to be a valid Ethernet address.",
s);
}
return FALSE;
@ -374,7 +374,7 @@ ether_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value, g
/* XXX - Try resolving as an Ethernet host name and parse that? */
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid Ethernet address.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid Ethernet address.", s);
return FALSE;
}
@ -401,7 +401,7 @@ oid_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_,
res = oid_str_to_bytes(s, bytes);
if (!res) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid OBJECT IDENTIFIER.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid OBJECT IDENTIFIER.", s);
g_byte_array_free(bytes, TRUE);
return FALSE;
}
@ -423,7 +423,7 @@ rel_oid_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value
res = rel_oid_str_to_bytes(s, bytes, FALSE);
if (!res) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid RELATIVE-OID.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid RELATIVE-OID.", s);
g_byte_array_free(bytes, TRUE);
return FALSE;
}
@ -446,7 +446,7 @@ system_id_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_valu
if (bytes_from_unparsed(fv, s, TRUE, NULL)) {
if (fv->value.bytes->len > MAX_SYSTEMID_LEN) {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("\"%s\" contains too many bytes to be a valid OSI System-ID.",
*err_msg = ws_strdup_printf("\"%s\" contains too many bytes to be a valid OSI System-ID.",
s);
}
return FALSE;
@ -458,7 +458,7 @@ system_id_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_valu
/* XXX - need better validation of OSI System-ID address */
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid OSI System-ID.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid OSI System-ID.", s);
return FALSE;
}
@ -473,7 +473,7 @@ fcwwn_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U
if (bytes_from_unparsed(fv, s, TRUE, NULL)) {
if (fv->value.bytes->len > FT_FCWWN_LEN) {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("\"%s\" contains too many bytes to be a valid FCWWN.",
*err_msg = ws_strdup_printf("\"%s\" contains too many bytes to be a valid FCWWN.",
s);
}
return FALSE;
@ -485,7 +485,7 @@ fcwwn_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U
/* XXX - need better validation of FCWWN address */
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid FCWWN.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid FCWWN.", s);
return FALSE;
}

View File

@ -44,21 +44,21 @@ val_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_,
if (endptr == s || *endptr != '\0') {
/* This isn't a valid number. */
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid number.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid number.", s);
return FALSE;
}
if (errno == ERANGE) {
if (fv->value.floating == 0) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" causes floating-point underflow.", s);
*err_msg = ws_strdup_printf("\"%s\" causes floating-point underflow.", s);
}
else if (fv->value.floating == HUGE_VAL) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" causes floating-point overflow.", s);
*err_msg = ws_strdup_printf("\"%s\" causes floating-point overflow.", s);
}
else {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid floating-point number.",
*err_msg = ws_strdup_printf("\"%s\" is not a valid floating-point number.",
s);
}
return FALSE;

View File

@ -73,7 +73,7 @@ guid_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_
if (!get_guid(s, &guid)) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid GUID.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid GUID.", s);
return FALSE;
}

View File

@ -64,7 +64,7 @@ uint_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_
* "converted in the obvious manner" by strtoul().
*/
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" too small for this field, minimum 0.", s);
*err_msg = ws_strdup_printf("\"%s\" too small for this field, minimum 0.", s);
return FALSE;
}
@ -74,13 +74,13 @@ uint_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_
if (errno == EINVAL || endptr == s || *endptr != '\0') {
/* This isn't a valid number. */
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid number.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid number.", s);
return FALSE;
}
if (errno == ERANGE) {
if (err_msg != NULL) {
if (value == ULONG_MAX) {
*err_msg = g_strdup_printf("\"%s\" causes an integer overflow.",
*err_msg = ws_strdup_printf("\"%s\" causes an integer overflow.",
s);
}
else {
@ -88,7 +88,7 @@ uint_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_
* XXX - can "strtoul()" set errno to
* ERANGE without returning ULONG_MAX?
*/
*err_msg = g_strdup_printf("\"%s\" is not an integer.", s);
*err_msg = ws_strdup_printf("\"%s\" is not an integer.", s);
}
}
return FALSE;
@ -96,7 +96,7 @@ uint_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_
if (value > max) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" too big for this field, maximum %u.", s, max);
*err_msg = ws_strdup_printf("\"%s\" too big for this field, maximum %u.", s, max);
return FALSE;
}
@ -152,7 +152,7 @@ sint_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_
* strtol().
*/
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" causes an integer overflow.", s);
*err_msg = ws_strdup_printf("\"%s\" causes an integer overflow.", s);
return FALSE;
}
@ -162,23 +162,23 @@ sint_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_
if (errno == EINVAL || endptr == s || *endptr != '\0') {
/* This isn't a valid number. */
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid number.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid number.", s);
return FALSE;
}
if (errno == ERANGE) {
if (err_msg != NULL) {
if (value == LONG_MAX) {
*err_msg = g_strdup_printf("\"%s\" causes an integer overflow.", s);
*err_msg = ws_strdup_printf("\"%s\" causes an integer overflow.", s);
}
else if (value == LONG_MIN) {
*err_msg = g_strdup_printf("\"%s\" causes an integer underflow.", s);
*err_msg = ws_strdup_printf("\"%s\" causes an integer underflow.", s);
}
else {
/*
* XXX - can "strtol()" set errno to
* ERANGE without returning ULONG_MAX?
*/
*err_msg = g_strdup_printf("\"%s\" is not an integer.", s);
*err_msg = ws_strdup_printf("\"%s\" is not an integer.", s);
}
}
return FALSE;
@ -186,12 +186,12 @@ sint_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_
if (value > max) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" too big for this field, maximum %d.",
*err_msg = ws_strdup_printf("\"%s\" too big for this field, maximum %d.",
s, max);
return FALSE;
} else if (value < min) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" too small for this field, minimum %d.",
*err_msg = ws_strdup_printf("\"%s\" too small for this field, minimum %d.",
s, min);
return FALSE;
}
@ -378,7 +378,7 @@ ipxnet_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _
/* XXX - Try resolving as an IPX host name and parse that? */
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid IPX network address.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid IPX network address.", s);
return FALSE;
}
@ -469,7 +469,7 @@ _uint64_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value
* "converted in the obvious manner" by g_ascii_strtoull().
*/
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" causes an integer underflow.", s);
*err_msg = ws_strdup_printf("\"%s\" causes an integer underflow.", s);
return FALSE;
}
@ -479,20 +479,20 @@ _uint64_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value
if (errno == EINVAL || endptr == s || *endptr != '\0') {
/* This isn't a valid number. */
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid number.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid number.", s);
return FALSE;
}
if (errno == ERANGE) {
if (err_msg != NULL) {
if (value == G_MAXUINT64) {
*err_msg = g_strdup_printf("\"%s\" causes an integer overflow.", s);
*err_msg = ws_strdup_printf("\"%s\" causes an integer overflow.", s);
}
else {
/*
* XXX - can "strtoul()" set errno to
* ERANGE without returning ULONG_MAX?
*/
*err_msg = g_strdup_printf("\"%s\" is not an integer.", s);
*err_msg = ws_strdup_printf("\"%s\" is not an integer.", s);
}
}
return FALSE;
@ -500,7 +500,7 @@ _uint64_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value
if (value > max) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" too big for this field, maximum %" G_GINT64_MODIFIER "u.", s, max);
*err_msg = ws_strdup_printf("\"%s\" too big for this field, maximum %" PRIu64".", s, max);
return FALSE;
}
@ -552,7 +552,7 @@ _sint64_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value
* "converted in the obvious manner" by g_ascii_strtoll().
*/
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" causes an integer overflow.", s);
*err_msg = ws_strdup_printf("\"%s\" causes an integer overflow.", s);
return FALSE;
}
@ -562,23 +562,23 @@ _sint64_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value
if (errno == EINVAL || endptr == s || *endptr != '\0') {
/* This isn't a valid number. */
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid number.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid number.", s);
return FALSE;
}
if (errno == ERANGE) {
if (err_msg != NULL) {
if (value == G_MAXINT64) {
*err_msg = g_strdup_printf("\"%s\" causes an integer overflow.", s);
*err_msg = ws_strdup_printf("\"%s\" causes an integer overflow.", s);
}
else if (value == G_MININT64) {
*err_msg = g_strdup_printf("\"%s\" causes an integer underflow.", s);
*err_msg = ws_strdup_printf("\"%s\" causes an integer underflow.", s);
}
else {
/*
* XXX - can "strtol()" set errno to
* ERANGE without returning LONG_MAX?
*/
*err_msg = g_strdup_printf("\"%s\" is not an integer.", s);
*err_msg = ws_strdup_printf("\"%s\" is not an integer.", s);
}
}
return FALSE;
@ -586,11 +586,11 @@ _sint64_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value
if (value > max) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" too big for this field, maximum %" G_GINT64_MODIFIER "u.", s, max);
*err_msg = ws_strdup_printf("\"%s\" too big for this field, maximum %" PRIu64".", s, max);
return FALSE;
} else if (value < min) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" too small for this field, maximum %" G_GINT64_MODIFIER "u.", s, max);
*err_msg = ws_strdup_printf("\"%s\" too small for this field, maximum %" PRIu64 ".", s, max);
return FALSE;
}
@ -738,7 +738,7 @@ eui64_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U
res = hex_str_to_bytes(s, bytes, TRUE);
if (!res || bytes->len != 8) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid EUI-64 address.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid EUI-64 address.", s);
g_byte_array_free(bytes, TRUE);
return FALSE;
}

View File

@ -53,7 +53,7 @@ val_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_,
if (!get_host_ipaddr(addr_str, &addr)) {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("\"%s\" is not a valid hostname or IPv4 address.",
*err_msg = ws_strdup_printf("\"%s\" is not a valid hostname or IPv4 address.",
addr_str);
}
if (addr_str_to_free)
@ -80,7 +80,7 @@ val_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_,
if (nmask_bits > 32) {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("Netmask bits in a CIDR IPv4 address should be <= 32, not %u",
*err_msg = ws_strdup_printf("Netmask bits in a CIDR IPv4 address should be <= 32, not %u",
nmask_bits);
}
return FALSE;

View File

@ -44,7 +44,7 @@ ipv6_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_
if (!get_host_ipaddr6(addr_str, &(fv->value.ipv6.addr))) {
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid hostname or IPv6 address.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid hostname or IPv6 address.", s);
if (addr_str_to_free)
wmem_free(NULL, addr_str_to_free);
return FALSE;
@ -65,7 +65,7 @@ ipv6_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_
if (nmask_bits > 128) {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("Prefix in a IPv6 address should be <= 128, not %u",
*err_msg = ws_strdup_printf("Prefix in a IPv6 address should be <= 128, not %u",
nmask_bits);
}
return FALSE;

View File

@ -90,7 +90,7 @@ val_from_charconst(fvalue_t *fv, unsigned long num, gchar **err_msg)
if (num > UINT8_MAX) {
if (err_msg) {
*err_msg = g_strdup_printf("%lu is too large for a byte value", num);
*err_msg = ws_strdup_printf("%lu is too large for a byte value", num);
}
return FALSE;
}

View File

@ -161,7 +161,7 @@ relative_val_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_v
fail:
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid time.", s);
*err_msg = ws_strdup_printf("\"%s\" is not a valid time.", s);
return FALSE;
}
@ -259,7 +259,7 @@ absolute_val_from_string(fvalue_t *fv, const char *s, gchar **err_msg)
fail:
if (err_msg != NULL)
*err_msg = g_strdup_printf("\"%s\" is not a valid absolute time. Example: \"Nov 12, 1999 08:55:44.123\" or \"2011-07-04 12:34:56\"",
*err_msg = ws_strdup_printf("\"%s\" is not a valid absolute time. Example: \"Nov 12, 1999 08:55:44.123\" or \"2011-07-04 12:34:56\"",
s);
return FALSE;
}

View File

@ -279,7 +279,7 @@ fvalue_from_unparsed(ftenum_t ftype, const char *s, gboolean allow_partial_value
}
else {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("\"%s\" cannot be converted to %s.",
*err_msg = ws_strdup_printf("\"%s\" cannot be converted to %s.",
s, ftype_pretty_name(ftype));
}
}
@ -303,7 +303,7 @@ fvalue_from_string(ftenum_t ftype, const char *s, gchar **err_msg)
}
else {
if (err_msg != NULL) {
*err_msg = g_strdup_printf("\"%s\" cannot be converted to %s.",
*err_msg = ws_strdup_printf("\"%s\" cannot be converted to %s.",
s, ftype_pretty_name(ftype));
}
}
@ -328,11 +328,11 @@ fvalue_from_charconst(ftenum_t ftype, unsigned long num, gchar **err_msg)
else {
if (err_msg != NULL) {
if (num <= 0x7f && g_ascii_isprint(num)) {
*err_msg = g_strdup_printf("Character constant '%c' (0x%lx) cannot be converted to %s.",
*err_msg = ws_strdup_printf("Character constant '%c' (0x%lx) cannot be converted to %s.",
(int)num, num, ftype_pretty_name(ftype));
}
else {
*err_msg = g_strdup_printf("Character constant 0x%lx cannot be converted to %s.",
*err_msg = ws_strdup_printf("Character constant 0x%lx cannot be converted to %s.",
num, ftype_pretty_name(ftype));
}
}

View File

@ -54,7 +54,7 @@ ResolveWin32UUID(e_guid_t if_id, char *uuid_name, int uuid_name_max_len)
if_id.data4[6], if_id.data4[7]);
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg_uuid_str, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
if (RegQueryValueEx(hKey, NULL, NULL, NULL, (LPBYTE)reg_uuid_name, &uuid_max_size) == ERROR_SUCCESS && uuid_max_size <= MAX_PATH) {
g_snprintf(uuid_name, uuid_name_max_len, "%s", utf_16to8(reg_uuid_name));
snprintf(uuid_name, uuid_name_max_len, "%s", utf_16to8(reg_uuid_name));
RegCloseKey(hKey);
wmem_free(NULL, reg_uuid_name);
wmem_free(NULL, reg_uuid_str);

View File

@ -103,7 +103,7 @@ static gboolean resolve_synchronously = FALSE;
#if 0
#define MMDB_DEBUG(...) { \
char *MMDB_DEBUG_MSG = g_strdup_printf(__VA_ARGS__); \
char *MMDB_DEBUG_MSG = ws_strdup_printf(__VA_ARGS__); \
ws_warning("mmdb: %s:%d %s", G_STRFUNC, __LINE__, MMDB_DEBUG_MSG); \
g_free(MMDB_DEBUG_MSG); \
}
@ -461,7 +461,7 @@ static void mmdb_resolve_start(void) {
}
GPtrArray *args = g_ptr_array_new();
char *mmdbresolve = g_strdup_printf("%s%c%s", get_progfile_dir(), G_DIR_SEPARATOR, "mmdbresolve");
char *mmdbresolve = ws_strdup_printf("%s%c%s", get_progfile_dir(), G_DIR_SEPARATOR, "mmdbresolve");
g_ptr_array_add(args, mmdbresolve);
for (guint i = 0; i < mmdb_file_arr->len; i++) {
g_ptr_array_add(args, g_strdup("-f"));
@ -502,7 +502,7 @@ maxmind_db_scan_dir(const char *dirname) {
while ((file = ws_dir_read_name(dir)) != NULL) {
const char *name = ws_dir_get_name(file);
if (g_str_has_suffix(file, ".mmdb")) {
char *datname = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", dirname, name);
char *datname = ws_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", dirname, name);
FILE *mmdb_f = ws_fopen(datname, "r");
if (mmdb_f) {
g_ptr_array_add(mmdb_file_arr, datname);
@ -688,7 +688,7 @@ maxmind_db_lookup_ipv4(const ws_in4_addr *addr) {
char addr_str[WS_INET_ADDRSTRLEN];
ws_inet_ntop4(addr, addr_str, WS_INET_ADDRSTRLEN);
MMDB_DEBUG("looking up %s", addr_str);
g_async_queue_push(mmdbr_request_q, g_strdup_printf("%s\n", addr_str));
g_async_queue_push(mmdbr_request_q, ws_strdup_printf("%s\n", addr_str));
if (resolve_synchronously) {
maxmind_db_await_response();
result = (mmdb_lookup_t *) wmem_map_lookup(mmdb_ipv4_map, GUINT_TO_POINTER(*addr));
@ -711,7 +711,7 @@ maxmind_db_lookup_ipv6(const ws_in6_addr *addr) {
char addr_str[WS_INET6_ADDRSTRLEN];
ws_inet_ntop6(addr, addr_str, WS_INET6_ADDRSTRLEN);
MMDB_DEBUG("looking up %s", addr_str);
g_async_queue_push(mmdbr_request_q, g_strdup_printf("%s\n", addr_str));
g_async_queue_push(mmdbr_request_q, ws_strdup_printf("%s\n", addr_str));
if (resolve_synchronously) {
maxmind_db_await_response();
result = (mmdb_lookup_t *) wmem_map_lookup(mmdb_ipv6_map, addr->bytes);

View File

@ -59,10 +59,10 @@ print_nsap_net_buf( const guint8 *ad, int length, gchar *buf, int buf_len)
cur += strlen( cur );
print_system_id_buf( ad + RFC1237_FULLAREA_LEN, RFC1237_SYSTEMID_LEN, cur, (int) (buf_len-(cur-buf)));
cur += strlen( cur );
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "[%02x]",
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "[%02x]",
ad[ RFC1237_FULLAREA_LEN + RFC1237_SYSTEMID_LEN ] );
if ( length == RFC1237_NSAP_LEN + 1 ) {
g_snprintf(cur, (int) (buf_len-(cur-buf)), "-%02x", ad[ length -1 ] );
snprintf(cur, (int) (buf_len-(cur-buf)), "-%02x", ad[ length -1 ] );
}
}
else { /* probably format as standard */
@ -102,31 +102,31 @@ print_system_id_buf( const guint8 *ad, int length, gchar *buf, int buf_len)
if ( ( 6 == length ) || /* System-ID */
( 7 == length ) || /* LAN-ID */
( 8 == length )) { /* LSP-ID */
cur += g_snprintf(cur, buf_len, "%02x%02x.%02x%02x.%02x%02x", ad[0], ad[1],
cur += snprintf(cur, buf_len, "%02x%02x.%02x%02x.%02x%02x", ad[0], ad[1],
ad[2], ad[3], ad[4], ad[5] );
if ( ( 7 == length ) ||
( 8 == length )) {
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), ".%02x", ad[6] );
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), ".%02x", ad[6] );
}
if ( 8 == length ) {
g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "-%02x", ad[7] );
snprintf(cur, (gulong) (buf_len-(cur-buf)), "-%02x", ad[7] );
}
}
else {
tmp = 0;
while ( tmp < length / 4 ) { /* 16 / 4 == 4 > four Octets left to print */
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x.", ad[tmp++] );
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x.", ad[tmp++] );
}
if ( 1 == tmp ) { /* Special case for Designated IS */
cur--;
g_snprintf(cur, (gulong) (buf_len-(cur-buf)), ".%02x", ad[tmp] );
snprintf(cur, (gulong) (buf_len-(cur-buf)), ".%02x", ad[tmp] );
}
else {
for ( ; tmp < length; ) { /* print the rest without dot */
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
}
}
}
@ -208,11 +208,11 @@ print_address_prefix_buf(const guint8 *ad, int length, gchar *buf, int buf_len)
/* Show the one-octet AFI, the two-octet IDI, the one-octet DFI, the
* 3-octet AA, and the 2 reserved octets.
*/
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "[%02x|%02x:%02x][%02x|%02x:%02x:%02x|%02x:%02x]",
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "[%02x|%02x:%02x][%02x|%02x:%02x:%02x|%02x:%02x]",
ad[0], ad[1], ad[2], ad[3], ad[4],
ad[5], ad[6], ad[7], ad[8] );
/* Show the 2-octet RD and the 2-octet Area. */
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "[%02x:%02x|%02x:%02x]",
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "[%02x:%02x|%02x:%02x]",
ad[9], ad[10], ad[11], ad[12] );
/* Show whatever the heck this is; it's not specified by RFC 1237,
* but we also handle 14-octet areas. Is it the "Designated IS"
@ -220,7 +220,7 @@ print_address_prefix_buf(const guint8 *ad, int length, gchar *buf, int buf_len)
* spec about that.)
*/
if ( (RFC1237_FULLAREA_LEN + 1)*2 == length )
g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "-[%02x]", ad[13] );
snprintf(cur, (gulong) (buf_len-(cur-buf)), "-[%02x]", ad[13] );
}
else {
/* This doesn't look like a full RFC 1237 IS-IS area, so all we know
@ -231,31 +231,31 @@ print_address_prefix_buf(const guint8 *ad, int length, gchar *buf, int buf_len)
/* XXX - RFC1237_AREA_LEN, which is 3 octets, doesn't seem to
* correspond to anything in RFC 1237. Where did it come from?
*/
g_snprintf(buf, buf_len, "%02x.%02x%02x", ad[0], ad[1], ad[2] );
snprintf(buf, buf_len, "%02x.%02x%02x", ad[0], ad[1], ad[2] );
return;
}
if ( length == 4*2 ) {
g_snprintf(buf, buf_len, "%02x%02x%02x%02x", ad[0], ad[1], ad[2], ad[3] );
snprintf(buf, buf_len, "%02x%02x%02x%02x", ad[0], ad[1], ad[2], ad[3] );
return;
}
while ( tmp < length / 8 ) { /* 32/8==4 > four Octets left to print */
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x.", ad[tmp++] );
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x.", ad[tmp++] );
}
if ( 2 == tmp ) { /* Special case for Designated IS */
cur--;
g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "-%02x", ad[tmp] );
snprintf(cur, (gulong) (buf_len-(cur-buf)), "-%02x", ad[tmp] );
}
else {
for ( ; tmp < length / 2; ) { /* print the rest without dot or dash */
cur += g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
cur += snprintf(cur, (gulong) (buf_len-(cur-buf)), "%02x", ad[tmp++] );
}
/* Odd half-octet? */
if (length & 1) {
/* Yes - print it (it's the upper half-octet) */
g_snprintf(cur, (gulong) (buf_len-(cur-buf)), "%x", (ad[tmp] & 0xF0)>>4 );
snprintf(cur, (gulong) (buf_len-(cur-buf)), "%x", (ad[tmp] & 0xF0)>>4 );
}
}
}

View File

@ -125,7 +125,7 @@ extern ext_menu_t * ext_menubar_add_submenu(ext_menu_t * parent, const gchar *me
entry->proto = parent->proto;
entry->is_plugin = parent->is_plugin;
/* Create unique name, which is used by GTK to provide the menu */
entry->name = g_strdup_printf("%sS%02d", parent->name, parent->submenu_cnt);
entry->name = ws_strdup_printf("%sS%02d", parent->name, parent->submenu_cnt);
entry->label = g_strdup(menulabel);
entry->tooltip = g_strdup(menulabel);
@ -151,7 +151,7 @@ static void ext_menubar_add_generic_entry (
entry = g_new0(ext_menubar_t, 1);
entry->type = type;
/* Create unique name, which is used by GTK to provide the menu */
entry->name = g_strdup_printf("%sI%02d", parent->name, parent->item_cnt);
entry->name = ws_strdup_printf("%sI%02d", parent->name, parent->item_cnt);
entry->label = g_strdup(label);
if ( tooltip != NULL && strlen(tooltip) > 0 )

View File

@ -2477,7 +2477,7 @@ column_hidden_to_str_cb(pref_t* pref, gboolean default_val)
gchar *prefs_fmt;
cfmt = (fmt_data *) clp->data;
if ((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_fields)) {
prefs_fmt = g_strdup_printf("%s:%s:%d:%c",
prefs_fmt = ws_strdup_printf("%s:%s:%d:%c",
col_format_to_string(cfmt->fmt),
cfmt->custom_fields,
cfmt->custom_occurrence,
@ -2748,7 +2748,7 @@ column_format_to_str_cb(pref_t* pref, gboolean default_val)
cfmt = (fmt_data *) clp->data;
col_l = g_list_append(col_l, g_strdup(cfmt->title));
if ((cfmt->fmt == COL_CUSTOM) && (cfmt->custom_fields)) {
prefs_fmt = g_strdup_printf("%s:%s:%d:%c",
prefs_fmt = ws_strdup_printf("%s:%s:%d:%c",
col_format_to_string(cfmt->fmt),
cfmt->custom_fields,
cfmt->custom_occurrence,
@ -5025,7 +5025,7 @@ try_convert_to_custom_column(gpointer *el_data)
++haystack_idx) {
if (strcmp(migrated_columns[haystack_idx].col_fmt, *fmt) == 0) {
gchar *cust_col = g_strdup_printf("%%Cus:%s:0",
gchar *cust_col = ws_strdup_printf("%%Cus:%s:0",
migrated_columns[haystack_idx].col_expr);
g_free(*fmt);
@ -6175,7 +6175,7 @@ prefs_pref_type_description(pref_t *pref)
int type;
if (!pref) {
return g_strdup_printf("%s.", type_desc); /* ...or maybe assert? */
return ws_strdup_printf("%s.", type_desc); /* ...or maybe assert? */
}
type = pref->type;
@ -6396,13 +6396,13 @@ prefs_pref_to_str(pref_t *pref, pref_source_t source) {
switch (pref->info.base) {
case 10:
return g_strdup_printf("%u", pref_uint);
return ws_strdup_printf("%u", pref_uint);
case 8:
return g_strdup_printf("%#o", pref_uint);
return ws_strdup_printf("%#o", pref_uint);
case 16:
return g_strdup_printf("%#x", pref_uint);
return ws_strdup_printf("%#x", pref_uint);
}
break;
}
@ -6444,7 +6444,7 @@ prefs_pref_to_str(pref_t *pref, pref_source_t source) {
return ret_value;
case PREF_COLOR:
return g_strdup_printf("%02x%02x%02x",
return ws_strdup_printf("%02x%02x%02x",
(pref_color->red * 255 / 65535),
(pref_color->green * 255 / 65535),
(pref_color->blue * 255 / 65535));
@ -6463,7 +6463,7 @@ prefs_pref_to_str(pref_t *pref, pref_source_t source) {
{
uat_t *uat = pref->varp.uat;
if (uat && uat->filename)
return g_strdup_printf("[Managed in the file \"%s\"]", uat->filename);
return ws_strdup_printf("[Managed in the file \"%s\"]", uat->filename);
else
pref_text = "[Managed in an unknown file]";
break;

View File

@ -372,7 +372,7 @@ write_ek_proto_tree(output_fields_t* fields,
/* Timestamp added for time indexing in Elasticsearch */
json_dumper_set_member_name(&dumper, "timestamp");
json_dumper_value_anyf(&dumper, "\"%" G_GUINT64_FORMAT "%03d\"", (guint64)edt->pi.abs_ts.secs, edt->pi.abs_ts.nsecs/1000000);
json_dumper_value_anyf(&dumper, "\"%" PRIu64 "%03d\"", (guint64)edt->pi.abs_ts.secs, edt->pi.abs_ts.nsecs/1000000);
if (print_summary)
write_ek_summary(edt->pi.cinfo, &data);
@ -598,14 +598,14 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
case FT_INT48:
case FT_INT56:
case FT_INT64:
fprintf(pdata->fh, "%" G_GINT64_MODIFIER "X", fvalue_get_sinteger64(&fi->value));
fprintf(pdata->fh, "%" PRIX64, fvalue_get_sinteger64(&fi->value));
break;
case FT_UINT40:
case FT_UINT48:
case FT_UINT56:
case FT_UINT64:
case FT_BOOLEAN:
fprintf(pdata->fh, "%" G_GINT64_MODIFIER "X", fvalue_get_uinteger64(&fi->value));
fprintf(pdata->fh, "%" PRIX64, fvalue_get_uinteger64(&fi->value));
break;
default:
ws_assert_not_reached();
@ -716,7 +716,7 @@ write_json_index(json_dumper *dumper, epan_dissect_t *edt)
(void) g_strlcpy(ts, "XXXX-XX-XX", sizeof(ts)); /* XXX - better way of saying "Not representable"? */
}
json_dumper_set_member_name(dumper, "_index");
str = g_strdup_printf("packets-%s", ts);
str = ws_strdup_printf("packets-%s", ts);
json_dumper_value_string(dumper, str);
g_free(str);
}
@ -886,7 +886,7 @@ write_json_proto_node(GSList *node_values_head,
// Retrieve json key from first value.
proto_node *first_value = (proto_node *) node_values_head->data;
const char *json_key = proto_node_to_json_key(first_value);
gchar* json_key_suffix = g_strdup_printf("%s%s", json_key, suffix);
gchar* json_key_suffix = ws_strdup_printf("%s%s", json_key, suffix);
json_dumper_set_member_name(pdata->dumper, json_key_suffix);
g_free(json_key_suffix);
write_json_proto_node_value_list(node_values_head, value_writer, pdata);
@ -961,14 +961,14 @@ write_json_proto_node_hex_dump(proto_node *node, write_json_data *pdata)
case FT_INT48:
case FT_INT56:
case FT_INT64:
json_dumper_value_anyf(pdata->dumper, "\"%" G_GINT64_MODIFIER "X\"", fvalue_get_sinteger64(&fi->value));
json_dumper_value_anyf(pdata->dumper, "\"%" PRIX64 "\"", fvalue_get_sinteger64(&fi->value));
break;
case FT_UINT40:
case FT_UINT48:
case FT_UINT56:
case FT_UINT64:
case FT_BOOLEAN:
json_dumper_value_anyf(pdata->dumper, "\"%" G_GINT64_MODIFIER "X\"", fvalue_get_uinteger64(&fi->value));
json_dumper_value_anyf(pdata->dumper, "\"%" PRIX64 "\"", fvalue_get_uinteger64(&fi->value));
break;
default:
ws_assert_not_reached();
@ -978,10 +978,10 @@ write_json_proto_node_hex_dump(proto_node *node, write_json_data *pdata)
}
/* Dump raw hex-encoded dissected information including position, length, bitmask, type */
json_dumper_value_anyf(pdata->dumper, "%" G_GINT32_MODIFIER "d", fi->start);
json_dumper_value_anyf(pdata->dumper, "%" G_GINT32_MODIFIER "d", fi->length);
json_dumper_value_anyf(pdata->dumper, "%" G_GUINT64_FORMAT, fi->hfinfo->bitmask);
json_dumper_value_anyf(pdata->dumper, "%" G_GINT32_MODIFIER "d", (gint32)fvalue_type_ftenum(&fi->value));
json_dumper_value_anyf(pdata->dumper, "%" PRId32, fi->start);
json_dumper_value_anyf(pdata->dumper, "%" PRId32, fi->length);
json_dumper_value_anyf(pdata->dumper, "%" PRIu64, fi->hfinfo->bitmask);
json_dumper_value_anyf(pdata->dumper, "%" PRId32, (gint32)fvalue_type_ftenum(&fi->value));
json_dumper_end_array(pdata->dumper);
}
@ -1253,10 +1253,10 @@ ek_write_name(proto_node *pnode, gchar* suffix, write_json_data* pdata)
if (fi->hfinfo->parent != -1) {
header_field_info* parent = proto_registrar_get_nth(fi->hfinfo->parent);
str = g_strdup_printf("%s_%s%s", parent->abbrev, fi->hfinfo->abbrev, suffix ? suffix : "");
str = ws_strdup_printf("%s_%s%s", parent->abbrev, fi->hfinfo->abbrev, suffix ? suffix : "");
json_dumper_set_member_name(pdata->dumper, str);
} else {
str = g_strdup_printf("%s%s", fi->hfinfo->abbrev, suffix ? suffix : "");
str = ws_strdup_printf("%s%s", fi->hfinfo->abbrev, suffix ? suffix : "");
json_dumper_set_member_name(pdata->dumper, str);
}
g_free(str);
@ -1284,14 +1284,14 @@ ek_write_hex(field_info *fi, write_json_data *pdata)
case FT_INT48:
case FT_INT56:
case FT_INT64:
json_dumper_value_anyf(pdata->dumper, "\"%" G_GINT64_MODIFIER "X\"", fvalue_get_sinteger64(&fi->value));
json_dumper_value_anyf(pdata->dumper, "\"%" PRIX64 "\"", fvalue_get_sinteger64(&fi->value));
break;
case FT_UINT40:
case FT_UINT48:
case FT_UINT56:
case FT_UINT64:
case FT_BOOLEAN:
json_dumper_value_anyf(pdata->dumper, "\"%" G_GINT64_MODIFIER "X\"", fvalue_get_uinteger64(&fi->value));
json_dumper_value_anyf(pdata->dumper, "\"%" PRIX64 "\"", fvalue_get_uinteger64(&fi->value));
break;
default:
ws_assert_not_reached();
@ -1985,7 +1985,7 @@ print_hex_data(print_stream_t *stream, epan_dissect_t *edt)
tvb = get_data_source_tvb(src);
if (multiple_sources) {
name = get_data_source_name(src);
line = g_strdup_printf("%s:", name);
line = ws_strdup_printf("%s:", name);
wmem_free(NULL, name);
print_line(stream, 0, line);
g_free(line);
@ -2406,7 +2406,7 @@ static void format_field_values(output_fields_t* fields, gpointer field_index, g
* character as a separator between the previous element
* and this element.
*/
g_ptr_array_add(fv_p, (gpointer)g_strdup_printf("%c", fields->aggregator));
g_ptr_array_add(fv_p, (gpointer)ws_strdup_printf("%c", fields->aggregator));
}
break;
default:
@ -2498,7 +2498,7 @@ static void write_specified_fields(fields_format format, output_fields_t *fields
if (!get_column_visible(col))
continue;
/* Prepend COLUMN_FIELD_FILTER as the field name */
col_name = g_strdup_printf("%s%s", COLUMN_FIELD_FILTER, cinfo->columns[col].col_title);
col_name = ws_strdup_printf("%s%s", COLUMN_FIELD_FILTER, cinfo->columns[col].col_title);
field_index = g_hash_table_lookup(fields->field_indicies, col_name);
g_free(col_name);
@ -2746,7 +2746,7 @@ get_field_hex_value(GSList *src_list, field_info *fi)
p = buffer;
/* Print a simple hex dump */
for (i = 0 ; i < fi->length; i++) {
g_snprintf(p, chars_per_byte+1, "%02x", pd[i]);
snprintf(p, chars_per_byte+1, "%02x", pd[i]);
p += chars_per_byte;
}
return buffer;

View File

@ -169,7 +169,7 @@ struct ptvcursor {
}
#ifdef ENABLE_CHECK_FILTER
#define CHECK_HF_VALUE(type, modifier, start_values) \
#define CHECK_HF_VALUE(type, spec, start_values) \
{ \
const type *current; \
int n, m; \
@ -186,7 +186,7 @@ struct ptvcursor {
if ((start_values[m].value == current->value) && \
(strcmp(start_values[m].strptr, current->strptr) != 0)) { \
ws_warning("Field '%s' (%s) has a conflicting entry in its" \
" value_string: %" modifier "u is at indices %u (%s) and %u (%s)", \
" value_string: %" spec " is at indices %u (%s) and %u (%s)", \
hfinfo->name, hfinfo->abbrev, \
current->value, m, start_values[m].strptr, n, current->strptr); \
} \
@ -845,7 +845,7 @@ proto_tree_free(proto_tree *tree)
/* 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 g_vsnprintf and copy strings around.
* having to call vsnprintf and copy strings around.
*/
gboolean
proto_tree_set_visible(proto_tree *tree, gboolean visible)
@ -4334,7 +4334,7 @@ proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb,
pi = proto_tree_add_pi(tree, hfinfo, tvb, start, &length);
va_start(ap, format);
protocol_rep = g_strdup_vprintf(format, ap);
protocol_rep = ws_strdup_vprintf(format, ap);
proto_tree_set_protocol_tvb(PNODE_FINFO(pi), protocol_tvb, protocol_rep);
g_free(protocol_rep);
va_end(ap);
@ -6313,11 +6313,11 @@ proto_tree_set_representation_value(proto_item *pi, const char *format, va_list
}
/* put in the hf name */
ret += g_snprintf(fi->rep->representation + ret, ITEM_LABEL_LENGTH - ret, "%s: ", hf->name);
ret += snprintf(fi->rep->representation + ret, ITEM_LABEL_LENGTH - ret, "%s: ", hf->name);
/* If possible, Put in the value of the string */
if (ret < ITEM_LABEL_LENGTH) {
ret += g_vsnprintf(fi->rep->representation + ret,
ret += vsnprintf(fi->rep->representation + ret,
ITEM_LABEL_LENGTH - ret, format, ap);
}
if (ret >= ITEM_LABEL_LENGTH) {
@ -6342,7 +6342,7 @@ proto_tree_set_representation(proto_item *pi, const char *format, va_list ap)
if (!proto_item_is_hidden(pi)) {
ITEM_LABEL_NEW(PNODE_POOL(pi), fi->rep);
ret = g_vsnprintf(fi->rep->representation, ITEM_LABEL_LENGTH,
ret = vsnprintf(fi->rep->representation, ITEM_LABEL_LENGTH,
format, ap);
if (ret >= ITEM_LABEL_LENGTH) {
/* Uh oh, we don't have enough room. Tell the user
@ -6636,11 +6636,11 @@ proto_item_fill_display_label(field_info *finfo, gchar *display_label_str, const
case FT_FLOAT:
if (hfinfo->display & BASE_UNIT_STRING) {
double d_value = fvalue_get_floating(&finfo->value);
g_snprintf(display_label_str, label_str_size,
snprintf(display_label_str, label_str_size,
"%." G_STRINGIFY(FLT_DIG) "g%s", d_value,
unit_name_string_get_double(d_value, (const unit_name_string*)hfinfo->strings));
} else {
g_snprintf(display_label_str, label_str_size,
snprintf(display_label_str, label_str_size,
"%." G_STRINGIFY(FLT_DIG) "g", fvalue_get_floating(&finfo->value));
}
label_len = (int)strlen(display_label_str);
@ -6649,11 +6649,11 @@ proto_item_fill_display_label(field_info *finfo, gchar *display_label_str, const
case FT_DOUBLE:
if (hfinfo->display & BASE_UNIT_STRING) {
double d_value = fvalue_get_floating(&finfo->value);
g_snprintf(display_label_str, label_str_size,
snprintf(display_label_str, label_str_size,
"%." G_STRINGIFY(DBL_DIG) "g%s", d_value,
unit_name_string_get_double(d_value, (const unit_name_string*)hfinfo->strings));
} else {
g_snprintf(display_label_str, label_str_size,
snprintf(display_label_str, label_str_size,
"%." G_STRINGIFY(DBL_DIG) "g", fvalue_get_floating(&finfo->value));
}
label_len = (int)strlen(display_label_str);
@ -6799,7 +6799,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
if (hfinfo->strings && FIELD_DISPLAY(hfinfo->display) == BASE_NONE) {
hf_str_val = hf_try_val_to_str(number, hfinfo);
g_snprintf(expr+offset_e, size-offset_e, "\"%s\"", hf_str_val);
snprintf(expr+offset_e, size-offset_e, "\"%s\"", hf_str_val);
} else {
number_out = hfinfo_char_value_format(hfinfo, number_buf, number);
@ -6833,7 +6833,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
if (hf_str_val && FIELD_DISPLAY(hfinfo->display) == BASE_NONE) {
hf_str_val = hf_try_val_to_str(number, hfinfo);
g_snprintf(expr+offset_e, size-offset_e, "\"%s\"", hf_str_val);
snprintf(expr+offset_e, size-offset_e, "\"%s\"", hf_str_val);
} else {
number_out = hfinfo_numeric_value_format(hfinfo, number_buf, number);
@ -6863,7 +6863,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
}
if (hf_str_val && FIELD_DISPLAY(hfinfo->display) == BASE_NONE) {
g_snprintf(expr+offset_e, size-offset_e, "\"%s\"", hf_str_val);
snprintf(expr+offset_e, size-offset_e, "\"%s\"", hf_str_val);
} else {
number_out = hfinfo_numeric_value_format64(hfinfo, number_buf, number64);
@ -7008,7 +7008,7 @@ proto_item_append_text(proto_item *pi, const char *format, ...)
curlen = strlen(fi->rep->representation);
if (ITEM_LABEL_LENGTH > curlen) {
va_start(ap, format);
g_vsnprintf(fi->rep->representation + curlen,
vsnprintf(fi->rep->representation + curlen,
ITEM_LABEL_LENGTH - (gulong) curlen, format, ap);
va_end(ap);
}
@ -7042,7 +7042,7 @@ proto_item_prepend_text(proto_item *pi, const char *format, ...)
(void) g_strlcpy(representation, fi->rep->representation, ITEM_LABEL_LENGTH);
va_start(ap, format);
g_vsnprintf(fi->rep->representation,
vsnprintf(fi->rep->representation,
ITEM_LABEL_LENGTH, format, ap);
va_end(ap);
(void) g_strlcat(fi->rep->representation, representation, ITEM_LABEL_LENGTH);
@ -8284,14 +8284,14 @@ tmp_fld_check_assert(header_field_info *hfinfo)
if (hfinfo->display & BASE_EXT_STRING) {
if (hfinfo->display & BASE_VAL64_STRING) {
const val64_string *start_values = VAL64_STRING_EXT_VS_P((const val64_string_ext*)hfinfo->strings);
CHECK_HF_VALUE(val64_string, G_GINT64_MODIFIER, start_values);
CHECK_HF_VALUE(val64_string, PRIu64, start_values);
} else {
const value_string *start_values = VALUE_STRING_EXT_VS_P((const value_string_ext*)hfinfo->strings);
CHECK_HF_VALUE(value_string, "", start_values);
CHECK_HF_VALUE(value_string, "u", start_values);
}
} else {
const value_string *start_values = (const value_string*)hfinfo->strings;
CHECK_HF_VALUE(value_string, "", start_values);
CHECK_HF_VALUE(value_string, "u", start_values);
}
}
@ -9119,12 +9119,12 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
{
double d_value = fvalue_get_floating(&fi->value);
if (hfinfo->display & BASE_UNIT_STRING) {
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %." G_STRINGIFY(FLT_DIG) "g%s",
hfinfo->name, d_value,
unit_name_string_get_double(d_value, (const unit_name_string*)hfinfo->strings));
} else {
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %." G_STRINGIFY(FLT_DIG) "g",
hfinfo->name, d_value);
}
@ -9135,12 +9135,12 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
{
double d_value = fvalue_get_floating(&fi->value);
if (hfinfo->display & BASE_UNIT_STRING) {
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %." G_STRINGIFY(DBL_DIG) "g%s",
hfinfo->name, d_value,
unit_name_string_get_double(d_value, (const unit_name_string*)hfinfo->strings));
} else {
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %." G_STRINGIFY(DBL_DIG) "g",
hfinfo->name, d_value);
}
@ -9155,7 +9155,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
case FT_RELATIVE_TIME:
tmp = rel_time_to_secs_str(NULL, (const nstime_t *)fvalue_get(&fi->value));
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s seconds", hfinfo->name, tmp);
wmem_free(NULL, tmp);
break;
@ -9163,7 +9163,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
case FT_IPXNET:
integer = fvalue_get_uinteger(&fi->value);
tmp = get_ipxnet_name(NULL, integer);
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s (0x%08X)", hfinfo->name,
tmp, integer);
wmem_free(NULL, tmp);
@ -9175,7 +9175,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
addr.data = (guint8 *)fvalue_get(&fi->value);
addr_str = (char*)address_to_str(NULL, &addr);
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", hfinfo->name, addr_str);
wmem_free(NULL, addr_str);
break;
@ -9186,7 +9186,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
addr.data = (guint8 *)fvalue_get(&fi->value);
addr_str = (char*)address_to_str(NULL, &addr);
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", hfinfo->name, addr_str);
wmem_free(NULL, addr_str);
break;
@ -9199,7 +9199,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
addr.data = bytes;
addr_str = (char*)address_with_resolution_to_str(NULL, &addr);
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", hfinfo->name, addr_str);
wmem_free(NULL, addr_str);
break;
@ -9216,7 +9216,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
} else {
addr_str = (char*)address_with_resolution_to_str(NULL, &addr);
}
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", hfinfo->name, addr_str);
wmem_free(NULL, addr_str);
break;
@ -9229,7 +9229,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
addr.data = bytes;
addr_str = (char*)address_with_resolution_to_str(NULL, &addr);
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", hfinfo->name, addr_str);
wmem_free(NULL, addr_str);
break;
@ -9240,7 +9240,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
addr.data = (guint8 *)fvalue_get(&fi->value);
addr_str = (char*)address_with_resolution_to_str(NULL, &addr);
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", hfinfo->name, addr_str);
wmem_free(NULL, addr_str);
break;
@ -9307,7 +9307,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
case FT_IEEE_11073_SFLOAT:
case FT_IEEE_11073_FLOAT:
tmp = fvalue_to_string_repr(NULL, &fi->value, FTREPR_DISPLAY, hfinfo->display);
g_snprintf(label_str, ITEM_LABEL_LENGTH,
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s",
hfinfo->name, tmp);
wmem_free(NULL, tmp);
@ -10096,11 +10096,11 @@ hfinfo_number_value_format_display(const header_field_info *hfinfo, int display,
manuf_name = uint_get_manuf_name_if_known(value);
if (manuf_name == NULL) {
/* Could not find an OUI. */
g_snprintf(buf, 32, "%02x:%02x:%02x", p_oui[0], p_oui[1], p_oui[2]);
snprintf(buf, 32, "%02x:%02x:%02x", p_oui[0], p_oui[1], p_oui[2]);
}
else {
/* Found an address string. */
g_snprintf(buf, 32, "%02x:%02x:%02x (%s)", p_oui[0], p_oui[1], p_oui[2], manuf_name);
snprintf(buf, 32, "%02x:%02x:%02x (%s)", p_oui[0], p_oui[1], p_oui[2], manuf_name);
}
return buf;
}
@ -10826,7 +10826,7 @@ proto_registrar_dump_values(void)
else if (vals64) {
vi = 0;
while (vals64[vi].strptr) {
printf("V64\t%s\t%" G_GINT64_MODIFIER "u\t%s\n",
printf("V64\t%s\t%" PRIu64 "\t%s\n",
hfinfo->abbrev,
vals64[vi].value,
vals64[vi].strptr);
@ -11095,7 +11095,7 @@ proto_registrar_dump_elastic(const gchar* filter)
/* Skip the fields that would map into string. This is the default in elasticsearch. */
type = ws_type_to_elastic(hfinfo->type);
if (type) {
str = g_strdup_printf("%s_%s", prev_proto, hfinfo->abbrev);
str = ws_strdup_printf("%s_%s", prev_proto, hfinfo->abbrev);
json_dumper_set_member_name(&dumper, dot_to_underscore(str));
g_free(str);
json_dumper_begin_object(&dumper); // 9.hfinfo->abbrev
@ -11236,7 +11236,7 @@ proto_registrar_dump_fields(void)
}
} else if (hfinfo->type == FT_BOOLEAN) {
/* For FT_BOOLEAN: 'display' can be "parent bitfield width" */
g_snprintf(width, sizeof(width), "%d", hfinfo->display);
snprintf(width, sizeof(width), "%d", hfinfo->display);
base_name = width;
}
@ -11246,7 +11246,7 @@ proto_registrar_dump_fields(void)
else if (strlen(blurb) == 0)
blurb = "\"\"";
printf("F\t%s\t%s\t%s\t%s\t%s\t0x%" G_GINT64_MODIFIER "x\t%s\n",
printf("F\t%s\t%s\t%s\t%s\t%s\t0x%" PRIx64 "\t%s\n",
hfinfo->name, hfinfo->abbrev, enum_name,
parent_hfinfo->abbrev, base_name,
hfinfo->bitmask, blurb);
@ -11482,16 +11482,16 @@ construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
*filter = (char *)wmem_alloc0(NULL, buf_len);
ptr = *filter;
ptr += g_snprintf(ptr, (gulong) (buf_len-(ptr-*filter)),
ptr += snprintf(ptr, (gulong) (buf_len-(ptr-*filter)),
"frame[%d:%d] == ", finfo->start, length);
for (i=0; i<length; i++) {
c = tvb_get_guint8(finfo->ds_tvb, start);
start++;
if (i == 0 ) {
ptr += g_snprintf(ptr, (gulong) (buf_len-(ptr-*filter)), "%02x", c);
ptr += snprintf(ptr, (gulong) (buf_len-(ptr-*filter)), "%02x", c);
}
else {
ptr += g_snprintf(ptr, (gulong) (buf_len-(ptr-*filter)), ":%02x", c);
ptr += snprintf(ptr, (gulong) (buf_len-(ptr-*filter)), ":%02x", c);
}
}
}
@ -12424,7 +12424,7 @@ proto_tree_add_split_bits_item_ret_val(proto_tree *tree, const int hfindex, tvbu
mask_greatest_bit_offset);
} else {
/* If the bitmask is too large, try to describe its contents. */
g_snprintf(bf_str, sizeof(bf_str), "%d bits", no_of_bits);
snprintf(bf_str, sizeof(bf_str), "%d bits", no_of_bits);
}
switch (hf_field->type) {

View File

@ -213,7 +213,7 @@ void proto_report_dissector_bug(const char *format, ...)
#define DISSECTOR_ASSERT_CMPINT(a, op, b) \
((void) ((a op b) ? (void)0 : \
__DISSECTOR_ASSERT_CMPINT (a, op, b, gint64, "%" G_GINT64_MODIFIER "d"))) \
__DISSECTOR_ASSERT_CMPINT (a, op, b, int64_t, "%" PRId64))) \
__DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(a op b)
/** Like DISSECTOR_ASSERT_CMPINT() except the arguments are treated as
@ -223,7 +223,7 @@ void proto_report_dissector_bug(const char *format, ...)
*/
#define DISSECTOR_ASSERT_CMPUINT(a, op, b) \
((void) ((a op b) ? (void)0 : \
__DISSECTOR_ASSERT_CMPINT (a, op, b, guint64, "%" G_GINT64_MODIFIER "u"))) \
__DISSECTOR_ASSERT_CMPINT (a, op, b, uint64_t, "%" PRIu64))) \
__DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(a op b)
/** Like DISSECTOR_ASSERT_CMPUINT() except the values are displayed in
@ -231,7 +231,7 @@ void proto_report_dissector_bug(const char *format, ...)
*/
#define DISSECTOR_ASSERT_CMPUINTHEX(a, op, b) \
((void) ((a op b) ? (void)0 : \
__DISSECTOR_ASSERT_CMPINT (a, op, b, guint64, "0x%" G_GINT64_MODIFIER "X"))) \
__DISSECTOR_ASSERT_CMPINT (a, op, b, uint64_t, "0x%" PRIX64))) \
__DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(a op b)
/*
@ -1169,7 +1169,7 @@ WS_DLL_PUBLIC void proto_tree_free(proto_tree *tree);
/** Set the tree visible or invisible.
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 g_vsnprintf and copy strings around.
having to call vsnprintf and copy strings around.
@param tree the tree to be set
@param visible ... or not
@return the old value */

View File

@ -518,9 +518,9 @@ emptyStatement ::= PT_SEMICOLON.
/* constant = fullIdent | ( [ "-" | "+" ] intLit ) | ( [ "-" | "+" ] floatLit ) | strLit | boolLit */
constant(A) ::= exIdent(B). { A = B->v; } /* boolLit is parsed as exIdent */
constant ::= strLit.
constant(A) ::= intLit(B). { A = pbl_store_string_token(state, g_strdup_printf("%" G_GUINT64_FORMAT, B)); }
constant(A) ::= PT_PLUS intLit(B). { A = pbl_store_string_token(state, g_strdup_printf("%" G_GUINT64_FORMAT, B)); }
constant(A) ::= PT_MINUS intLit(B). { A = pbl_store_string_token(state, g_strdup_printf("-%" G_GUINT64_FORMAT, B)); }
constant(A) ::= intLit(B). { A = pbl_store_string_token(state, ws_strdup_printf("%" PRIu64, B)); }
constant(A) ::= PT_PLUS intLit(B). { A = pbl_store_string_token(state, ws_strdup_printf("%" PRIu64, B)); }
constant(A) ::= PT_MINUS intLit(B). { A = pbl_store_string_token(state, ws_strdup_printf("-%" PRIu64, B)); }
constant(A) ::= PT_PLUS exIdent(B). { A = pbl_store_string_token(state, g_strconcat("+", B->v, NULL)); } /* This cover floatLit. */
constant(A) ::= PT_MINUS exIdent(B). { A = pbl_store_string_token(state, g_strconcat("-", B->v, NULL)); }
@ -559,7 +559,7 @@ pbl_parser_error(protobuf_lang_state_t *state, const char *fmt, ...)
void* scanner;
va_list ap;
va_start(ap, fmt);
msg = g_strdup_vprintf(fmt, ap);
msg = ws_strdup_vprintf(fmt, ap);
scanner = state ? state->scanner : NULL;
protobuf_lang_error(scanner, state, msg);
va_end(ap);

View File

@ -895,7 +895,7 @@ pbl_node_t* pbl_create_field_node(pbl_file_descriptor_t* file, int lineno, const
case PROTOBUF_TYPE_INT32:
case PROTOBUF_TYPE_SINT32:
case PROTOBUF_TYPE_SFIXED32:
sscanf(node->orig_default_value, "%" G_GINT32_FORMAT, &node->default_value.i32);
sscanf(node->orig_default_value, "%" PRId32, &node->default_value.i32);
break;
case PROTOBUF_TYPE_INT64:
@ -906,7 +906,7 @@ pbl_node_t* pbl_create_field_node(pbl_file_descriptor_t* file, int lineno, const
case PROTOBUF_TYPE_UINT32:
case PROTOBUF_TYPE_FIXED32:
sscanf(node->orig_default_value, "%" G_GUINT32_FORMAT, &node->default_value.u32);
sscanf(node->orig_default_value, "%" PRIu32, &node->default_value.u32);
break;
case PROTOBUF_TYPE_UINT64:

View File

@ -13,11 +13,10 @@
#ifndef __PROTOBUF_LANG_TREE_H__
#define __PROTOBUF_LANG_TREE_H__
#include <glib.h>
#include <wireshark.h>
#include <stdio.h>
#include <stdarg.h>
#include "ws_attributes.h"
#ifdef __cplusplus
extern "C" {

View File

@ -289,7 +289,7 @@ static void add_value(Radius_scanner_state_t* state, const gchar* attrib_name, c
<ATTR>[0-9a-z_/.-]+ { yyextra->attr_name = g_strdup(yytext); yyextra->encrypted = 0; yyextra->has_tag = FALSE; BEGIN ATTR_W_NAME; }
<ATTR_W_NAME>[0-9.]+ { yyextra->attr_id = g_strdup(yytext); BEGIN ATTR_W_ID;}
<ATTR_W_NAME>0x[0-9a-f]+ { yyextra->attr_id = g_strdup_printf("%u",(int)strtoul(yytext,NULL,16)); BEGIN ATTR_W_ID;}
<ATTR_W_NAME>0x[0-9a-f]+ { yyextra->attr_id = ws_strdup_printf("%u",(int)strtoul(yytext,NULL,16)); BEGIN ATTR_W_ID;}
<ATTR_W_ID>integer { yyextra->attr_type = radius_integer; BEGIN ATTR_W_TYPE; }
<ATTR_W_ID>string { yyextra->attr_type = radius_string; BEGIN ATTR_W_TYPE; }
<ATTR_W_ID>octets { yyextra->attr_type = radius_octets; BEGIN ATTR_W_TYPE; }
@ -359,7 +359,7 @@ static void add_value(Radius_scanner_state_t* state, const gchar* attrib_name, c
yyextra->include_stack[yyextra->include_stack_ptr++] = YY_CURRENT_BUFFER;
yyextra->fullpaths[yyextra->include_stack_ptr] = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
yyextra->fullpaths[yyextra->include_stack_ptr] = ws_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
yyextra->directory,yytext);
yyin = ws_fopen( yyextra->fullpaths[yyextra->include_stack_ptr], "r" );
@ -742,7 +742,7 @@ gboolean radius_load_dictionary (radius_dictionary_t* d, gchar* dir, const gchar
state.directory = dir;
state.fullpaths[0] = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
state.fullpaths[0] = ws_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
state.directory,filename);
state.linenums[0] = 1;
for (i = 1; i < MAX_INCLUDE_DEPTH; i++) {

View File

@ -261,7 +261,7 @@ pkcs11_load_keys_from_token(const char *token_uri, const char *pin, char **err)
ret = gnutls_pkcs11_obj_list_import_url4(&list, &nlist, token_uri,
GNUTLS_PKCS11_OBJ_FLAG_PRIVKEY|GNUTLS_PKCS11_OBJ_FLAG_LOGIN);
if (ret < 0) {
*err = g_strdup_printf("Failed to iterate through objects for %s: %s", token_uri, gnutls_strerror(ret));
*err = ws_strdup_printf("Failed to iterate through objects for %s: %s", token_uri, gnutls_strerror(ret));
goto cleanup;
}
@ -443,7 +443,7 @@ load_rsa_keyfile(const char *filename, const char *password, gboolean save_key,
FILE *fp = ws_fopen(filename, "rb");
if (!fp) {
*err = g_strdup_printf("Error loading RSA key file %s: %s", filename, g_strerror(errno));
*err = ws_strdup_printf("Error loading RSA key file %s: %s", filename, g_strerror(errno));
return;
}
@ -455,7 +455,7 @@ load_rsa_keyfile(const char *filename, const char *password, gboolean save_key,
}
fclose(fp);
if (!x509_priv_key) {
*err = g_strdup_printf("Error loading RSA key file %s: %s", filename, errmsg);
*err = ws_strdup_printf("Error loading RSA key file %s: %s", filename, errmsg);
g_free(errmsg);
return;
}
@ -464,12 +464,12 @@ load_rsa_keyfile(const char *filename, const char *password, gboolean save_key,
ret = gnutls_privkey_import_x509(privkey, x509_priv_key,
GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE|GNUTLS_PRIVKEY_IMPORT_COPY);
if (ret < 0) {
*err = g_strdup_printf("Error importing private key %s: %s", filename, gnutls_strerror(ret));
*err = ws_strdup_printf("Error importing private key %s: %s", filename, gnutls_strerror(ret));
goto end;
}
ret = gnutls_x509_privkey_get_key_id(x509_priv_key, GNUTLS_KEYID_USE_SHA1, key_id.key_id, &size);
if (ret < 0 || size != sizeof(key_id)) {
*err = g_strdup_printf("Error calculating Key ID for %s: %s", filename, gnutls_strerror(ret));
*err = ws_strdup_printf("Error calculating Key ID for %s: %s", filename, gnutls_strerror(ret));
goto end;
}

View File

@ -146,7 +146,7 @@ void sequence_analysis_use_col_info_as_label_comment(packet_info *pinfo, seq_ana
if (colinfo != NULL) {
sai->frame_label = g_strdup(colinfo);
if (protocol != NULL) {
sai->comment = g_strdup_printf("%s: %s", protocol, colinfo);
sai->comment = ws_strdup_printf("%s: %s", protocol, colinfo);
} else {
sai->comment = g_strdup(colinfo);
}
@ -559,8 +559,8 @@ sequence_analysis_dump_to_file(FILE *of, seq_analysis_info_t *sainfo, unsigned
end_position
);
g_snprintf(src_port, sizeof(src_port), "(%i)", sai->port_src);
g_snprintf(dst_port, sizeof(dst_port), "(%i)", sai->port_dst);
snprintf(src_port, sizeof(src_port), "(%i)", sai->port_src);
snprintf(dst_port, sizeof(dst_port), "(%i)", sai->port_dst);
if (start_position<end_position) {
overwrite(tmp_str, src_port, start_position-9, start_position-1);

View File

@ -72,7 +72,7 @@ typedef struct register_analysis register_analysis_t;
#if 0
#define SEQ_ANALYSIS_DEBUG(...) { \
char *SEQ_ANALYSIS_DEBUG_MSG = g_strdup_printf(__VA_ARGS__); \
char *SEQ_ANALYSIS_DEBUG_MSG = ws_strdup_printf(__VA_ARGS__); \
ws_warning("sequence analysis: %s:%d %s", G_STRFUNC, __LINE__, SEQ_ANALYSIS_DEBUG_MSG); \
g_free(SEQ_ANALYSIS_DEBUG_MSG); \
}

View File

@ -54,10 +54,10 @@ extern gchar*
stats_tree_node_to_str(const stat_node *node, gchar *buffer, guint len)
{
if (buffer) {
g_snprintf(buffer,len,"%s: %i",node->name, node->counter);
snprintf(buffer,len,"%s: %i",node->name, node->counter);
return buffer;
} else {
return g_strdup_printf("%s: %i",node->name, node->counter);
return ws_strdup_printf("%s: %i",node->name, node->counter);
}
}
@ -1101,16 +1101,16 @@ stats_tree_get_values_from_node (const stat_node* node)
gchar **values = (gchar**) g_malloc0(sizeof(gchar*)*(node->st->num_columns));
values[COL_NAME] = (node->st_flags&ST_FLG_ROOTCHILD)?stats_tree_get_displayname(node->name):g_strdup(node->name);
values[COL_COUNT] = g_strdup_printf("%u",node->counter);
values[COL_COUNT] = ws_strdup_printf("%u",node->counter);
if (((node->st_flags&ST_FLG_AVERAGE) || node->rng)) {
if (node->counter) {
switch (node->datatype)
{
case STAT_DT_INT:
values[COL_AVERAGE] = g_strdup_printf("%.2f", ((float)node->total.int_total) / node->counter);
values[COL_AVERAGE] = ws_strdup_printf("%.2f", ((float)node->total.int_total) / node->counter);
break;
case STAT_DT_FLOAT:
values[COL_AVERAGE] = g_strdup_printf("%.2f", node->total.float_total / node->counter);
values[COL_AVERAGE] = ws_strdup_printf("%.2f", node->total.float_total / node->counter);
break;
}
} else {
@ -1125,10 +1125,10 @@ stats_tree_get_values_from_node (const stat_node* node)
switch (node->datatype)
{
case STAT_DT_INT:
values[COL_MIN] = g_strdup_printf("%d", node->minvalue.int_min);
values[COL_MIN] = ws_strdup_printf("%d", node->minvalue.int_min);
break;
case STAT_DT_FLOAT:
values[COL_MIN] = g_strdup_printf("%f", node->minvalue.float_min);
values[COL_MIN] = ws_strdup_printf("%f", node->minvalue.float_min);
break;
}
}
@ -1145,10 +1145,10 @@ stats_tree_get_values_from_node (const stat_node* node)
switch (node->datatype)
{
case STAT_DT_INT:
values[COL_MAX] = g_strdup_printf("%d", node->maxvalue.int_max);
values[COL_MAX] = ws_strdup_printf("%d", node->maxvalue.int_max);
break;
case STAT_DT_FLOAT:
values[COL_MAX] = g_strdup_printf("%f", node->maxvalue.float_max);
values[COL_MAX] = ws_strdup_printf("%f", node->maxvalue.float_max);
break;
}
}
@ -1160,18 +1160,18 @@ stats_tree_get_values_from_node (const stat_node* node)
values[COL_MAX] = g_strdup("");
}
values[COL_RATE] = (node->st->elapsed)?g_strdup_printf("%.4f",((float)node->counter)/node->st->elapsed):g_strdup("");
values[COL_RATE] = (node->st->elapsed)?ws_strdup_printf("%.4f",((float)node->counter)/node->st->elapsed):g_strdup("");
values[COL_PERCENT] = ((node->parent)&&(node->parent->counter))?
g_strdup_printf("%.2f%%",(node->counter*100.0)/node->parent->counter):
ws_strdup_printf("%.2f%%",(node->counter*100.0)/node->parent->counter):
(node->parent==&(node->st->root)?g_strdup("100%"):g_strdup(""));
if (node->st->num_columns>COL_BURSTTIME) {
values[COL_BURSTRATE] = (!prefs.st_enable_burstinfo)?g_strdup(""):
(node->max_burst?(prefs.st_burst_showcount?
g_strdup_printf("%d",node->max_burst):
g_strdup_printf("%.4f",((double)node->max_burst)/prefs.st_burst_windowlen)):
ws_strdup_printf("%d",node->max_burst):
ws_strdup_printf("%.4f",((double)node->max_burst)/prefs.st_burst_windowlen)):
g_strdup("-"));
values[COL_BURSTTIME] = (!prefs.st_enable_burstinfo)?g_strdup(""):
(node->max_burst?g_strdup_printf("%.3f",(node->burst_time/1000.0)):g_strdup("-"));
(node->max_burst?ws_strdup_printf("%.3f",(node->burst_time/1000.0)):g_strdup("-"));
}
return values;
}
@ -1333,10 +1333,10 @@ stats_tree_format_as_str(const stats_tree* st, st_format_type format_type,
s = g_string_new("\n");
g_string_append(s,separator);
g_string_append_printf(s,"\n%s:\n",st->cfg->name);
g_snprintf (fmt,(gulong)sizeof(fmt),"%%-%us",maxnamelen);
snprintf (fmt,(gulong)sizeof(fmt),"%%-%us",maxnamelen);
g_string_append_printf(s,fmt,stats_tree_get_column_name(0));
for (count = 1; count<st->num_columns; count++) {
g_snprintf (fmt,(gulong)sizeof(fmt)," %%-%us",stats_tree_get_column_size(count)+1);
snprintf (fmt,(gulong)sizeof(fmt)," %%-%us",stats_tree_get_column_size(count)+1);
g_string_append_printf(s,fmt,stats_tree_get_column_name(count));
}
memset (separator, '-', sep_length);
@ -1406,7 +1406,7 @@ WS_DLL_PUBLIC void stats_tree_format_node_as_str(const stat_node *node,
switch(format_type) {
case ST_FORMAT_YAML:
if (indent) {
g_snprintf(fmt, (gulong)sizeof(fmt), "%%%ds%%s%%s", indent*4-2);
snprintf(fmt, (gulong)sizeof(fmt), "%%%ds%%s%%s", indent*4-2);
}
g_string_append_printf(s, fmt, "", indent?"- ":"", "Description");
g_string_append_printf(s, ": \"%s\"\n", values[0]);
@ -1444,10 +1444,10 @@ WS_DLL_PUBLIC void stats_tree_format_node_as_str(const stat_node *node,
g_string_append (s,"\n");
break;
case ST_FORMAT_PLAIN:
g_snprintf (fmt,(gulong)sizeof(fmt),"%%%ds%%-%us",indent,maxnamelen-indent);
snprintf (fmt,(gulong)sizeof(fmt),"%%%ds%%-%us",indent,maxnamelen-indent);
g_string_append_printf(s,fmt,"",values[0]);
for (count = 1; count<num_columns; count++) {
g_snprintf (fmt,(gulong)sizeof(fmt)," %%-%us",stats_tree_get_column_size(count)+1);
snprintf (fmt,(gulong)sizeof(fmt)," %%-%us",stats_tree_get_column_size(count)+1);
g_string_append_printf(s,fmt,values[count]);
}
g_string_append (s,"\n");
@ -1456,7 +1456,7 @@ WS_DLL_PUBLIC void stats_tree_format_node_as_str(const stat_node *node,
indent++;
indent = indent > INDENT_MAX ? INDENT_MAX : indent;
full_path = g_strdup_printf ("%s/%s",path,values[0]);
full_path = ws_strdup_printf ("%s/%s",path,values[0]);
for (count = 0; count<num_columns; count++) {
g_free(values[count]);

View File

@ -312,27 +312,27 @@ display_epoch_time(gchar *buf, int buflen, const time_t sec, gint32 frac,
switch (units) {
case TO_STR_TIME_RES_T_SECS:
g_snprintf(buf, buflen, "%0.0f", elapsed_secs);
snprintf(buf, buflen, "%0.0f", elapsed_secs);
break;
case TO_STR_TIME_RES_T_DSECS:
g_snprintf(buf, buflen, "%0.0f.%01d", elapsed_secs, frac);
snprintf(buf, buflen, "%0.0f.%01d", elapsed_secs, frac);
break;
case TO_STR_TIME_RES_T_CSECS:
g_snprintf(buf, buflen, "%0.0f.%02d", elapsed_secs, frac);
snprintf(buf, buflen, "%0.0f.%02d", elapsed_secs, frac);
break;
case TO_STR_TIME_RES_T_MSECS:
g_snprintf(buf, buflen, "%0.0f.%03d", elapsed_secs, frac);
snprintf(buf, buflen, "%0.0f.%03d", elapsed_secs, frac);
break;
case TO_STR_TIME_RES_T_USECS:
g_snprintf(buf, buflen, "%0.0f.%06d", elapsed_secs, frac);
snprintf(buf, buflen, "%0.0f.%06d", elapsed_secs, frac);
break;
case TO_STR_TIME_RES_T_NSECS:
g_snprintf(buf, buflen, "%0.0f.%09d", elapsed_secs, frac);
snprintf(buf, buflen, "%0.0f.%09d", elapsed_secs, frac);
break;
}
}

View File

@ -3702,7 +3702,7 @@ tvb_get_stringz_enc(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, g
* no more than bufsize number of bytes, including terminating NUL, to buffer.
* Returns length of string (not including terminating NUL), or -1 if the string was
* truncated in the buffer due to not having reached the terminating NUL.
* In this way, it acts like g_snprintf().
* In this way, it acts like snprintf().
*
* bufsize MUST be greater than 0.
*
@ -3788,7 +3788,7 @@ _tvb_get_nstringz(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8*
* no more than bufsize number of bytes, including terminating NUL, to buffer.
* Returns length of string (not including terminating NUL), or -1 if the string was
* truncated in the buffer due to not having reached the terminating NUL.
* In this way, it acts like g_snprintf().
* In this way, it acts like snprintf().
*
* When processing a packet where the remaining number of bytes is less
* than bufsize, an exception is not thrown if the end of the packet

View File

@ -773,7 +773,7 @@ WS_DLL_PUBLIC const guint8 *tvb_get_const_stringz(tvbuff_t *tvb,
* no more than bufsize number of bytes, including terminating NUL, to buffer.
* Returns length of string (not including terminating NUL), or -1 if the
* string was truncated in the buffer due to not having reached the terminating
* NUL. In this way, it acts like g_snprintf().
* NUL. In this way, it acts like snprintf().
*
* When processing a packet where the remaining number of bytes is less
* than bufsize, an exception is not thrown if the end of the packet

View File

@ -376,7 +376,7 @@ gboolean uat_save(uat_t* uat, char** error) {
/* Parent directory does not exist, try creating first */
gchar *pf_dir_path = NULL;
if (create_persconffile_dir(&pf_dir_path) != 0) {
*error = g_strdup_printf("uat_save: error creating '%s'", pf_dir_path);
*error = ws_strdup_printf("uat_save: error creating '%s'", pf_dir_path);
g_free (pf_dir_path);
return FALSE;
}
@ -384,7 +384,7 @@ gboolean uat_save(uat_t* uat, char** error) {
}
if (!fp) {
*error = g_strdup_printf("uat_save: error opening '%s': %s",fname,g_strerror(errno));
*error = ws_strdup_printf("uat_save: error opening '%s': %s",fname,g_strerror(errno));
return FALSE;
}
@ -734,7 +734,7 @@ gboolean uat_fld_chk_bool(void* u1 _U_, const char* strptr, guint len, const voi
return TRUE;
}
*err = g_strdup_printf("invalid value: %s (must be TRUE or FALSE)", str);
*err = ws_strdup_printf("invalid value: %s (must be TRUE or FALSE)", str);
g_free(str);
return FALSE;
}
@ -753,7 +753,7 @@ gboolean uat_fld_chk_enum(void* u1 _U_, const char* strptr, guint len, const voi
}
}
*err = g_strdup_printf("invalid value: %s",str);
*err = ws_strdup_printf("invalid value: %s",str);
g_free(str);
return FALSE;
}
@ -770,11 +770,11 @@ gboolean uat_fld_chk_range(void* u1 _U_, const char* strptr, guint len, const vo
ret_value = TRUE;
break;
case CVT_SYNTAX_ERROR:
*err = g_strdup_printf("syntax error in range: %s",str);
*err = ws_strdup_printf("syntax error in range: %s",str);
ret_value = FALSE;
break;
case CVT_NUMBER_TOO_BIG:
*err = g_strdup_printf("value too large in range: '%s' (max = %u)",str,GPOINTER_TO_UINT(u3));
*err = ws_strdup_printf("value too large in range: '%s' (max = %u)",str,GPOINTER_TO_UINT(u3));
ret_value = FALSE;
break;
default:
@ -919,7 +919,7 @@ char* uat_esc(const char* buf, guint len) {
for (b = (const guint8 *)buf; b < end; b++) {
if (*b == '"' || *b == '\\' || ! g_ascii_isprint(*b) ) {
g_snprintf(s,5,"\\x%02x",((guint)*b));
snprintf(s,5,"\\x%02x",((guint)*b));
s+=4;
} else {
*(s++) = (*b);
@ -936,7 +936,7 @@ gboolean uat_fld_chk_str_isprint(void* u1 _U_, const char* strptr, guint len, co
for (i = 0; i < len; i++) {
char c = strptr[i];
if (! g_ascii_isprint(c)) {
*err = g_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
*err = ws_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
return FALSE;
}
}
@ -950,7 +950,7 @@ gboolean uat_fld_chk_str_isalpha(void* u1 _U_, const char* strptr, guint len, co
for (i = 0; i < len; i++) {
char c = strptr[i];
if (! g_ascii_isalpha(c)) {
*err = g_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
*err = ws_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
return FALSE;
}
}
@ -964,7 +964,7 @@ gboolean uat_fld_chk_str_isalnum(void* u1 _U_, const char* strptr, guint len, co
for (i = 0; i < len; i++) {
char c = strptr[i];
if (! g_ascii_isalnum(c)) {
*err = g_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
*err = ws_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
return FALSE;
}
}
@ -978,7 +978,7 @@ gboolean uat_fld_chk_str_isdigit(void* u1 _U_, const char* strptr, guint len, co
for (i = 0; i < len; i++) {
char c = strptr[i];
if (! g_ascii_isdigit(c)) {
*err = g_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
*err = ws_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
return FALSE;
}
}
@ -992,7 +992,7 @@ gboolean uat_fld_chk_str_isxdigit(void* u1 _U_, const char* strptr, guint len, c
for (i = 0; i < len; i++) {
char c = strptr[i];
if (! g_ascii_isxdigit(c)) {
*err = g_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
*err = ws_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
return FALSE;
}
}

View File

@ -540,7 +540,7 @@ static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, g
ws_strtou32(tmp_str, NULL, &((rec_t*)rec)->field_name); \
g_free(tmp_str); } \
static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
*out_ptr = g_strdup_printf("%u",((rec_t*)rec)->field_name); \
*out_ptr = ws_strdup_printf("%u",((rec_t*)rec)->field_name); \
*out_len = (unsigned)strlen(*out_ptr); }
#define UAT_FLD_DEC(basename,field_name,title,desc) \
@ -555,7 +555,7 @@ static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, g
ws_strtou64(tmp_str, NULL, &((rec_t*)rec)->field_name); \
g_free(tmp_str); } \
static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
*out_ptr = g_strdup_printf("%" G_GINT64_MODIFIER "u",((rec_t*)rec)->field_name); \
*out_ptr = ws_strdup_printf("%" PRIu64,((rec_t*)rec)->field_name); \
*out_len = (unsigned)strlen(*out_ptr); }
#define UAT_FLD_DEC64(basename,field_name,title,desc) \
@ -570,7 +570,7 @@ static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, g
ws_strtoi32(tmp_str, NULL, &((rec_t*)rec)->field_name); \
g_free(tmp_str); } \
static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
*out_ptr = g_strdup_printf("%d",((rec_t*)rec)->field_name); \
*out_ptr = ws_strdup_printf("%d",((rec_t*)rec)->field_name); \
*out_len = (unsigned)strlen(*out_ptr); }
#define UAT_FLD_SIGNED_DEC(basename,field_name,title,desc) \
@ -585,7 +585,7 @@ static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, g
ws_strtoi64(tmp_str, NULL, &((rec_t*)rec)->field_name); \
g_free(tmp_str); } \
static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
*out_ptr = g_strdup_printf("%" G_GINT64_MODIFIER "d",((rec_t*)rec)->field_name); \
*out_ptr = ws_strdup_printf("%" PRId64,((rec_t*)rec)->field_name); \
*out_len = (unsigned)strlen(*out_ptr); }
#define UAT_FLD_SIGNED_DEC64(basename,field_name,title,desc) \
@ -605,7 +605,7 @@ static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, g
ws_hexstrtou32(tmp_str, NULL, &((rec_t*)rec)->field_name); \
g_free(tmp_str); } \
static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
*out_ptr = g_strdup_printf("%x",((rec_t*)rec)->field_name); \
*out_ptr = ws_strdup_printf("%x",((rec_t*)rec)->field_name); \
*out_len = (unsigned)strlen(*out_ptr); }
#define UAT_FLD_HEX(basename,field_name,title,desc) \
@ -621,7 +621,7 @@ static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, g
ws_hexstrtou64(tmp_str, NULL, &((rec_t*)rec)->field_name); \
g_free(tmp_str); } \
static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
*out_ptr = g_strdup_printf("%" G_GINT64_MODIFIER "x",((rec_t*)rec)->field_name); \
*out_ptr = ws_strdup_printf("%" PRIx64,((rec_t*)rec)->field_name); \
*out_len = (unsigned)strlen(*out_ptr); }
#define UAT_FLD_HEX64(basename,field_name,title,desc) \
@ -640,7 +640,7 @@ static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, g
((rec_t*)rec)->field_name = 0; \
g_free(tmp_str); } \
static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
*out_ptr = g_strdup_printf("%s",((rec_t*)rec)->field_name ? "TRUE" : "FALSE"); \
*out_ptr = ws_strdup_printf("%s",((rec_t*)rec)->field_name ? "TRUE" : "FALSE"); \
*out_len = (unsigned)strlen(*out_ptr); }
#define UAT_FLD_BOOL(basename,field_name,title,desc) \
@ -718,7 +718,7 @@ static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, g
((rec_t*)rec)->field_name = (guint)strtol(tmp_str,NULL,16); \
g_free(tmp_str); } \
static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
*out_ptr = g_strdup_printf("#%06X",((rec_t*)rec)->field_name); \
*out_ptr = ws_strdup_printf("#%06X",((rec_t*)rec)->field_name); \
*out_len = (unsigned)strlen(*out_ptr); }
#define UAT_FLD_COLOR(basename,field_name,title,desc) \

View File

@ -121,9 +121,9 @@ typedef struct {
* must also be freed.
*/
#define ERROR(fmtd) do { \
char* fmt_str = g_strdup_printf fmtd; \
char* fmt_str = ws_strdup_printf fmtd; \
g_free(yyextra->error); \
yyextra->error = g_strdup_printf("%s:%d: %s",yyextra->uat->filename,yyextra->linenum,fmt_str); \
yyextra->error = ws_strdup_printf("%s:%d: %s",yyextra->uat->filename,yyextra->linenum,fmt_str); \
g_free(fmt_str); \
if (yyextra->uat->free_cb) { \
yyextra->uat->free_cb(yyextra->record); \
@ -144,7 +144,7 @@ typedef struct {
if (yyextra->uat->fields[yyextra->colnum].cb.chk) { \
if ( ! yyextra->uat->fields[yyextra->colnum].cb.chk(yyextra->record, yyextra->ptrx, yyextra->len, yyextra->uat->fields[yyextra->colnum].cbdata.chk, yyextra->uat->fields[yyextra->colnum].fld_data, &errx) ) { \
g_free(yyextra->error); \
yyextra->error = g_strdup_printf("%s:%d: %s",yyextra->uat->filename,yyextra->linenum,errx); \
yyextra->error = ws_strdup_printf("%s:%d: %s",yyextra->uat->filename,yyextra->linenum,errx); \
g_free(errx); \
yyextra->valid_record = FALSE; \
}\
@ -476,7 +476,7 @@ uat_load_str(uat_t *uat, char *entry, char **err)
uat_load_scanner_state_t state;
state.uat = uat;
state.parse_str = g_strdup_printf("%s\n", entry); /* Records must end with a newline */
state.parse_str = ws_strdup_printf("%s\n", entry); /* Records must end with a newline */
state.error = NULL;
state.valid_record = TRUE;

View File

@ -742,14 +742,14 @@ _try_val64_to_str_ext_init(const guint64 val, val64_string_ext *vse)
if (type == VS_BIN_TREE) {
if (prev_value > vs_p[i].value) {
ws_warning("Extended value string '%s' forced to fall back to linear search:\n"
" entry %u, value %" G_GINT64_MODIFIER "u [%#" G_GINT64_MODIFIER "x] < previous entry, value %" G_GINT64_MODIFIER "u [%#" G_GINT64_MODIFIER "x]",
" entry %u, value %" PRIu64 " [%#" PRIx64 "] < previous entry, value %" PRIu64 " [%#" PRIx64 "]",
vse->_vs_name, i, vs_p[i].value, vs_p[i].value, prev_value, prev_value);
type = VS_SEARCH;
break;
}
if (first_value > vs_p[i].value) {
ws_warning("Extended value string '%s' forced to fall back to linear search:\n"
" entry %u, value %" G_GINT64_MODIFIER "u [%#" G_GINT64_MODIFIER "x] < first entry, value %" G_GINT64_MODIFIER "u [%#" G_GINT64_MODIFIER "x]",
" entry %u, value %" PRIu64 " [%#" PRIx64 "] < first entry, value %" PRIu64 " [%#" PRIx64 "]",
vse->_vs_name, i, vs_p[i].value, vs_p[i].value, first_value, first_value);
type = VS_SEARCH;
break;

View File

@ -462,7 +462,7 @@ static void wslua_clear_plugin_list(void)
}
static int lua_script_push_args(const int script_num) {
gchar* argname = g_strdup_printf("lua_script%d", script_num);
gchar* argname = ws_strdup_printf("lua_script%d", script_num);
const gchar* argvalue = NULL;
int i, count = ex_opt_count(argname);
@ -654,7 +654,7 @@ static int lua_load_plugins(const char *dirname, register_cb cb, gpointer client
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
continue; /* skip "." and ".." */
filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", dirname, name);
filename = ws_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", dirname, name);
if (test_for_directory(filename) == EISDIR) {
sorted_dirnames = g_list_prepend(sorted_dirnames, (gpointer)filename);
continue;

View File

@ -59,7 +59,7 @@ report_error(int *err, gchar **err_info, const char *fmt, ...)
gchar *msg;
va_start(ap, fmt);
msg = g_strdup_vprintf(fmt, ap);
msg = ws_strdup_vprintf(fmt, ap);
va_end(ap);
if (err != NULL) {
*err = WTAP_ERR_INTERNAL;
@ -224,7 +224,7 @@ wslua_filehandler_open(wtap *wth, int *err, gchar **err_info)
/* not a valid return type */
if (err) {
*err = WTAP_ERR_INTERNAL;
*err_info = g_strdup_printf("FileHandler read_open routine returned %d", retval);
*err_info = ws_strdup_printf("FileHandler read_open routine returned %d", retval);
}
retval = WTAP_OPEN_ERROR;
}

View File

@ -292,7 +292,7 @@ WSLUA_CONSTRUCTOR Int64_fromhex(lua_State* L) {
const gchar *s = luaL_checklstring(L,WSLUA_ARG_Int64_fromhex_HEX,&len);
if (len > 0) {
if (sscanf(s, "%" G_GINT64_MODIFIER "x", &result) != 1) {
if (sscanf(s, "%" PRIx64, &result) != 1) {
return luaL_error(L, "Error decoding the passed-in hex string");
}
}
@ -349,7 +349,7 @@ WSLUA_METAMETHOD Int64__tostring(lua_State* L) {
/* Converts the <<lua_class_Int64,`Int64`>> into a string of decimal digits. */
gint64 num = getInt64(L,1);
gchar s[LUATYPE64_STRING_SIZE];
if (g_snprintf(s, LUATYPE64_STRING_SIZE, "%" G_GINT64_MODIFIER "d", num) < 0) {
if (snprintf(s, LUATYPE64_STRING_SIZE, "%" PRId64, num) < 0) {
return luaL_error(L, "Error writing Int64 to a string");
}
lua_pushstring(L,s);
@ -835,7 +835,7 @@ WSLUA_METAMETHOD UInt64__tostring(lua_State* L) {
/* Converts the <<lua_class_UInt64,`UInt64`>> into a string. */
guint64 num = getUInt64(L,1);
gchar s[LUATYPE64_STRING_SIZE];
if (g_snprintf(s, LUATYPE64_STRING_SIZE, "%" G_GINT64_MODIFIER "u",(guint64)num) < 0) {
if (snprintf(s, LUATYPE64_STRING_SIZE, "%" PRIu64,(guint64)num) < 0) {
return luaL_error(L, "Error writing UInt64 to a string");
}
lua_pushstring(L,s);
@ -852,7 +852,7 @@ WSLUA_CONSTRUCTOR UInt64_fromhex(lua_State* L) {
const gchar *s = luaL_checklstring(L,WSLUA_ARG_UInt64_fromhex_HEX,&len);
if (len > 0) {
if (sscanf(s, "%" G_GINT64_MODIFIER "x", &result) != 1) {
if (sscanf(s, "%" PRIx64, &result) != 1) {
return luaL_error(L, "Error decoding the passed-in hex string");
}
}

View File

@ -1434,7 +1434,7 @@ PROTOFIELD_OTHER(eui64,FT_EUI64)
WSLUA_METAMETHOD ProtoField__tostring(lua_State* L) {
/* Returns a string with info about a protofield (for debugging purposes). */
ProtoField f = checkProtoField(L,1);
gchar* s = g_strdup_printf("ProtoField(%i): %s %s %s %s %p %.8x %s",
gchar* s = ws_strdup_printf("ProtoField(%i): %s %s %s %s %p %.8x %s",
f->hfid,f->name,f->abbrev,
ftenum_to_string(f->type),
base_to_string(f->base),

View File

@ -209,7 +209,7 @@ dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
}
if (is_extended) {
poll_final = (control & XDLC_P_F_EXT);
g_snprintf(info, 80, "S%s, func=%s, N(R)=%u",
snprintf(info, 80, "S%s, func=%s, N(R)=%u",
(poll_final ?
(is_response ? " F" : " P") :
""),
@ -217,7 +217,7 @@ dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
(control & XDLC_N_R_EXT_MASK) >> XDLC_N_R_EXT_SHIFT);
} else {
poll_final = (control & XDLC_P_F);
g_snprintf(info, 80, "S%s, func=%s, N(R)=%u",
snprintf(info, 80, "S%s, func=%s, N(R)=%u",
(poll_final ?
(is_response ? " F" : " P") :
""),
@ -277,7 +277,7 @@ dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
u_modifier_short_vals_cmd, "Unknown");
}
poll_final = (control & XDLC_P_F);
g_snprintf(info, 80, "U%s, func=%s",
snprintf(info, 80, "U%s, func=%s",
(poll_final ?
(is_response ? " F" : " P") :
""),
@ -318,7 +318,7 @@ dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
cf_items = cf_items_ext;
control_format = "Control field: %s (0x%04X)";
poll_final = (control & XDLC_P_F_EXT);
g_snprintf(info, 80, "I%s, N(R)=%u, N(S)=%u",
snprintf(info, 80, "I%s, N(R)=%u, N(S)=%u",
((control & XDLC_P_F_EXT) ? " P" : ""),
(control & XDLC_N_R_EXT_MASK) >> XDLC_N_R_EXT_SHIFT,
(control & XDLC_N_S_EXT_MASK) >> XDLC_N_S_EXT_SHIFT);
@ -328,7 +328,7 @@ dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
cf_items = cf_items_nonext;
control_format = "Control field: %s (0x%02X)";
poll_final = (control & XDLC_P_F);
g_snprintf(info, 80, "I%s, N(R)=%u, N(S)=%u",
snprintf(info, 80, "I%s, N(R)=%u, N(S)=%u",
((control & XDLC_P_F) ? " P" : ""),
(control & XDLC_N_R_MASK) >> XDLC_N_R_SHIFT,
(control & XDLC_N_S_MASK) >> XDLC_N_S_SHIFT);