From nobody Tue Feb 10 04:14:15 2026 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=1664356603; cv=none; d=zohomail.com; s=zohoarc; b=liypUToua5sV4YnzzRyRX2yQ4Djzdy29glDYe8A00kiShK51eUsqA4J+eifzIimolz6HItM34dnXBg5zKIbBj8d0LdZjVNRNQcWXGxn61OI8ZJ0Pp57OTjYGtHHQMiQltYXLLNd23/4bd0JLDZHnG9qQu6DRphrXwVj77vieffk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664356603; 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=C766JYsfMX7Nzr3hwAlukL4TK2ArgI7v4YmcFnFKGOA=; b=cJTJbqfAQ14QYbqvQqP6ttNj7nXH3917PVO88g3/2jV3q6/hmoQyCwvKD3jeUo8TGZhEnr7C5wc0VsUVaqEtZDL7EuG1zxHfuIzgVXbz/+mTQ+JD+6sa4spbX+RJZdbCXZ8vXR9/g7XcWflu21j5yiDwpSqclx8Z/id7wmF5dQ8= 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 1664356603759539.7592686926997; Wed, 28 Sep 2022 02:16:43 -0700 (PDT) Received: from localhost ([::1]:39922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odTBK-0008J7-Ly for importer@patchew.org; Wed, 28 Sep 2022 05:16:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odRME-0001Av-IY for qemu-devel@nongnu.org; Wed, 28 Sep 2022 03:19:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odRMB-00007D-Fb for qemu-devel@nongnu.org; Wed, 28 Sep 2022 03:19:48 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-511-trs4QZTSMl64dZVfFx9llQ-1; Wed, 28 Sep 2022 03:19:44 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 49101185A79C; Wed, 28 Sep 2022 07:19:44 +0000 (UTC) Received: from thuth.com (unknown [10.39.193.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64F7D40C83BB; Wed, 28 Sep 2022 07:19:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664349586; 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=C766JYsfMX7Nzr3hwAlukL4TK2ArgI7v4YmcFnFKGOA=; b=RAR/6G+oEKrVkuVg8E+9+Z67EyUZFiGAhFTbJuCcqIEsSEeD4qvF6aWLu7K6Bx4tswl0E5 o5ZokcqspkDiQz/RO1R1IwZT/k4eYT/B1clB5ONRtAYvZzmO2Gu58/UFPsr/8izlrHCBDl 2mLcxI3QY+DzFlZ85hcsU1CaVoIwyRE= X-MC-Unique: trs4QZTSMl64dZVfFx9llQ-1 From: Thomas Huth To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Bin Meng Subject: [PULL 32/37] tests/qtest: hd-geo-test: Avoid using hardcoded /tmp Date: Wed, 28 Sep 2022 09:18:38 +0200 Message-Id: <20220928071843.1468323-33-thuth@redhat.com> In-Reply-To: <20220928071843.1468323-1-thuth@redhat.com> References: <20220928071843.1468323-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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=ham 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: 1664356604903100001 Content-Type: text/plain; charset="utf-8" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng Message-Id: <20220927110632.1973965-13-bmeng.cn@gmail.com> Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- tests/qtest/hd-geo-test.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c index 413cf964c0..ba772f4d7a 100644 --- a/tests/qtest/hd-geo-test.c +++ b/tests/qtest/hd-geo-test.c @@ -27,16 +27,16 @@ =20 static char *create_test_img(int secs) { - char *template =3D strdup("/tmp/qtest.XXXXXX"); + char *template; int fd, ret; =20 - fd =3D mkstemp(template); + fd =3D g_file_open_tmp("qtest.XXXXXX", &template, NULL); g_assert(fd >=3D 0); ret =3D ftruncate(fd, (off_t)secs * 512); close(fd); =20 if (ret) { - free(template); + g_free(template); template =3D NULL; } =20 @@ -422,9 +422,8 @@ static MBRpartitions empty_mbr =3D { {false, 0, 0, 0, 0= , 0, 0, 0, 0}, =20 static char *create_qcow2_with_mbr(MBRpartitions mbr, uint64_t sectors) { - const char *template =3D "/tmp/qtest.XXXXXX"; - char *raw_path =3D strdup(template); - char *qcow2_path =3D strdup(template); + g_autofree char *raw_path =3D NULL; + char *qcow2_path; char cmd[100 + 2 * PATH_MAX]; uint8_t buf[512] =3D {}; int i, ret, fd, offset; @@ -468,7 +467,7 @@ static char *create_qcow2_with_mbr(MBRpartitions mbr, u= int64_t sectors) offset +=3D 0x10; } =20 - fd =3D mkstemp(raw_path); + fd =3D g_file_open_tmp("qtest.XXXXXX", &raw_path, NULL); g_assert(fd >=3D 0); close(fd); =20 @@ -478,7 +477,7 @@ static char *create_qcow2_with_mbr(MBRpartitions mbr, u= int64_t sectors) g_assert(ret =3D=3D sizeof(buf)); close(fd); =20 - fd =3D mkstemp(qcow2_path); + fd =3D g_file_open_tmp("qtest.XXXXXX", &qcow2_path, NULL); g_assert(fd >=3D 0); close(fd); =20 @@ -506,7 +505,6 @@ static char *create_qcow2_with_mbr(MBRpartitions mbr, u= int64_t sectors) free(qemu_img_abs_path); =20 unlink(raw_path); - free(raw_path); =20 return qcow2_path; } @@ -714,7 +712,7 @@ static void test_override(TestArgs *args, CHSResult exp= ected[]) =20 for (i =3D 0; i < args->n_drives; i++) { unlink(args->drives[i]); - free(args->drives[i]); + g_free(args->drives[i]); } g_free(args->drives); g_strfreev(args->argv); @@ -867,7 +865,7 @@ static void test_override_scsi_hot_unplug(void) =20 for (i =3D 0; i < args->n_drives; i++) { unlink(args->drives[i]); - free(args->drives[i]); + g_free(args->drives[i]); } g_free(args->drives); g_strfreev(args->argv); @@ -927,7 +925,7 @@ static void test_override_virtio_hot_unplug(void) =20 for (i =3D 0; i < args->n_drives; i++) { unlink(args->drives[i]); - free(args->drives[i]); + g_free(args->drives[i]); } g_free(args->drives); g_strfreev(args->argv); @@ -987,7 +985,7 @@ test_add_done: for (i =3D 0; i < backend_last; i++) { if (img_file_name[i]) { unlink(img_file_name[i]); - free(img_file_name[i]); + g_free(img_file_name[i]); } } =20 --=20 2.31.1