diff mbox series

overall: Remove unnecessary g_strdup_printf() calls

Message ID 20250130105743.1355-1-philmd@linaro.org
State New
Headers show
Series overall: Remove unnecessary g_strdup_printf() calls | expand

Commit Message

Philippe Mathieu-Daudé Jan. 30, 2025, 10:57 a.m. UTC
Replace g_strdup_printf("%s", value) -> g_strdup(value)
to avoid unnecessary string formatting.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 crypto/hash-afalg.c | 2 +-
 hw/ppc/spapr_caps.c | 2 +-
 plugins/loader.c    | 2 +-
 target/i386/cpu.c   | 2 +-
 trace/simple.c      | 2 +-
 ui/console.c        | 4 +---
 ui/gtk.c            | 3 +--
 util/module.c       | 2 +-
 8 files changed, 8 insertions(+), 11 deletions(-)

Comments

Daniel P. Berrangé Jan. 30, 2025, 10:59 a.m. UTC | #1
On Thu, Jan 30, 2025 at 11:57:43AM +0100, Philippe Mathieu-Daudé wrote:
> Replace g_strdup_printf("%s", value) -> g_strdup(value)
> to avoid unnecessary string formatting.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  crypto/hash-afalg.c | 2 +-
>  hw/ppc/spapr_caps.c | 2 +-
>  plugins/loader.c    | 2 +-
>  target/i386/cpu.c   | 2 +-
>  trace/simple.c      | 2 +-
>  ui/console.c        | 4 +---
>  ui/gtk.c            | 3 +--
>  util/module.c       | 2 +-
>  8 files changed, 8 insertions(+), 11 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
Stefan Hajnoczi Jan. 30, 2025, 12:58 p.m. UTC | #2
On Thu, Jan 30, 2025 at 11:57:43AM +0100, Philippe Mathieu-Daudé wrote:
> Replace g_strdup_printf("%s", value) -> g_strdup(value)
> to avoid unnecessary string formatting.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  crypto/hash-afalg.c | 2 +-
>  hw/ppc/spapr_caps.c | 2 +-
>  plugins/loader.c    | 2 +-
>  target/i386/cpu.c   | 2 +-
>  trace/simple.c      | 2 +-
>  ui/console.c        | 4 +---
>  ui/gtk.c            | 3 +--
>  util/module.c       | 2 +-
>  8 files changed, 8 insertions(+), 11 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox series

Patch

diff --git a/crypto/hash-afalg.c b/crypto/hash-afalg.c
index 8c0ce5b5200..bd3fe3b4272 100644
--- a/crypto/hash-afalg.c
+++ b/crypto/hash-afalg.c
@@ -59,7 +59,7 @@  qcrypto_afalg_hash_format_name(QCryptoHashAlgo alg,
     if (is_hmac) {
         name = g_strdup_printf("hmac(%s)", alg_name);
     } else {
-        name = g_strdup_printf("%s", alg_name);
+        name = g_strdup(alg_name);
     }
 
     return name;
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index 7edd1383601..904bff87ce1 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -1034,7 +1034,7 @@  void spapr_caps_add_properties(SpaprMachineClass *smc)
     for (i = 0; i < ARRAY_SIZE(capability_table); i++) {
         SpaprCapabilityInfo *cap = &capability_table[i];
         g_autofree char *name = g_strdup_printf("cap-%s", cap->name);
-        g_autofree char *desc = g_strdup_printf("%s", cap->description);
+        g_autofree char *desc = g_strdup(cap->description);
 
         object_class_property_add(klass, name, cap->type,
                                   cap->get, cap->set,
diff --git a/plugins/loader.c b/plugins/loader.c
index ebc01da9c6e..99686b54666 100644
--- a/plugins/loader.c
+++ b/plugins/loader.c
@@ -128,7 +128,7 @@  static int plugin_add(void *opaque, const char *name, const char *value,
                 /* Will treat arg="argname" as "argname=on" */
                 fullarg = g_strdup_printf("%s=%s", value, "on");
             } else {
-                fullarg = g_strdup_printf("%s", value);
+                fullarg = g_strdup(value);
             }
             warn_report("using 'arg=%s' is deprecated", value);
             error_printf("Please use '%s' directly\n", fullarg);
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index b5dd60d2812..72ab147e851 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6166,7 +6166,7 @@  static void x86_cpu_list_entry(gpointer data, gpointer user_data)
         desc = g_strdup_printf("%s [%s]", model_id, cc->model->note);
     }
     if (!desc) {
-        desc = g_strdup_printf("%s", model_id);
+        desc = g_strdup(model_id);
     }
 
     if (cc->model && cc->model->cpudef->deprecation_note) {
diff --git a/trace/simple.c b/trace/simple.c
index 18af590cf7b..c0aba00cb7f 100644
--- a/trace/simple.c
+++ b/trace/simple.c
@@ -366,7 +366,7 @@  void st_set_trace_file(const char *file)
         /* Type cast needed for Windows where getpid() returns an int. */
         trace_file_name = g_strdup_printf(CONFIG_TRACE_FILE "-" FMT_pid, (pid_t)getpid());
     } else {
-        trace_file_name = g_strdup_printf("%s", file);
+        trace_file_name = g_strdup(file);
     }
 
     st_set_trace_file_enabled(saved_enable);
diff --git a/ui/console.c b/ui/console.c
index 914ed2cc76b..6456e8dd908 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1386,9 +1386,7 @@  char *qemu_console_get_label(QemuConsole *con)
                                        object_get_typename(c->device),
                                        c->head);
             } else {
-                return g_strdup_printf("%s", dev->id ?
-                                       dev->id :
-                                       object_get_typename(c->device));
+                return g_strdup(dev->id ? : object_get_typename(c->device));
             }
         }
         return g_strdup("VGA");
diff --git a/ui/gtk.c b/ui/gtk.c
index c0237431489..59bda83da65 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1944,8 +1944,7 @@  static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc,
     vcd->console = vc;
 
     snprintf(buffer, sizeof(buffer), "vc%d", idx);
-    vc->label = g_strdup_printf("%s", vc->vte.chr->label
-                                ? vc->vte.chr->label : buffer);
+    vc->label = g_strdup(vc->vte.chr->label ? : buffer);
     group = gd_vc_menu_init(s, vc, idx, group, view_menu);
 
     vc->vte.terminal = vte_terminal_new();
diff --git a/util/module.c b/util/module.c
index 3eb0f06df16..1aa2079d013 100644
--- a/util/module.c
+++ b/util/module.c
@@ -234,7 +234,7 @@  int module_load(const char *prefix, const char *name, Error **errp)
 
     search_dir = getenv("QEMU_MODULE_DIR");
     if (search_dir != NULL) {
-        dirs[n_dirs++] = g_strdup_printf("%s", search_dir);
+        dirs[n_dirs++] = g_strdup(search_dir);
     }
     dirs[n_dirs++] = get_relocated_path(CONFIG_QEMU_MODDIR);