*_stdup_printf -> strdup for "single string only" formatting.

Done for performance improvements.

This could probably be done in checkAPIs.pl, but this was just
a quick manual check with grepping.

Change-Id: I91ff102cb528bb00fa2f65489de53890e7e46f2d
Reviewed-on: https://code.wireshark.org/review/15751
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
This commit is contained in:
Michael Mann 2016-06-05 22:24:47 -04:00 committed by Jaap Keuter
parent 6333b98ea6
commit 57ef06e242
50 changed files with 106 additions and 114 deletions

View File

@ -1332,7 +1332,7 @@ sync_interface_set_80211_chan(const gchar *iface, const char *freq, const gchar
if (type)
opt = g_strdup_printf("%s,%s,%s,%s", freq, type, center_freq1, center_freq2);
else
opt = g_strdup_printf("%s", freq);
opt = g_strdup(freq);
if (!opt) {
*primary_msg = g_strdup("Out of mem.");

View File

@ -940,9 +940,9 @@ airpcap_get_if_string_number(airpcap_if_info_t* if_info)
if (a == 0)
{
if (g_ascii_strcasecmp(if_info->name,AIRPCAP_DEVICE_ANY_EXTRACT_STRING)!=0)
number = g_strdup_printf("??");
number = g_strdup("??");
else
number = g_strdup_printf(AIRPCAP_CHANNEL_ANY_NAME);
number = g_strdup(AIRPCAP_CHANNEL_ANY_NAME);
}
else
{

View File

@ -176,7 +176,7 @@ char* paramset_get_params_list(param_t* paramsets, const char* fmt) G_GNUC_PRINT
static echld_bool_t param_set_ ## Name (char* val , char** err _U_) { char* p; int temp = (int)strtol(val, &p, 10); if (p<=val) { *err = g_strdup("not an integer"); return FALSE; } else { param_ ## Name = temp; return TRUE; } }
#define PARAM_BOOL(Name, Default) static gboolean param_ ## Name = Default; \
static char* param_get_ ## Name (char** err _U_ ) { return g_strdup_printf("%s",param_ ## Name ? "TRUE" : "FALSE"); } \
static char* param_get_ ## Name (char** err _U_ ) { return g_strdup(param_ ## Name ? "TRUE" : "FALSE"); } \
static echld_bool_t param_set_ ## Name (char* val , char** err _U_) { param_ ## Name = (*val == 'T' || *val == 't') ? TRUE : FALSE; return TRUE;}
#define PARAM(Name,Desc) {#Name, param_get_ ## Name, param_set_ ## Name, Desc}

View File

@ -572,7 +572,7 @@ ldap_conv_info_t *ldap_info;
if(and_filter_string) {
proto_item_append_text(it, "%%s", and_filter_string);
Filter_string=wmem_strdup_printf(wmem_packet_scope(), "%%s",and_filter_string);
Filter_string=wmem_strdup(wmem_packet_scope(), and_filter_string);
}
and_filter_string=old_and_filter_string;
@ -596,7 +596,7 @@ ldap_conv_info_t *ldap_info;
%(DEFAULT_BODY)s
if(or_filter_string) {
proto_item_append_text(it, "%%s", or_filter_string);
Filter_string=wmem_strdup_printf(wmem_packet_scope(), "%%s",or_filter_string);
Filter_string=wmem_strdup(wmem_packet_scope(), or_filter_string);
}
or_filter_string=old_or_filter_string;

View File

@ -25,7 +25,7 @@
else if (actx->rose_ctx->d.code == 1)
descr = wmem_strdup_printf(wmem_packet_scope(), "ERR: %s", actx->rose_ctx->d.code_global);
} else {
descr = wmem_strdup_printf(wmem_packet_scope(), "ERR:");
descr = wmem_strdup(wmem_packet_scope(), "ERR:");
}
if (actx->rose_ctx->apdu_depth >= 0)

View File

@ -25,7 +25,7 @@
else if (actx->rose_ctx->d.code == 1)
descr = wmem_strdup_printf(wmem_packet_scope(), "INV: %s", actx->rose_ctx->d.code_global);
} else {
descr = wmem_strdup_printf(wmem_packet_scope(), "INV:");
descr = wmem_strdup(wmem_packet_scope(), "INV:");
}
if (actx->rose_ctx->apdu_depth >= 0)

View File

@ -26,7 +26,7 @@
else if (actx->rose_ctx->d.code == 1)
descr = wmem_strdup_printf(wmem_packet_scope(), "RES: %s", actx->rose_ctx->d.code_global);
} else {
descr = wmem_strdup_printf(wmem_packet_scope(), "RES:");
descr = wmem_strdup(wmem_packet_scope(), "RES:");
}
if (actx->rose_ctx->apdu_depth >= 0)

View File

@ -680,8 +680,7 @@ static gint dissect_options(proto_tree *tree, packet_info *pinfo,
set_address_tvb(&addr, AT_IPv4, 4, tvb, offset);
offset += 4;
str = wmem_strdup_printf(wmem_packet_scope(), "%s",
address_to_display(wmem_packet_scope(), &addr));
str = address_to_display(wmem_packet_scope(), &addr);
break;
case 0x0004:
@ -695,8 +694,7 @@ static gint dissect_options(proto_tree *tree, packet_info *pinfo,
set_address_tvb(&addr, AT_IPv6, 16, tvb, offset);
offset += 16;
str = wmem_strdup_printf(wmem_packet_scope(), "%s",
address_to_display(wmem_packet_scope(), &addr));
str = address_to_display(wmem_packet_scope(), &addr);
break;
default:
@ -1142,8 +1140,7 @@ static gint dissect_block(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb,
}
}
str = wmem_strdup_printf(wmem_packet_scope(), "%s",
address_to_display(wmem_packet_scope(), &addr));
str = address_to_display(wmem_packet_scope(), &addr);
break;
case 0x0002: /* IPv6 Record */
if (record_length < 17) {
@ -1168,8 +1165,7 @@ static gint dissect_block(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb,
}
}
str = wmem_strdup_printf(wmem_packet_scope(), "%s",
address_to_display(wmem_packet_scope(), &addr));
str = address_to_display(wmem_packet_scope(), &addr);
break;
default:

View File

@ -958,8 +958,8 @@ SpoolssSetPrinterData_q(tvbuff_t *tvb, int offset,
/* GetPrinterDataEx() stores the key/value in se_data */
if(!pinfo->fd->flags.visited){
if(!dcv->se_data){
dcv->se_data = wmem_strdup_printf(wmem_file_scope(),
"%s", value_name?value_name:"");
dcv->se_data = wmem_strdup(wmem_file_scope(),
value_name?value_name:"");
}
}
@ -2448,8 +2448,8 @@ SpoolssOpenPrinterEx_q(tvbuff_t *tvb, int offset,
/* OpenPrinterEx() stores the key/value in se_data */
if(!pinfo->fd->flags.visited){
if(!dcv->se_data){
dcv->se_data = wmem_strdup_printf(wmem_file_scope(),
"%s", name?name:"");
dcv->se_data = wmem_strdup(wmem_file_scope(),
name?name:"");
}
}

View File

@ -133,7 +133,7 @@ static gboolean uat_devicenet_record_update_cb(void* r, char** err) {
uat_devicenet_record_t* rec = (uat_devicenet_record_t *)r;
if (rec->mac_id > 63) {
*err = g_strdup_printf("MAC ID must be between 0-63");
*err = g_strdup("MAC ID must be between 0-63");
return FALSE;
}
return TRUE;

View File

@ -315,8 +315,7 @@ dissect_diameter_3gpp_imeisv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
item = proto_tree_add_item(tree, hf_diameter_3gpp_imeisv, tvb, offset, length, ENC_UTF_8 | ENC_NA);
PROTO_ITEM_SET_GENERATED(item);
diam_sub_dis->avp_str = wmem_strdup_printf(wmem_packet_scope(), "%s",
tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8 | ENC_NA));
diam_sub_dis->avp_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8 | ENC_NA);
}
return length;
@ -390,8 +389,7 @@ dissect_diameter_3gpp_af_application_identifier(tvbuff_t *tvb, packet_info *pinf
item = proto_tree_add_item(tree, hf_diameter_3gpp_af_application_identifier, tvb, offset, length, ENC_UTF_8 | ENC_NA);
PROTO_ITEM_SET_GENERATED(item);
diam_sub_dis->avp_str = wmem_strdup_printf(wmem_packet_scope(), "%s",
tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8 | ENC_NA));
diam_sub_dis->avp_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8 | ENC_NA);
}
return length;
@ -416,8 +414,7 @@ dissect_diameter_3gpp_af_charging_identifier(tvbuff_t *tvb, packet_info *pinfo _
item = proto_tree_add_item(tree, hf_diameter_3gpp_af_charging_identifier, tvb, offset, length, ENC_UTF_8 | ENC_NA);
PROTO_ITEM_SET_GENERATED(item);
diam_sub_dis->avp_str = wmem_strdup_printf(wmem_packet_scope(), "%s",
tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8 | ENC_NA));
diam_sub_dis->avp_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8 | ENC_NA);
}
return length;
@ -1012,8 +1009,7 @@ dissect_diameter_3gpp_charging_rule_name(tvbuff_t *tvb, packet_info *pinfo _U_,
item = proto_tree_add_item(tree, hf_diameter_3gpp_charging_rule_name, tvb, offset, length, ENC_UTF_8 | ENC_NA);
PROTO_ITEM_SET_GENERATED(item);
diam_sub_dis->avp_str = wmem_strdup_printf(wmem_packet_scope(), "%s",
tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8 | ENC_NA));
diam_sub_dis->avp_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8 | ENC_NA);
}
return length;

View File

@ -3365,30 +3365,30 @@ static void secmode_list_update_cb(void *r, const char **err)
size = (guint32)strlen(rec->domain);
if (!VALIDHEX(rec->domain[0]) && !dof_oid_create_internal(rec->domain, &size, NULL))
{
*err = wmem_strdup_printf(wmem_packet_scope(), "Invalid domain [must be valid OID].");
*err = wmem_strdup(wmem_packet_scope(), "Invalid domain [must be valid OID].");
return;
}
else if (!count_hex_bytes(rec->domain))
{
*err = wmem_strdup_printf(wmem_packet_scope(), "Invalid domain [must be valid OID].");
*err = wmem_strdup(wmem_packet_scope(), "Invalid domain [must be valid OID].");
return;
}
size = (guint32)strlen(rec->identity);
if (!VALIDHEX(rec->identity[0]) && !dof_oid_create_internal(rec->identity, &size, NULL))
{
*err = wmem_strdup_printf(wmem_packet_scope(), "Invalid identity [must be valid OID].");
*err = wmem_strdup(wmem_packet_scope(), "Invalid identity [must be valid OID].");
return;
}
else if (!count_hex_bytes(rec->identity))
{
*err = wmem_strdup_printf(wmem_packet_scope(), "Invalid identity [must be valid OID].");
*err = wmem_strdup(wmem_packet_scope(), "Invalid identity [must be valid OID].");
return;
}
if (count_hex_bytes(rec->kek) != 32)
{
*err = wmem_strdup_printf(wmem_packet_scope(), "Invalid KEK [must be 32 byte key].");
*err = wmem_strdup(wmem_packet_scope(), "Invalid KEK [must be 32 byte key].");
return;
}
}
@ -3455,7 +3455,7 @@ static void seckey_list_update_cb(void *r, const char **err)
*err = NULL;
if (count_hex_bytes(rec->key) != 32)
{
*err = wmem_strdup_printf(wmem_packet_scope(), "Invalid secret [must be 32 bytes].");
*err = wmem_strdup(wmem_packet_scope(), "Invalid secret [must be 32 bytes].");
return;
}
}
@ -3507,13 +3507,13 @@ static void identsecret_list_update_cb(void *r, const char **err)
{
if (dof_oid_create_internal(rec->domain, &size, NULL))
{
*err = wmem_strdup_printf(wmem_packet_scope(), "Invalid domain [must be valid OID].");
*err = wmem_strdup(wmem_packet_scope(), "Invalid domain [must be valid OID].");
return;
}
}
else if (!count_hex_bytes(rec->domain))
{
*err = wmem_strdup_printf(wmem_packet_scope(), "Invalid domain [must be valid OID].");
*err = wmem_strdup(wmem_packet_scope(), "Invalid domain [must be valid OID].");
return;
}
@ -3522,19 +3522,19 @@ static void identsecret_list_update_cb(void *r, const char **err)
{
if (dof_oid_create_internal(rec->identity, &size, NULL))
{
*err = wmem_strdup_printf(wmem_packet_scope(), "Invalid identity [must be valid OID].");
*err = wmem_strdup(wmem_packet_scope(), "Invalid identity [must be valid OID].");
return;
}
}
else if (!count_hex_bytes(rec->identity))
{
*err = wmem_strdup_printf(wmem_packet_scope(), "Invalid identity [must be valid OID].");
*err = wmem_strdup(wmem_packet_scope(), "Invalid identity [must be valid OID].");
return;
}
if (count_hex_bytes(rec->secret) != 32)
{
*err = wmem_strdup_printf(wmem_packet_scope(), "Invalid secret [must be 32 byte key].");
*err = wmem_strdup(wmem_packet_scope(), "Invalid secret [must be 32 byte key].");
return;
}
}
@ -3719,7 +3719,7 @@ static gboolean identsecret_chk_cb(void *r _U_, const char *p _U_, unsigned len
if (!num_protos)
{
*err = wmem_strdup_printf(wmem_packet_scope(), "No protocols given");
*err = wmem_strdup(wmem_packet_scope(), "No protocols given");
return FALSE;
}

View File

@ -1556,7 +1556,7 @@ static gboolean
dtlsdecrypt_uat_fld_protocol_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
{
if (!p || strlen(p) == 0u) {
*err = g_strdup_printf("No protocol given.");
*err = g_strdup("No protocol given.");
return FALSE;
}

View File

@ -235,7 +235,7 @@ dissect_h450_ros_Invoke(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_,
else if (actx->rose_ctx->d.code == 1)
descr = wmem_strdup_printf(wmem_packet_scope(), "INV: %s", actx->rose_ctx->d.code_global);
} else {
descr = wmem_strdup_printf(wmem_packet_scope(), "INV:");
descr = wmem_strdup(wmem_packet_scope(), "INV:");
}
if (actx->rose_ctx->apdu_depth >= 0)
@ -318,7 +318,7 @@ dissect_h450_ros_ReturnResult(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *act
else if (actx->rose_ctx->d.code == 1)
descr = wmem_strdup_printf(wmem_packet_scope(), "RES: %s", actx->rose_ctx->d.code_global);
} else {
descr = wmem_strdup_printf(wmem_packet_scope(), "RES:");
descr = wmem_strdup(wmem_packet_scope(), "RES:");
}
if (actx->rose_ctx->apdu_depth >= 0)
@ -388,7 +388,7 @@ dissect_h450_ros_ReturnError(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx
else if (actx->rose_ctx->d.code == 1)
descr = wmem_strdup_printf(wmem_packet_scope(), "ERR: %s", actx->rose_ctx->d.code_global);
} else {
descr = wmem_strdup_printf(wmem_packet_scope(), "ERR:");
descr = wmem_strdup(wmem_packet_scope(), "ERR:");
}
if (actx->rose_ctx->apdu_depth >= 0)

View File

@ -5309,7 +5309,7 @@ static gboolean ikev1_uat_data_update_cb(void* p, char** err) {
}
if (ud->key_len == 0) {
*err = g_strdup_printf("Must have Encryption key.");
*err = g_strdup("Must have Encryption key.");
return FALSE;
}

View File

@ -375,7 +375,7 @@ protos_chk_cb(void* r _U_, const char* p, guint len, const void* u1 _U_, const v
g_strstrip(protos[num_protos]);
if (!num_protos) {
*err = g_strdup_printf("No protocols given");
*err = g_strdup("No protocols given");
wmem_free(NULL, line);
wmem_free(NULL, protos);
return FALSE;

View File

@ -159,7 +159,7 @@ static gboolean lbmpdm_tcp_tag_update_cb(void * record, char * * error_string)
if (tag->name == NULL)
{
*error_string = g_strdup_printf("Tag name can't be empty");
*error_string = g_strdup("Tag name can't be empty");
return FALSE;
}
else
@ -167,7 +167,7 @@ static gboolean lbmpdm_tcp_tag_update_cb(void * record, char * * error_string)
g_strstrip(tag->name);
if (tag->name[0] == 0)
{
*error_string = g_strdup_printf("Tag name can't be empty");
*error_string = g_strdup("Tag name can't be empty");
return FALSE;
}
}

View File

@ -1967,7 +1967,7 @@ static gboolean lbmr_tag_update_cb(void * record, char * * error_string)
if (tag->name == NULL)
{
*error_string = g_strdup_printf("Tag name can't be empty");
*error_string = g_strdup("Tag name can't be empty");
return FALSE;
}
else
@ -1975,7 +1975,7 @@ static gboolean lbmr_tag_update_cb(void * record, char * * error_string)
g_strstrip(tag->name);
if (tag->name[0] == 0)
{
*error_string = g_strdup_printf("Tag name can't be empty");
*error_string = g_strdup("Tag name can't be empty");
return FALSE;
}
}

View File

@ -652,7 +652,7 @@ static gboolean lbtrm_tag_update_cb(void * record, char * * error_string)
if (tag->name == NULL)
{
*error_string = g_strdup_printf("Tag name can't be empty");
*error_string = g_strdup("Tag name can't be empty");
return FALSE;
}
else
@ -660,7 +660,7 @@ static gboolean lbtrm_tag_update_cb(void * record, char * * error_string)
g_strstrip(tag->name);
if (tag->name[0] == 0)
{
*error_string = g_strdup_printf("Tag name can't be empty");
*error_string = g_strdup("Tag name can't be empty");
return FALSE;
}
}

View File

@ -701,7 +701,7 @@ static gboolean lbtru_tag_update_cb(void * record, char * * error_string)
if (tag->name == NULL)
{
*error_string = g_strdup_printf("Tag name can't be empty");
*error_string = g_strdup("Tag name can't be empty");
return FALSE;
}
else
@ -709,7 +709,7 @@ static gboolean lbtru_tag_update_cb(void * record, char * * error_string)
g_strstrip(tag->name);
if (tag->name[0] == 0)
{
*error_string = g_strdup_printf("Tag name can't be empty");
*error_string = g_strdup("Tag name can't be empty");
return FALSE;
}
}

View File

@ -332,7 +332,7 @@ static gboolean lbttcp_tag_update_cb(void * record, char * * error_string)
if (tag->name == NULL)
{
*error_string = g_strdup_printf("Tag name can't be empty");
*error_string = g_strdup("Tag name can't be empty");
return FALSE;
}
else
@ -340,7 +340,7 @@ static gboolean lbttcp_tag_update_cb(void * record, char * * error_string)
g_strstrip(tag->name);
if (tag->name[0] == 0)
{
*error_string = g_strdup_printf("Tag name can't be empty");
*error_string = g_strdup("Tag name can't be empty");
return FALSE;
}
}

View File

@ -1900,7 +1900,7 @@ dissect_ldap_T_and(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_,
if(and_filter_string) {
proto_item_append_text(it, "%s", and_filter_string);
Filter_string=wmem_strdup_printf(wmem_packet_scope(), "%s",and_filter_string);
Filter_string=wmem_strdup(wmem_packet_scope(), and_filter_string);
}
and_filter_string=old_and_filter_string;
@ -1948,7 +1948,7 @@ dissect_ldap_T_or(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_,
if(or_filter_string) {
proto_item_append_text(it, "%s", or_filter_string);
Filter_string=wmem_strdup_printf(wmem_packet_scope(), "%s",or_filter_string);
Filter_string=wmem_strdup(wmem_packet_scope(), or_filter_string);
}
or_filter_string=old_or_filter_string;

View File

@ -296,7 +296,7 @@ dissect_q932_ros_Invoke(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset
else if (actx->rose_ctx->d.code == 1)
descr = wmem_strdup_printf(wmem_packet_scope(), "INV: %s", actx->rose_ctx->d.code_global);
} else {
descr = wmem_strdup_printf(wmem_packet_scope(), "INV:");
descr = wmem_strdup(wmem_packet_scope(), "INV:");
}
if (actx->rose_ctx->apdu_depth >= 0)
@ -389,7 +389,7 @@ dissect_q932_ros_ReturnResult(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int
else if (actx->rose_ctx->d.code == 1)
descr = wmem_strdup_printf(wmem_packet_scope(), "RES: %s", actx->rose_ctx->d.code_global);
} else {
descr = wmem_strdup_printf(wmem_packet_scope(), "RES:");
descr = wmem_strdup(wmem_packet_scope(), "RES:");
}
if (actx->rose_ctx->apdu_depth >= 0)
@ -469,7 +469,7 @@ dissect_q932_ros_ReturnError(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o
else if (actx->rose_ctx->d.code == 1)
descr = wmem_strdup_printf(wmem_packet_scope(), "ERR: %s", actx->rose_ctx->d.code_global);
} else {
descr = wmem_strdup_printf(wmem_packet_scope(), "ERR:");
descr = wmem_strdup(wmem_packet_scope(), "ERR:");
}
if (actx->rose_ctx->apdu_depth >= 0)

View File

@ -435,7 +435,7 @@ rpcstat_param(register_srt_t* srt, const char* opt_arg, char** err)
}
else
{
*err = g_strdup_printf("<program>,<version>[,<filter>]");
*err = g_strdup("<program>,<version>[,<filter>]");
}
return pos;

View File

@ -1062,7 +1062,7 @@ scsistat_param(register_srt_t* srt, const char* opt_arg, char** err)
}
else
{
*err = g_strdup_printf("<cmdset>[,<filter>]");
*err = g_strdup("<cmdset>[,<filter>]");
}
return pos;

View File

@ -4916,7 +4916,7 @@ gboolean
ssldecrypt_uat_fld_ip_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
{
if (!p || strlen(p) == 0u) {
*err = g_strdup_printf("No IP address given.");
*err = g_strdup("No IP address given.");
return FALSE;
}
@ -4928,14 +4928,14 @@ gboolean
ssldecrypt_uat_fld_port_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
{
if (!p || strlen(p) == 0u) {
*err = g_strdup_printf("No Port given.");
*err = g_strdup("No Port given.");
return FALSE;
}
if (strcmp(p, "start_tls") != 0){
const gint i = atoi(p);
if (i < 0 || i > 65535) {
*err = g_strdup_printf("Invalid port given.");
*err = g_strdup("Invalid port given.");
return FALSE;
}
}
@ -4950,7 +4950,7 @@ ssldecrypt_uat_fld_fileopen_chk_cb(void* r _U_, const char* p, guint len _U_, co
ws_statb64 st;
if (!p || strlen(p) == 0u) {
*err = g_strdup_printf("No filename given.");
*err = g_strdup("No filename given.");
return FALSE;
} else {
if (ws_stat64(p, &st) != 0) {

View File

@ -3649,7 +3649,7 @@ static gboolean
ssldecrypt_uat_fld_protocol_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
{
if (!p || strlen(p) == 0u) {
*err = g_strdup_printf("No protocol given.");
*err = g_strdup("No protocol given.");
return FALSE;
}

View File

@ -610,7 +610,7 @@ uat_key_record_update_cb(void *r, char **err)
uat_key_record_t *rec = (uat_key_record_t *)r;
if (rec->string == NULL) {
*err = g_strdup_printf("Key can't be blank.");
*err = g_strdup("Key can't be blank.");
return FALSE;
} else {
g_strstrip(rec->string);
@ -622,7 +622,7 @@ uat_key_record_update_cb(void *r, char **err)
return FALSE;
}
} else {
*err = g_strdup_printf("Key can't be blank.");
*err = g_strdup("Key can't be blank.");
return FALSE;
}
}

View File

@ -524,7 +524,7 @@ dissect_zbee_nwk_full(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
if ( (packet.dst == ZBEE_BCAST_ALL)
|| (packet.dst == ZBEE_BCAST_ACTIVE)
|| (packet.dst == ZBEE_BCAST_ROUTERS)){
dst_addr = wmem_strdup_printf(pinfo->pool, "Broadcast");
dst_addr = wmem_strdup(pinfo->pool, "Broadcast");
}
else {
dst_addr = wmem_strdup_printf(pinfo->pool, "0x%04x", packet.dst);
@ -549,7 +549,7 @@ dissect_zbee_nwk_full(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
|| (packet.src == ZBEE_BCAST_ACTIVE)
|| (packet.src == ZBEE_BCAST_ROUTERS)){
/* Source Broadcast doesn't make much sense. */
src_addr = wmem_strdup_printf(pinfo->pool, "Unexpected Source Broadcast");
src_addr = wmem_strdup(pinfo->pool, "Unexpected Source Broadcast");
unicast_src = FALSE;
}
else {

View File

@ -4829,7 +4829,7 @@ prefs_pref_to_str(pref_t *pref, pref_source_t source) {
}
case PREF_BOOL:
return g_strdup_printf("%s", (*(gboolean *) valp) ? "TRUE" : "FALSE");
return g_strdup((*(gboolean *) valp) ? "TRUE" : "FALSE");
case PREF_ENUM:
{

View File

@ -40,12 +40,12 @@ ssh_session create_ssh_connection(const char* hostname, const unsigned int port,
/* Open session and set options */
sshs = ssh_new();
if (sshs == NULL) {
*err_info = g_strdup_printf("Can't create ssh session");
*err_info = g_strdup("Can't create ssh session");
return NULL;
}
if (!hostname) {
*err_info = g_strdup_printf("Hostname needed");
*err_info = g_strdup("Hostname needed");
goto failure;
}

View File

@ -1338,7 +1338,7 @@ insert_new_rows(GList *list)
* used.
*/
if (data_link_info->description != NULL) {
str = g_strdup_printf("%s", data_link_info->description);
str = g_strdup(data_link_info->description);
linkr->dlt = data_link_info->dlt;
} else {
str = g_strdup_printf("%s (not supported)", data_link_info->name);
@ -3369,7 +3369,7 @@ static void change_pipe_name_cb(gpointer dialog _U_, gint btn, gpointer data)
g_free(device.name);
g_free(device.display_name);
device.name = g_strdup((gchar *)data);
device.display_name = g_strdup_printf("%s", device.name);
device.display_name = g_strdup(device.name);
g_array_remove_index(global_capture_opts.all_ifaces, i);
g_array_insert_val(global_capture_opts.all_ifaces, i, device);
temp = g_strdup_printf("<b>%s</b>", device.display_name);
@ -3479,7 +3479,7 @@ add_pipe_cb(gpointer w _U_)
pipe_name = g_strdup(g_save_file);
memset(&device, 0, sizeof(device));
device.name = g_strdup(g_save_file);
device.display_name = g_strdup_printf("%s", device.name);
device.display_name = g_strdup(device.name);
device.hidden = FALSE;
device.selected = TRUE;
device.type = IF_PIPE;

View File

@ -45,20 +45,20 @@ apply_selected_filter (guint callback_action, const char *filter)
switch(type){
case ACTYPE_SELECTED:
str = g_strdup_printf("%s", filter);
str = g_strdup(filter);
break;
case ACTYPE_NOT_SELECTED:
str = g_strdup_printf("!(%s)", filter);
break;
case ACTYPE_AND_SELECTED:
if ((!current_filter) || (0 == strlen(current_filter)))
str = g_strdup_printf("%s", filter);
str = g_strdup(filter);
else
str = g_strdup_printf("(%s) && (%s)", current_filter, filter);
break;
case ACTYPE_OR_SELECTED:
if ((!current_filter) || (0 == strlen(current_filter)))
str = g_strdup_printf("%s", filter);
str = g_strdup(filter);
else
str = g_strdup_printf("(%s) || (%s)", current_filter, filter);
break;

View File

@ -543,13 +543,13 @@ get_ip_address_list_from_packet_list_row(gpointer data)
/* First check selected column */
if (is_address_column (column)) {
addr_list = g_list_append (addr_list, g_strdup_printf("%s", cfile.cinfo.col_expr.col_expr_val[column]));
addr_list = g_list_append (addr_list, g_strdup(cfile.cinfo.col_expr.col_expr_val[column]));
}
for (col = 0; col < cfile.cinfo.num_cols; col++) {
/* Then check all columns except the selected */
if ((col != column) && (is_address_column (col))) {
addr_list = g_list_append (addr_list, g_strdup_printf("%s", cfile.cinfo.col_expr.col_expr_val[col]));
addr_list = g_list_append (addr_list, g_strdup(cfile.cinfo.col_expr.col_expr_val[col]));
}
}

View File

@ -190,7 +190,7 @@ column_prefs_show(GtkWidget *prefs_window) {
cfmt->custom_fields = NULL;
cfmt->custom_occurrence = 0;
}
fmt = g_strdup_printf("%s", col_format_desc(cfmt->fmt));
fmt = g_strdup(col_format_desc(cfmt->fmt));
}
gtk_list_store_insert_with_values(store, &iter, G_MAXINT,
VISIBLE_COLUMN, cfmt->visible,
@ -561,7 +561,7 @@ column_menu_changed_cb(GtkWidget *w, gpointer data) {
/* Changing from custom to non-custom */
gtk_editable_delete_text(GTK_EDITABLE(field_te), 0, -1);
gtk_editable_delete_text(GTK_EDITABLE(occurrence_te), 0, -1);
fmt = g_strdup_printf("%s", col_format_desc(cur_cb_fmt));
fmt = g_strdup(col_format_desc(cur_cb_fmt));
gtk_widget_set_sensitive(field_lb, FALSE);
gtk_widget_set_sensitive(field_te, FALSE);
gtk_widget_set_sensitive(occurrence_lb, FALSE);
@ -588,7 +588,7 @@ column_menu_changed_cb(GtkWidget *w, gpointer data) {
} else {
/* Changing from non-custom to non-custom */
fmt = g_strdup_printf("%s", col_format_desc(cur_cb_fmt));
fmt = g_strdup(col_format_desc(cur_cb_fmt));
}
g_signal_handler_unblock(occurrence_te, column_occurrence_changed_handler_id);
g_signal_handler_unblock(field_te, column_field_changed_handler_id);

View File

@ -84,7 +84,7 @@ proto_hier_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data _U_, g
gtk_tree_model_get (model, &iter, FILTER_NAME, &filter, -1);
if (filter && strlen(filter) > 0) {
str = g_strdup_printf("%s", filter);
str = g_strdup(filter);
} else {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not acquire information to build a filter!\nTry expanding or choosing another item.");
return;
@ -92,7 +92,7 @@ proto_hier_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data _U_, g
while (gtk_tree_path_up(path) && gtk_tree_path_get_depth(path) > 0)
{
strtmp = g_strdup_printf("%s", str);
strtmp = g_strdup(str);
g_free(str);
gtk_tree_model_get_iter(model, &iter, path);

View File

@ -548,7 +548,7 @@ sctp_set_filter(GtkButton *button _U_, struct sctp_analyse *u_data)
dstlist = g_list_next(dstlist);
wmem_free(NULL, addr_str);
}
str = g_strdup_printf(")))");
str = g_strdup(")))");
g_string_append(gstring, str);
filter_string = g_string_free(gstring, FALSE);
}

View File

@ -536,7 +536,7 @@ sctp_stat_on_filter(GtkButton *button _U_, gpointer user_data _U_)
wmem_free(NULL, addr_str);
dstlist = g_list_next(dstlist);
}
str = g_strdup_printf(")))");
str = g_strdup(")))");
g_string_append(gstring, str);
filter_string = g_string_free(gstring,FALSE);
}

View File

@ -456,7 +456,7 @@ init_gtk_tree(const char* opt_arg, void *userdata _U_)
title=g_strdup_printf("%s with filter: %s",st->display_name,st->filter);
} else {
st->filter=NULL;
title=g_strdup_printf("%s", st->display_name);
title=g_strdup(st->display_name);
}
gtk_window_set_title(GTK_WINDOW(st->pr->win), title);
@ -585,7 +585,7 @@ void gtk_stats_tree_cb(GtkAction *action, gpointer user_data _U_)
if(abbr){
abbr = abbr+1;
}else{
abbr = g_strdup_printf("%s",action_name);
abbr = g_strdup(action_name);
}
cfg = stats_tree_get_cfg_by_abbr(abbr);
if(cfg){

View File

@ -250,7 +250,7 @@ scan_local_interfaces(void (*update_cb)(void))
link = (link_row *)g_malloc(sizeof(link_row));
if (data_link_info->description != NULL) {
link->dlt = data_link_info->dlt;
link->name = g_strdup_printf("%s", data_link_info->description);
link->name = g_strdup(data_link_info->description);
} else {
link->dlt = -1;
link->name = g_strdup_printf("%s (not supported)", data_link_info->name);
@ -326,7 +326,7 @@ scan_local_interfaces(void (*update_cb)(void))
device.name = g_strdup(interface_opts.name);
device.display_name = interface_opts.descr ?
g_strdup_printf("%s: %s", device.name, interface_opts.descr) :
g_strdup_printf("%s", device.name);
g_strdup(device.name);
device.hidden = FALSE;
device.selected = TRUE;
device.type = IF_PIPE;

View File

@ -608,7 +608,7 @@ void ManageInterfacesDialog::addRemoteInterfaces(GList* rlist, remote_options *r
* used.
*/
if (data_link_info->description != NULL) {
str = g_strdup_printf("%s", data_link_info->description);
str = g_strdup(data_link_info->description);
linkr->dlt = data_link_info->dlt;
} else {
str = g_strdup_printf("%s (not supported)", data_link_info->name);

View File

@ -120,18 +120,18 @@ wtap_open_return_val btsnoop_open(wtap *wth, int *err, gchar **err_info)
break;
case KHciLoggerDatalinkTypeBCSP:
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("btsnoop: BCSP capture logs unsupported");
*err_info = g_strdup("btsnoop: BCSP capture logs unsupported");
return WTAP_OPEN_ERROR;
case KHciLoggerDatalinkTypeH5:
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("btsnoop: H5 capture logs unsupported");
*err_info = g_strdup("btsnoop: H5 capture logs unsupported");
return WTAP_OPEN_ERROR;
case KHciLoggerDatalinkLinuxMonitor:
file_encap=WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR;
break;
case KHciLoggerDatalinkBlueZ5Simulator:
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("btsnoop: BlueZ 5 Simulator capture logs unsupported");
*err_info = g_strdup("btsnoop: BlueZ 5 Simulator capture logs unsupported");
return WTAP_OPEN_ERROR;
default:
*err = WTAP_ERR_UNSUPPORTED;

View File

@ -226,7 +226,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
{
/* If not got any data return error */
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("dct3trace: record without data");
*err_info = g_strdup("dct3trace: record without data");
return FALSE;
}
}
@ -338,7 +338,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
baddata:
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("dct3trace: record missing mandatory attributes");
*err_info = g_strdup("dct3trace: record missing mandatory attributes");
return FALSE;
}

View File

@ -520,7 +520,7 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
/* If this isn't a pad record, it's a corrupt packet; bail out */
if ((erf_header->type & 0x7F) != ERF_TYPE_PAD) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("erf: File has 0 byte packet");
*err_info = g_strdup("erf: File has 0 byte packet");
return FALSE;
}

View File

@ -746,7 +746,7 @@ netmon_process_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
*/
if (!filetime_to_nstime(&phdr->ts, d)) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("netmon: time stamp outside supported range");
*err_info = g_strdup("netmon: time stamp outside supported range");
return FAILURE;
}
}

View File

@ -597,7 +597,7 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
if (type != REC_VERS) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("ngsniffer: Sniffer file doesn't start with a version record");
*err_info = g_strdup("ngsniffer: Sniffer file doesn't start with a version record");
return WTAP_OPEN_ERROR;
}
@ -892,7 +892,7 @@ process_rec_header2_v2(wtap *wth, unsigned char *buffer, guint16 length,
* There's not enough data to compare.
*/
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("ngsniffer: WAN capture has too-short protocol list");
*err_info = g_strdup("ngsniffer: WAN capture has too-short protocol list");
return -1;
}

View File

@ -1738,7 +1738,7 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap,
case WTAP_ENCAP_NFC_LLCP:
if (check_packet_size && packet_size < LLCP_HEADER_LEN) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("pcap: libpcap llcp file too short");
*err_info = g_strdup("pcap: libpcap llcp file too short");
return -1;
}
if (!pcap_read_llcp_pseudoheader(fh, &phdr->pseudo_header, err, err_info))

View File

@ -562,7 +562,7 @@ pcapng_read_section_header_block(FILE_T fh, pcapng_block_header_t *bh,
/* We currently only suport one SHB */
if (pn->shb_read == TRUE) {
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("pcapng_read_section_header_block: multiple section header blocks not supported");
*err_info = g_strdup("pcapng_read_section_header_block: multiple section header blocks not supported");
return PCAPNG_BLOCK_ERROR;
}
@ -1407,7 +1407,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
if (0 >= pn->interfaces->len) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("pcapng_read_simple_packet_block: SPB appeared before any IDBs");
*err_info = g_strdup("pcapng_read_simple_packet_block: SPB appeared before any IDBs");
return FALSE;
}
iface_info = g_array_index(pn->interfaces, interface_info_t, 0);
@ -2584,7 +2584,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
wth->phdr.pkt_encap = WTAP_ENCAP_UNKNOWN;
wth->phdr.pkt_tsprec = WTAP_TSPREC_UNKNOWN;
*err = WTAP_ERR_UNSUPPORTED;
*err_info = g_strdup_printf("pcapng: multi-section files not currently supported");
*err_info = g_strdup("pcapng: multi-section files not currently supported");
return FALSE;
case(BLOCK_TYPE_PB):

View File

@ -734,7 +734,7 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
t = (((guint64) timestamp.upper) << 32) + timestamp.lower;
if (!nsfiletime_to_nstime(&phdr->ts, t)) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("peektagged: time stamp outside supported range");
*err_info = g_strdup("peektagged: time stamp outside supported range");
return -1;
}

View File

@ -371,7 +371,7 @@ parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gch
/* We will need to add code to handle new format */
if (num_items_scanned != 8) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("vms: header line not valid");
*err_info = g_strdup("vms: header line not valid");
return FALSE;
}
}
@ -382,7 +382,7 @@ parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gch
if ( !*p ) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("vms: Length field not valid");
*err_info = g_strdup("vms: Length field not valid");
return FALSE;
}
@ -446,7 +446,7 @@ parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gch
if (!parse_single_hex_dump_line(line, pd, i,
offset, pkt_len - i)) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("vms: hex dump not valid");
*err_info = g_strdup("vms: hex dump not valid");
return FALSE;
}
}