From nobody Sun Dec 22 05:58:14 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=1669203953; cv=none; d=zohomail.com; s=zohoarc; b=aCd7q00nl08HAK4ECC6S5VFDZmWC3ZcJHRMQHONwgII3Z1/HfWSoVx7FbeKt39a2Nxr5hhC7IRXB077q5B0vSmA+2AUMuqGbn8e6BtclP4GSUJ9gfNbiXcfTNCeKG+Tptn260vBuKMzBA5jIkoMUV/D/kiJT+aVACKWKgWPE3C8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669203953; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4atEuIaaRKqT9tSK9Che07ZLdyq5LOl66atTrA4lUzs=; b=MuBvWCwslzxiE0OZEmF4KpvfSuZ6Zo7JJs0zjxM4gngwns/AEZKIK6gsebuvfkbxFHMsr2CF9L63MZo88wdZOZvs5nNg23yQvcXlkh1ccmg5dSgL1mJy3dXdAuJKWBDjmSKn6HfB02Nba9lIvClJgJVyp0xDjaAizwSotlEwyUo= 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 166920395376557.82696042782004; Wed, 23 Nov 2022 03:45:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxo9J-0002en-6l; Wed, 23 Nov 2022 06:42:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxo9H-0002cU-6f for qemu-devel@nongnu.org; Wed, 23 Nov 2022 06:42:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxo9E-000613-Ob for qemu-devel@nongnu.org; Wed, 23 Nov 2022 06:42:38 -0500 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-500-aPQ-5JklOF2_UfqGovhy1A-1; Wed, 23 Nov 2022 06:42:33 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6FB883C0F237; Wed, 23 Nov 2022 11:42:32 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A2DDC1908E; Wed, 23 Nov 2022 11:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669203756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4atEuIaaRKqT9tSK9Che07ZLdyq5LOl66atTrA4lUzs=; b=Ckrqn7TynPRJ0tGD6msuOM0lMPCc/HUOIpCl7XTUD6yKep7tQZ1nRwDMPI+/gtIacMin54 u73vMXWvR+NMEZ8HaInG6A04ac0dQJH9hW5lvDqJY0Wc5bJ4FpSSVYqdR/IGL5UUyQnZ1U YM8q0/lbaNp08KggSf875cpmFNgUstk= X-MC-Unique: aPQ-5JklOF2_UfqGovhy1A-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Vladimir Sementsov-Ogievskiy , Eric Blake , Fam Zheng , Stefan Hajnoczi , "Denis V. Lunev" , Stefan Weil , Jeff Cody , Cleber Rosa , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH v5 06/15] block: avoid duplicating filename string in bdrv_create Date: Wed, 23 Nov 2022 06:42:18 -0500 Message-Id: <20221123114227.85757-7-eesposit@redhat.com> In-Reply-To: <20221123114227.85757-1-eesposit@redhat.com> References: <20221123114227.85757-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669203955508100003 Content-Type: text/plain; charset="utf-8" We know that the string will stay around until the function returns, and the parameter of drv->bdrv_co_create_opts is const char*, so it must not be modified either. Suggested-by: Kevin Wolf Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf --- block.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 8c9f4ee37c..9d51e7b6e5 100644 --- a/block.c +++ b/block.c @@ -553,7 +553,7 @@ int bdrv_create(BlockDriver *drv, const char* filename, Coroutine *co; CreateCo cco =3D { .drv =3D drv, - .filename =3D g_strdup(filename), + .filename =3D filename, .opts =3D opts, .ret =3D NOT_DONE, .err =3D NULL, @@ -561,8 +561,7 @@ int bdrv_create(BlockDriver *drv, const char* filename, =20 if (!drv->bdrv_co_create_opts) { error_setg(errp, "Driver '%s' does not support image creation", dr= v->format_name); - ret =3D -ENOTSUP; - goto out; + return -ENOTSUP; } =20 if (qemu_in_coroutine()) { @@ -585,8 +584,6 @@ int bdrv_create(BlockDriver *drv, const char* filename, } } =20 -out: - g_free(cco.filename); return ret; } =20 --=20 2.31.1