]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
test: (mkfds::make-regular-file) delete the created file when an error occurs
authorMasatake YAMATO <yamato@redhat.com>
Wed, 5 Jul 2023 03:38:12 +0000 (12:38 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Wed, 5 Jul 2023 04:49:17 +0000 (13:49 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/helpers/test_mkfds.c

index 19ffa0d7e636f3e1a3a209e599857d1ffccd041e..8da4d4753dde7088be5bc5756958a95c2a491f86 100644 (file)
@@ -412,6 +412,7 @@ static void *make_w_regular_file(const struct factory *factory, struct fdesc fde
                if (dup2(fd, fdescs[0].fd) < 0) {
                        int e = errno;
                        close(fd);
+                       unlink(fname);
                        free (fname);
                        errno = e;
                        err(EXIT_FAILURE, "failed to dup %d -> %d", fd, fdescs[0].fd);