From nobody Mon Feb 9 18:19:16 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1664107603; cv=none; d=zohomail.com; s=zohoarc; b=QYox3ZSQGyCpEFhcg2xcRT2YIHFxIXztPoDwLSvC/zxtyPGFzD+JD/Ad3oI7BU0Px4Il9kKqkPIRbYle2tfHGAsuMfOQ3WZwXjXodOCC1TBB26YR0nlhI10w7TnHnSwKQB5yUy/oajMSqpYO7nIVNAQQSkYypffikYio8ZwLNUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664107603; 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=nM74FruDmU4z4IA66IfyAjmi4E35/GiRsCvNkBTqFAc=; b=aEE+z+miINUNu1ilAvAfa0y/D345UjC1irX5tTBqi95GS7nkdgY7BFNaCH2z7NsNE1h2n1/4M+RcCdYcviK7UJlHES2yZMthdOvn2nnWAF51XMFof9pgeWaKszgkgU7DWR3JpT5oUOWCNB2P6RY6GSfbbgxeCQ0TYlFf1lYhLT8= 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 1664107603104478.87979158741825; Sun, 25 Sep 2022 05:06:43 -0700 (PDT) Received: from localhost ([::1]:57612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQPB-0002rs-Uc for importer@patchew.org; Sun, 25 Sep 2022 08:06:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrK-0002m8-PU for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:42 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:45853) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrD-0006Km-KI for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:42 -0400 Received: by mail-pj1-x1036.google.com with SMTP id p1-20020a17090a2d8100b0020040a3f75eso4291911pjd.4 for ; Sun, 25 Sep 2022 04:31:23 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=nM74FruDmU4z4IA66IfyAjmi4E35/GiRsCvNkBTqFAc=; b=KCPNTydWPmJ5bBn1MGb6t5mz5qm7zt5MZ+/qPPFcPvsc9+cKfuFzWn4LstvqNxpFdo h6bJDnu6PwnFSCelrUjmiWA/L5fqrYvOZxKapd4jF1Mwz0CBPQxJBYmOZ40yjaf98a33 9N0suiAtIsw67i8co48UxP/sBaaqUd83dMjqHM+myoiwnqQ20qACrNKbY3yE4qqj7TVR cB304e9y4pRAHe24hZWZcYCRrn0hzajUagff7c4Feg04KT23krYiz0d80NrzT5MCi8vC RTjxyUp0Suec+TgINcaXAtRZjBJYlQWmETFmFRsfkaiitM8jQEXdNkRkDZs9bxwetEX/ ku6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=nM74FruDmU4z4IA66IfyAjmi4E35/GiRsCvNkBTqFAc=; b=WU3VCYCnPD18EenOGCtdjSbWx6YQfR3DroKv//HQpibBd1UpAUkQjQUd7L+EqCVJRn LdRhX5w/WJSRvpt1e8khIdHnHTJvGebJjm31SeWvCM6z9BUlzPhJtEyiQxGvVX/Z72Dl Osu2sMeydlmTldwOHBtYKuj18pkj2ppEqiK2ONEH/+o6IkAZ/1YfcayhrJGGVKLqepf5 Q4GhUIuitPjVHQdR+mEFNA8OQmWhpHYvZ+rgqr38wztIPMuwefUEUnjTxXp7DGSjlMXQ k+qKhEbDU649Zo27rZamkzDHeO+HJiIqyd83LRNbRuZcpyDBNe6RXbme9C9gFXbGsGNS LVUw== X-Gm-Message-State: ACrzQf2MfZ47Mo2OyP4+93djZmWpQ3wKSPvnurX+brhLoJLqGIN6Ub9W bAVYot0m73agGY2/mZgBzjxaiw9qWpI= X-Google-Smtp-Source: AMsMyM4qo0ajlMcNaTJH4aKQGZG/PYlVn5qBa1tBQuluWkvMV/S1mMaeX2DuOgGlVtvxKx1+ILygCQ== X-Received: by 2002:a17:902:7c0d:b0:178:a6ca:1dbc with SMTP id x13-20020a1709027c0d00b00178a6ca1dbcmr17304140pll.115.1664105482181; Sun, 25 Sep 2022 04:31:22 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 15/54] tests/qtest: pflash-cfi02-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:53 +0800 Message-Id: <20220925113032.1949844-16-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::1036; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1036.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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 @gmail.com) X-ZM-MESSAGEID: 1664107604015100001 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 --- Changes in v3: - Split to a separate patch tests/qtest/pflash-cfi02-test.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/qtest/pflash-cfi02-test.c b/tests/qtest/pflash-cfi02-tes= t.c index 7fce614b64..55890b7d95 100644 --- a/tests/qtest/pflash-cfi02-test.c +++ b/tests/qtest/pflash-cfi02-test.c @@ -56,7 +56,7 @@ typedef struct { QTestState *qtest; } FlashConfig; =20 -static char image_path[] =3D "/tmp/qtest.XXXXXX"; +static char *image_path; =20 /* * The pflash implementation allows some parameters to be unspecified. We = want @@ -608,6 +608,7 @@ static void test_cfi_in_autoselect(const void *opaque) static void cleanup(void *opaque) { unlink(image_path); + g_free(image_path); } =20 /* @@ -635,16 +636,17 @@ static const FlashConfig configuration[] =3D { =20 int main(int argc, char **argv) { - int fd =3D mkstemp(image_path); + int fd =3D g_file_open_tmp("qtest.XXXXXX", &image_path, NULL); if (fd =3D=3D -1) { g_printerr("Failed to create temporary file %s: %s\n", image_path, strerror(errno)); + g_free(image_path); exit(EXIT_FAILURE); } if (ftruncate(fd, UNIFORM_FLASH_SIZE) < 0) { int error_code =3D errno; close(fd); - unlink(image_path); + cleanup(NULL); g_printerr("Failed to truncate file %s to %u MB: %s\n", image_path, UNIFORM_FLASH_SIZE, strerror(error_code)); exit(EXIT_FAILURE); --=20 2.34.1