]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Use negative_errno() to assert errno is positive after a few system calls
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 12 Jan 2016 22:25:23 +0000 (17:25 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 18 Jan 2016 19:25:19 +0000 (14:25 -0500)
This is not particularly intrusive because it happens in simple
utility functions. It helps gcc understand that error codes
are negative.

This gets a rid of most of the remaining warnings.

src/basic/btrfs-util.c
src/basic/clock-util.c
src/basic/path-util.c
src/shared/ask-password-api.c

index acd48f6954a7522d31888c60b91409288e368fd6..d07d1df5a8872d7d024dc849fa4b76cd4963d42b 100644 (file)
@@ -2051,7 +2051,7 @@ int btrfs_subvol_get_parent(int fd, uint64_t subvol_id, uint64_t *ret) {
 
                 args.key.nr_items = 256;
                 if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) < 0)
-                        return -errno;
+                        return negative_errno();
 
                 if (args.key.nr_items <= 0)
                         break;
index 00f549c023fc9b640aabba36519f4740b398632e..05788a360e3739de14b6a1841bf0cfb347dc6972 100644 (file)
@@ -33,6 +33,7 @@
 #include "fd-util.h"
 #include "macro.h"
 #include "string-util.h"
+#include "util.h"
 
 int clock_get_hwclock(struct tm *tm) {
         _cleanup_close_ int fd = -1;
@@ -121,7 +122,8 @@ int clock_set_timezone(int *min) {
          * have read from the RTC.
          */
         if (settimeofday(tv_null, &tz) < 0)
-                return -errno;
+                return negative_errno();
+
         if (min)
                 *min = minutesdelta;
         return 0;
index 61fab0e0878a383d9992dc0a88d22bd181d72478..4837bb2d7d2fa71dde08ca21bef448a972d6810d 100644 (file)
@@ -102,7 +102,7 @@ int path_make_absolute_cwd(const char *p, char **ret) {
 
                 cwd = get_current_dir_name();
                 if (!cwd)
-                        return -errno;
+                        return negative_errno();
 
                 c = strjoin(cwd, "/", p, NULL);
         }
index bc12f89f02704f5ce8172b524cb7a4328442aaa5..8de1445a9617da5059428e4ffa5005f6d5c5469d 100644 (file)
@@ -71,7 +71,7 @@ static int lookup_key(const char *keyname, key_serial_t *ret) {
 
         serial = request_key("user", keyname, NULL, 0);
         if (serial == -1)
-                return -errno;
+                return negative_errno();
 
         *ret = serial;
         return 0;