From nobody Wed Apr 24 22:14:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1663924336; cv=none; d=zohomail.com; s=zohoarc; b=az9ZF8j0s/zExxg3c7qGFaU7LtCz4/jTeNN5jQupxfBsQgd0jxBr6OcBou9pgqz4thit8Wn03NOw1Q4wEX483zhF6A1uy6VrnHPuX4SqiWj90DF3zZ/7njaNoUEr3wF62LV2D+iTYgbPaWgd4l7mhhdoNC+JFlUuGMX/Aa5i1cY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663924336; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=1gpuiKCs1ELi0jnftapN38Fc+t+M2ss2J/W/XR1Ol3g=; b=LkB+7nm5+k1y+TaFbKEEtwa3W2aE6+RNVQxT37wFhpG4uCb77SXQSki1CnhIkQXq72T4c729cQt5Up0y35E2ygaP4u/W+jh9q5+rQ5gl5MaaY7VInMnFZq5qX2gFBivuIfiz8dVXlJZWi5SsvMThNhYA2qhFo1D6dIU7nd2dy3w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1663924336688607.6237477334801; Fri, 23 Sep 2022 02:12:16 -0700 (PDT) Received: from localhost ([::1]:59368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obejH-0007JM-7f for importer@patchew.org; Fri, 23 Sep 2022 05:12:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obebt-0002EJ-AP for qemu-devel@nongnu.org; Fri, 23 Sep 2022 05:04:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39252) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obebr-0004oL-N9 for qemu-devel@nongnu.org; Fri, 23 Sep 2022 05:04:36 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-488-ccbGTkkqPaiuPwm1g4kUlQ-1; Fri, 23 Sep 2022 05:04:31 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5A35A3C1023D; Fri, 23 Sep 2022 09:04:31 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.163]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C50349BB60; Fri, 23 Sep 2022 09:04:30 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DDA1921E6900; Fri, 23 Sep 2022 11:04:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663923875; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1gpuiKCs1ELi0jnftapN38Fc+t+M2ss2J/W/XR1Ol3g=; b=JdyLauckC8c9kEsPhoGJuzYG/zCr5StBMSiDgUjM8bhqDjExCyVRsMD0Vn8Us06SdfR55D E9wp3xR2jAjS94ARiGWoYCrH5Y6iGNXcbgdTOjd/zvjaTSKNjzjyPEvc4d7zLgpoRGlzjV CsdCRCsWFp8LlFrSnuZclvhANnburN8= X-MC-Unique: ccbGTkkqPaiuPwm1g4kUlQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, mtosatti@redhat.com, sunilmut@microsoft.com, qemu-trivial@nongnu.org Subject: [PATCH] Drop superfluous conditionals around g_free() Date: Fri, 23 Sep 2022 11:04:28 +0200 Message-Id: <20220923090428.93529-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663924337683100001 Content-Type: text/plain; charset="utf-8" There is no need to guard g_free(P) with if (P): g_free(NULL) is safe. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- replay/replay.c | 6 ++---- target/i386/kvm/kvm.c | 12 ++++-------- target/i386/whpx/whpx-all.c | 14 ++++++-------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/replay/replay.c b/replay/replay.c index 4c396bb376..9a0dc1cf44 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -366,10 +366,8 @@ void replay_finish(void) fclose(replay_file); replay_file =3D NULL; } - if (replay_filename) { - g_free(replay_filename); - replay_filename =3D NULL; - } + g_free(replay_filename); + replay_filename =3D NULL; =20 g_free(replay_snapshot); replay_snapshot =3D NULL; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index a1fd1f5379..9603bf265a 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2176,15 +2176,11 @@ int kvm_arch_destroy_vcpu(CPUState *cs) =20 g_free(env->xsave_buf); =20 - if (cpu->kvm_msr_buf) { - g_free(cpu->kvm_msr_buf); - cpu->kvm_msr_buf =3D NULL; - } + g_free(cpu->kvm_msr_buf); + cpu->kvm_msr_buf =3D NULL; =20 - if (env->nested_state) { - g_free(env->nested_state); - env->nested_state =3D NULL; - } + g_free(env->nested_state); + env->nested_state =3D NULL; =20 qemu_del_vm_change_state_handler(cpu->vmsentry); =20 diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index b22a3314b4..8e4969edeb 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1225,14 +1225,12 @@ static void whpx_translate_cpu_breakpoints( } } =20 - if (breakpoints->breakpoints) { - /* - * Free the previous breakpoint list. This can be optimized by kee= ping - * 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); =20 breakpoints->breakpoints =3D new_breakpoints; } --=20 2.37.2