Marc-André Lureau <[email protected]> writes: > Hi > > On Tue, Sep 20, 2022 at 2:47 PM Bin Meng <[email protected]> wrote: > >> From: Bin Meng <[email protected]> >> >> Lots of test cases were written to use hardcoded /tmp directory for >> temporary files. To avoid this, we update them to use g_dir_make_tmp() >> or g_file_open_tmp() when appropriate. >> >> Signed-off-by: Bin Meng <[email protected]> >> --- >> >> Changes in v2: >> - Use g_dir_make_tmp(), g_file_open_tmp() when appropriate >> >> tests/qtest/fuzz/generic_fuzz_configs.h | 4 ++-- >> tests/qtest/ahci-test.c | 19 +++++++++++-------- >> tests/qtest/aspeed_smc-test.c | 5 ++--- >> tests/qtest/boot-serial-test.c | 9 +++++---- >> tests/qtest/cxl-test.c | 15 ++++++--------- >> tests/qtest/fdc-test.c | 5 +++-- >> tests/qtest/fuzz/virtio_blk_fuzz.c | 4 ++-- >> tests/qtest/hd-geo-test.c | 24 +++++++++++------------- >> tests/qtest/ide-test.c | 10 ++++++---- >> tests/qtest/libqtest.c | 12 ++++++++---- >> tests/qtest/migration-test.c | 7 ++++--- >> tests/qtest/pflash-cfi02-test.c | 8 +++++--- >> tests/qtest/qmp-test.c | 6 ++++-- >> tests/qtest/vhost-user-blk-test.c | 3 ++- >> tests/qtest/vhost-user-test.c | 8 ++++---- >> tests/qtest/virtio-blk-test.c | 4 ++-- >> tests/qtest/virtio-scsi-test.c | 4 ++-- >> tests/unit/test-image-locking.c | 8 ++++---- >> tests/unit/test-qga.c | 2 +- >> tests/vhost-user-bridge.c | 3 +-- >> 20 files changed, 85 insertions(+), 75 deletions(-) >> >> diff --git a/tests/qtest/fuzz/generic_fuzz_configs.h >> b/tests/qtest/fuzz/generic_fuzz_configs.h >> index 0775e6702b..a825b78c14 100644 >> --- a/tests/qtest/fuzz/generic_fuzz_configs.h >> +++ b/tests/qtest/fuzz/generic_fuzz_configs.h >> @@ -20,8 +20,8 @@ typedef struct generic_fuzz_config { >> } generic_fuzz_config; >> >> static inline gchar *generic_fuzzer_virtio_9p_args(void){ >> - char tmpdir[] = "/tmp/qemu-fuzz.XXXXXX"; >> - g_assert_nonnull(g_mkdtemp(tmpdir)); >> + g_autofree char *tmpdir = g_dir_make_tmp("qemu-fuzz.XXXXXX", NULL); >> + g_assert_nonnull(tmpdir); >> >> return g_strdup_printf("-machine q35 -nodefaults " >> "-device virtio-9p,fsdev=hshare,mount_tag=hshare " >> diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c >> index f1e510b0ac..00524f14c6 100644 >> --- a/tests/qtest/ahci-test.c >> +++ b/tests/qtest/ahci-test.c >> @@ -44,9 +44,9 @@ >> #define TEST_IMAGE_SIZE_MB_SMALL 64 >> >> /*** Globals ***/ >> -static char tmp_path[] = "/tmp/qtest.XXXXXX"; >> -static char debug_path[] = "/tmp/qtest-blkdebug.XXXXXX"; >> -static char mig_socket[] = "/tmp/qtest-migration.XXXXXX"; >> +static char *tmp_path; >> +static char *debug_path; >> +static char *mig_socket; >> static bool ahci_pedantic; >> static const char *imgfmt; >> static unsigned test_image_size_mb; >> @@ -1437,10 +1437,10 @@ static void test_ncq_simple(void) >> >> static int prepare_iso(size_t size, unsigned char **buf, char **name) >> { >> - char cdrom_path[] = "/tmp/qtest.iso.XXXXXX"; >> + g_autofree char *cdrom_path; >> > > Whenever introducing g_auto* usage, please make sure to initialize the > variable to NULL or a correct value.
Potential food for checkpatch.pl. [...]
