From: Zbigniew Jędrzejewski-Szmek Date: Wed, 31 Mar 2021 15:13:24 +0000 (+0200) Subject: test-capability: silence gcc warning X-Git-Tag: v249-rc1~490^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0a94e77ed4cf5480f2ea0aac373392a9bb48571d;p=thirdparty%2Fsystemd.git test-capability: silence gcc warning [2/3] Compiling C object test-capability.p/src_test_test-capability.c.o ../src/test/test-capability.c: In function ‘main’: ../src/test/test-capability.c:270:12: warning: ‘run_ambient’ may be used uninitialized in this function [-Wmaybe-uninitialized] 270 | if (run_ambient) | ^ gcc-11.0.1-0.3.fc34.x86_64 --- diff --git a/src/test/test-capability.c b/src/test/test-capability.c index 0ff56070b16..bd17dc0e790 100644 --- a/src/test/test-capability.c +++ b/src/test/test-capability.c @@ -103,22 +103,15 @@ static int setup_tests(bool *run_ambient) { nobody = getpwnam(NOBODY_USER_NAME); if (!nobody) - return log_error_errno(SYNTHETIC_ERRNO(ENOENT), "Could not find nobody user: %m"); + return log_warning_errno(SYNTHETIC_ERRNO(ENOENT), "Couldn't find 'nobody' user: %m"); test_uid = nobody->pw_uid; test_gid = nobody->pw_gid; - *run_ambient = false; - r = prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0, 0, 0); - - /* There's support for PR_CAP_AMBIENT if the prctl() call - * succeeded or error code was something else than EINVAL. The - * EINVAL check should be good enough to rule out false - * positives. */ - - if (r >= 0 || errno != EINVAL) - *run_ambient = true; + /* There's support for PR_CAP_AMBIENT if the prctl() call succeeded or error code was something else + * than EINVAL. The EINVAL check should be good enough to rule out false positives. */ + *run_ambient = r >= 0 || errno != EINVAL; return 0; } @@ -249,7 +242,7 @@ static void test_ensure_cap_64bit(void) { } int main(int argc, char *argv[]) { - bool run_ambient; + bool run_ambient = false; /* unnecessary initialization to silence gcc warning */ test_setup_logging(LOG_INFO);