utils: fix error open() handling
authorLubomir Rintel <lkundrak@v3.sk>
Thu, 21 Jan 2016 15:56:19 +0000 (16:56 +0100)
committerLubomir Rintel <lkundrak@v3.sk>
Thu, 21 Jan 2016 15:56:19 +0000 (16:56 +0100)
CID 59376 (#2-1 of 2): Argument cannot be negative (NEGATIVE_RETURNS)
negative_returns: urandom is passed to a parameter that cannot be negative.

src/NetworkManagerUtils.c

index fb680d9..76116ac 100644 (file)
@@ -3416,7 +3416,7 @@ nm_utils_ipv6_addr_set_stable_privacy (struct in6_addr *addr,
                int urandom = open ("/dev/urandom", O_RDONLY);
                mode_t key_mask;
 
-               if (!urandom) {
+               if (urandom == -1) {
                        g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN,
                                     "Can't open /dev/urandom: %s", strerror (errno));
                        return FALSE;