1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
From: Simon McVittie <smcv@collabora.com>
Date: Wed, 28 Oct 2020 12:21:16 +0000
Subject: glib/tests/fileutils: Make more use of g_assert_no_errno()
Signed-off-by: Simon McVittie <smcv@collabora.com>
Forwarded: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1724
---
glib/tests/fileutils.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/glib/tests/fileutils.c b/glib/tests/fileutils.c
index 4baedf6..50199ef 100644
--- a/glib/tests/fileutils.c
+++ b/glib/tests/fileutils.c
@@ -557,13 +557,13 @@ check_cap_dac_override (const char *tmpdir)
dac_denies_write = g_build_filename (tmpdir, "dac-denies-write", NULL);
inside = g_build_filename (dac_denies_write, "inside", NULL);
- g_assert_cmpint (mkdir (dac_denies_write, S_IRWXU) == 0 ? 0 : errno, ==, 0);
- g_assert_cmpint (chmod (dac_denies_write, 0) == 0 ? 0 : errno, ==, 0);
+ g_assert_no_errno (mkdir (dac_denies_write, S_IRWXU));
+ g_assert_no_errno (chmod (dac_denies_write, 0));
if (mkdir (inside, S_IRWXU) == 0)
{
g_test_message ("Looks like we have CAP_DAC_OVERRIDE or equivalent");
- g_assert_cmpint (rmdir (inside) == 0 ? 0 : errno, ==, 0);
+ g_assert_no_errno (rmdir (inside));
have_cap = TRUE;
}
else
@@ -575,8 +575,8 @@ check_cap_dac_override (const char *tmpdir)
have_cap = FALSE;
}
- g_assert_cmpint (chmod (dac_denies_write, S_IRWXU) == 0 ? 0 : errno, ==, 0);
- g_assert_cmpint (rmdir (dac_denies_write) == 0 ? 0 : errno, ==, 0);
+ g_assert_no_errno (chmod (dac_denies_write, S_IRWXU));
+ g_assert_no_errno (rmdir (dac_denies_write));
g_free (dac_denies_write);
g_free (inside);
return have_cap;
@@ -606,8 +606,8 @@ test_mkdir_with_parents_permission (void)
subdir = g_build_filename (tmpdir, "sub", NULL);
subdir2 = g_build_filename (subdir, "sub2", NULL);
subdir3 = g_build_filename (subdir2, "sub3", NULL);
- g_assert_cmpint (g_mkdir (subdir, 0700) == 0 ? 0 : errno, ==, 0);
- g_assert_cmpint (g_chmod (subdir, 0) == 0 ? 0 : errno, ==, 0);
+ g_assert_no_errno (g_mkdir (subdir, 0700));
+ g_assert_no_errno (g_chmod (subdir, 0));
if (have_cap_dac_override)
{
@@ -625,11 +625,11 @@ test_mkdir_with_parents_permission (void)
g_assert_cmpint (result, ==, -1);
g_assert_cmpint (saved_errno, ==, EACCES);
- g_assert_cmpint (g_chmod (subdir, 0700) == 0 ? 0 : errno, ==, 0);
+ g_assert_no_errno (g_chmod (subdir, 0700));
}
- g_assert_cmpint (g_remove (subdir) == 0 ? 0 : errno, ==, 0);
- g_assert_cmpint (g_remove (tmpdir) == 0 ? 0 : errno, ==, 0);
+ g_assert_no_errno (g_remove (subdir));
+ g_assert_no_errno (g_remove (tmpdir));
g_free (subdir3);
g_free (subdir2);
g_free (subdir);
|