]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (test_mkfds, refactor) use xmemdup newly added in xalloc.h
authorMasatake YAMATO <yamato@redhat.com>
Wed, 18 Sep 2024 19:01:23 +0000 (04:01 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Tue, 1 Oct 2024 17:43:11 +0000 (02:43 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/helpers/test_mkfds.c

index 6ac1ad07a56a4691b414d7ba040b551177dbb8c0..0f20435df39cb33b31932e3a3a6ecfd3173caa47 100644 (file)
@@ -701,8 +701,7 @@ static void *make_w_regular_file(const struct factory *factory, struct fdesc fde
                        errno = e;
                        err(EXIT_FAILURE, "failed in dup2");
                }
-               data = xmalloc(sizeof(iDupfd));
-               *((int *)data) = iDupfd;
+               data = xmemdup(&iDupfd, sizeof(iDupfd));
        }
 
        lock_fn(fd, fname);
@@ -2828,8 +2827,7 @@ static void *make_pty(const struct factory *factory _U_, struct fdesc fdescs[],
                .data  = NULL
        };
 
-       indexp = xmalloc(sizeof(index));
-       *indexp = index;
+       indexp = xmemdup(&index, sizeof(index));
        return indexp;
 }