Skip to content

Commit 9038ac0

Browse files
philmdMichael Tokarev
authored andcommitted
overall: Remove unnecessary g_strdup_printf() calls
Replace g_strdup_printf("%s", value) -> g_strdup(value) to avoid unnecessary string formatting. Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Reviewed-by: Michael Tokarev <[email protected]> Signed-off-by: Michael Tokarev <[email protected]>
1 parent ce31532 commit 9038ac0

File tree

8 files changed

+8
-11
lines changed

8 files changed

+8
-11
lines changed

crypto/hash-afalg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ qcrypto_afalg_hash_format_name(QCryptoHashAlgo alg,
5959
if (is_hmac) {
6060
name = g_strdup_printf("hmac(%s)", alg_name);
6161
} else {
62-
name = g_strdup_printf("%s", alg_name);
62+
name = g_strdup(alg_name);
6363
}
6464

6565
return name;

hw/ppc/spapr_caps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ void spapr_caps_add_properties(SpaprMachineClass *smc)
10341034
for (i = 0; i < ARRAY_SIZE(capability_table); i++) {
10351035
SpaprCapabilityInfo *cap = &capability_table[i];
10361036
g_autofree char *name = g_strdup_printf("cap-%s", cap->name);
1037-
g_autofree char *desc = g_strdup_printf("%s", cap->description);
1037+
g_autofree char *desc = g_strdup(cap->description);
10381038

10391039
object_class_property_add(klass, name, cap->type,
10401040
cap->get, cap->set,

plugins/loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static int plugin_add(void *opaque, const char *name, const char *value,
128128
/* Will treat arg="argname" as "argname=on" */
129129
fullarg = g_strdup_printf("%s=%s", value, "on");
130130
} else {
131-
fullarg = g_strdup_printf("%s", value);
131+
fullarg = g_strdup(value);
132132
}
133133
warn_report("using 'arg=%s' is deprecated", value);
134134
error_printf("Please use '%s' directly\n", fullarg);

target/i386/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6166,7 +6166,7 @@ static void x86_cpu_list_entry(gpointer data, gpointer user_data)
61666166
desc = g_strdup_printf("%s [%s]", model_id, cc->model->note);
61676167
}
61686168
if (!desc) {
6169-
desc = g_strdup_printf("%s", model_id);
6169+
desc = g_strdup(model_id);
61706170
}
61716171

61726172
if (cc->model && cc->model->cpudef->deprecation_note) {

trace/simple.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void st_set_trace_file(const char *file)
366366
/* Type cast needed for Windows where getpid() returns an int. */
367367
trace_file_name = g_strdup_printf(CONFIG_TRACE_FILE "-" FMT_pid, (pid_t)getpid());
368368
} else {
369-
trace_file_name = g_strdup_printf("%s", file);
369+
trace_file_name = g_strdup(file);
370370
}
371371

372372
st_set_trace_file_enabled(saved_enable);

ui/console.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,9 +1386,7 @@ char *qemu_console_get_label(QemuConsole *con)
13861386
object_get_typename(c->device),
13871387
c->head);
13881388
} else {
1389-
return g_strdup_printf("%s", dev->id ?
1390-
dev->id :
1391-
object_get_typename(c->device));
1389+
return g_strdup(dev->id ? : object_get_typename(c->device));
13921390
}
13931391
}
13941392
return g_strdup("VGA");

ui/gtk.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,8 +1944,7 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc,
19441944
vcd->console = vc;
19451945

19461946
snprintf(buffer, sizeof(buffer), "vc%d", idx);
1947-
vc->label = g_strdup_printf("%s", vc->vte.chr->label
1948-
? vc->vte.chr->label : buffer);
1947+
vc->label = g_strdup(vc->vte.chr->label ? : buffer);
19491948
group = gd_vc_menu_init(s, vc, idx, group, view_menu);
19501949

19511950
vc->vte.terminal = vte_terminal_new();

util/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ int module_load(const char *prefix, const char *name, Error **errp)
234234

235235
search_dir = getenv("QEMU_MODULE_DIR");
236236
if (search_dir != NULL) {
237-
dirs[n_dirs++] = g_strdup_printf("%s", search_dir);
237+
dirs[n_dirs++] = g_strdup(search_dir);
238238
}
239239
dirs[n_dirs++] = get_relocated_path(CONFIG_QEMU_MODDIR);
240240

0 commit comments

Comments
 (0)