]> git.proxmox.com Git - mirror_qemu.git/commitdiff
Drop superfluous conditionals around g_free()
authorMarkus Armbruster <armbru@redhat.com>
Fri, 23 Sep 2022 09:04:28 +0000 (11:04 +0200)
committerLaurent Vivier <laurent@vivier.eu>
Mon, 3 Oct 2022 22:10:11 +0000 (00:10 +0200)
There is no need to guard g_free(P) with if (P): g_free(NULL) is safe.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220923090428.93529-1-armbru@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
replay/replay.c
target/i386/kvm/kvm.c
target/i386/whpx/whpx-all.c

index 4c396bb3761b22ee2a838cb41e8807457823001f..9a0dc1cf4447a54d4941a09150c782fe5417a053 100644 (file)
@@ -366,10 +366,8 @@ void replay_finish(void)
         fclose(replay_file);
         replay_file = NULL;
     }
-    if (replay_filename) {
-        g_free(replay_filename);
-        replay_filename = NULL;
-    }
+    g_free(replay_filename);
+    replay_filename = NULL;
 
     g_free(replay_snapshot);
     replay_snapshot = NULL;
index a1fd1f53791df96bfab30e6764956a6fe02ee471..9603bf265af5f2aa955c85ead4d2d98899a7a120 100644 (file)
@@ -2176,15 +2176,11 @@ int kvm_arch_destroy_vcpu(CPUState *cs)
 
     g_free(env->xsave_buf);
 
-    if (cpu->kvm_msr_buf) {
-        g_free(cpu->kvm_msr_buf);
-        cpu->kvm_msr_buf = NULL;
-    }
+    g_free(cpu->kvm_msr_buf);
+    cpu->kvm_msr_buf = NULL;
 
-    if (env->nested_state) {
-        g_free(env->nested_state);
-        env->nested_state = NULL;
-    }
+    g_free(env->nested_state);
+    env->nested_state = NULL;
 
     qemu_del_vm_change_state_handler(cpu->vmsentry);
 
index b22a3314b415b440a98d7a4673faa1441f9fa198..8e4969edeb8f853aea81b5fbac40b95689dee3d3 100644 (file)
@@ -1225,14 +1225,12 @@ static void whpx_translate_cpu_breakpoints(
         }
     }
 
-    if (breakpoints->breakpoints) {
-        /*
-         * Free the previous breakpoint list. This can be optimized by keeping
-         * it as shadow buffer for the next computation instead of freeing
-         * it immediately.
-         */
-        g_free(breakpoints->breakpoints);
-    }
+    /*
+     * Free the previous breakpoint list. This can be optimized by keeping
+     * it as shadow buffer for the next computation instead of freeing
+     * it immediately.
+     */
+    g_free(breakpoints->breakpoints);
 
     breakpoints->breakpoints = new_breakpoints;
 }