From: Masatake YAMATO Date: Wed, 18 Sep 2024 19:01:23 +0000 (+0900) Subject: tests: (test_mkfds, refactor) use xmemdup newly added in xalloc.h X-Git-Tag: v2.42-start~184^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5ac589475166d0e30c5a4ad73ebf2d8398fa78b7;p=thirdparty%2Futil-linux.git tests: (test_mkfds, refactor) use xmemdup newly added in xalloc.h Signed-off-by: Masatake YAMATO --- diff --git a/tests/helpers/test_mkfds.c b/tests/helpers/test_mkfds.c index 6ac1ad07a..0f20435df 100644 --- a/tests/helpers/test_mkfds.c +++ b/tests/helpers/test_mkfds.c @@ -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; }