From ca29e8e9845f854d74961c359ddade5751ca9b16 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sun, 2 Aug 2009 21:45:31 -0400 Subject: [PATCH] Use assertUmask() instead of unchecked umask(). SVN-Revision: 1324 --- cpio/test/test_basic.c | 7 ++----- cpio/test/test_format_newc.c | 5 +---- cpio/test/test_gcpio_compat.c | 6 +----- cpio/test/test_option_c.c | 5 +---- cpio/test/test_passthrough_dotdot.c | 5 +---- cpio/test/test_passthrough_reverse.c | 5 +---- 6 files changed, 7 insertions(+), 26 deletions(-) diff --git a/cpio/test/test_basic.c b/cpio/test/test_basic.c index 2175ba4e6..2e0ed3b09 100644 --- a/cpio/test/test_basic.c +++ b/cpio/test/test_basic.c @@ -183,9 +183,8 @@ DEFINE_TEST(test_basic) { int fd; int filelist; - int oldumask; - oldumask = umask(0); + assertUmask(0); /* * Create an assortment of files on disk. @@ -220,7 +219,7 @@ DEFINE_TEST(test_basic) /* All done. */ close(filelist); - umask(022); + assertUmask(022); /* Archive/dearchive with a variety of options. */ basic_cpio("copy", "", "", "2 blocks\n"); @@ -239,6 +238,4 @@ DEFINE_TEST(test_basic) #endif /* Copy in one step using -p */ passthrough("passthrough"); - - umask(oldumask); } diff --git a/cpio/test/test_format_newc.c b/cpio/test/test_format_newc.c index 2bcfcc6db..bbe3dcd4f 100644 --- a/cpio/test/test_format_newc.c +++ b/cpio/test/test_format_newc.c @@ -69,9 +69,8 @@ DEFINE_TEST(test_format_newc) time_t t, t2, now; char *p, *e; size_t s, fs, ns; - mode_t oldmask; - oldmask = umask(0); + assertUmask(0); /* * Create an assortment of files. @@ -284,6 +283,4 @@ DEFINE_TEST(test_format_newc) assertEqualMem(e + 110, "TRAILER!!!\0\0", 12); /* Name */ free(p); - - umask(oldmask); } diff --git a/cpio/test/test_gcpio_compat.c b/cpio/test/test_gcpio_compat.c index 30970a8d2..c5e80575b 100644 --- a/cpio/test/test_gcpio_compat.c +++ b/cpio/test/test_gcpio_compat.c @@ -111,9 +111,7 @@ unpack_test(const char *from, const char *options, const char *se) DEFINE_TEST(test_gcpio_compat) { - int oldumask; - - oldumask = umask(0); + assertUmask(0); /* Dearchive sample files with a variety of options. */ unpack_test("test_gcpio_compat_ref.bin", "--no-preserve-owner", "1 block\n"); @@ -121,6 +119,4 @@ DEFINE_TEST(test_gcpio_compat) unpack_test("test_gcpio_compat_ref.newc", "--no-preserve-owner", "2 blocks\n"); /* gcpio-2.9 only reads 6 blocks here */ unpack_test("test_gcpio_compat_ref.ustar", "--no-preserve-owner", "7 blocks\n"); - - umask(oldumask); } diff --git a/cpio/test/test_option_c.c b/cpio/test/test_option_c.c index 23808ae5c..7270187ec 100644 --- a/cpio/test/test_option_c.c +++ b/cpio/test/test_option_c.c @@ -59,9 +59,8 @@ DEFINE_TEST(test_option_c) time_t t, now; char *p, *e; size_t s; - mode_t oldmask; - oldmask = umask(0); + assertUmask(0); /* * Create an assortment of files. @@ -222,6 +221,4 @@ DEFINE_TEST(test_option_c) assertEqualMem(e + 76, "TRAILER!!!\0", 11); /* Name */ free(p); - - umask(oldmask); } diff --git a/cpio/test/test_passthrough_dotdot.c b/cpio/test/test_passthrough_dotdot.c index 83c97d86e..9dc8dbb0d 100644 --- a/cpio/test/test_passthrough_dotdot.c +++ b/cpio/test/test_passthrough_dotdot.c @@ -34,9 +34,8 @@ DEFINE_TEST(test_passthrough_dotdot) struct stat st; int fd, r; int filelist; - int oldumask; - oldumask = umask(0); + assertUmask(0); /* * Create an assortment of files on disk. @@ -88,6 +87,4 @@ DEFINE_TEST(test_passthrough_dotdot) assertEqualInt(10, st.st_size); assertEqualInt(1, st.st_nlink); } - - umask(oldumask); } diff --git a/cpio/test/test_passthrough_reverse.c b/cpio/test/test_passthrough_reverse.c index cd8efd8ce..25ba73b56 100644 --- a/cpio/test/test_passthrough_reverse.c +++ b/cpio/test/test_passthrough_reverse.c @@ -39,9 +39,8 @@ DEFINE_TEST(test_passthrough_reverse) struct stat st; int fd, r; int filelist; - int oldumask; - oldumask = umask(0); + assertUmask(0); /* * Create an assortment of files on disk. @@ -107,6 +106,4 @@ DEFINE_TEST(test_passthrough_reverse) assertEqualInt(10, st.st_size); assertEqualInt(1, st.st_nlink); } - - umask(oldumask); } -- 2.47.3