]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Further coverity related cleanups.
authorNeil Brown <neilb@suse.de>
Fri, 23 Jun 2006 07:10:56 +0000 (17:10 +1000)
committerNeil Brown <neilb@suse.de>
Fri, 23 Jun 2006 07:10:56 +0000 (17:10 +1000)
Greg Banks suggested some variations, particularly improved
use of xmalloc/xstrdup functions.  Thanks.

support/misc/mountpoint.c
utils/idmapd/idmapd.c
utils/statd/notlist.c

index 2cf1324fb17a9674109221fd49dde2643f65577a..750b6e81a602928e7a34404cb0d6cce775542c28 100644 (file)
@@ -22,9 +22,8 @@ is_mountpoint(char *path)
        struct stat stb, pstb;
        int rv;
 
-       dotdot = malloc(strlen(path)+4);
-       if (!dotdot)
-               return 0;
+       dotdot = xmalloc(strlen(path)+4);
+
        strcat(strcpy(dotdot, path), "/..");
        if (lstat(path, &stb) != 0 ||
            lstat(dotdot, &pstb) != 0)
index 1231db4045dab5023dfc3504c3111ce44aef6eab..5fc7811a8465b3c5be2ce35ef85c628fc639d092 100644 (file)
@@ -1003,12 +1003,15 @@ mydaemon(int nochdir, int noclose)
 
        if (noclose == 0) {
                tempfd = open("/dev/null", O_RDWR);
+               if (tempfd < 0)
+                       tempfd = open("/", O_RDONLY);
                if (tempfd >= 0) {
                        dup2(tempfd, 0);
                        dup2(tempfd, 1);
                        dup2(tempfd, 2);
-               }
-               closeall(3);
+                       closeall(3);
+               } else
+                       closeall(0);
        }
 
        return;
index 98aa6e2fa3a2571871f148cef70e27e284076db7..b74d9df07b1806667e5a7992ae675223771a0824 100644 (file)
@@ -54,19 +54,13 @@ nlist_new(char *my_name, char *mon_name, int state)
 {
        notify_list     *new;
 
-       if (!(new = (notify_list *) xmalloc(sizeof(notify_list))))
-               return NULL;
+       new = (notify_list *) xmalloc(sizeof(notify_list));
        memset(new, 0, sizeof(*new));
 
        NL_TIMES(new) = MAX_TRIES;
        NL_STATE(new) = state;
-       if (!(NL_MY_NAME(new) = xstrdup(my_name))
-           || !(NL_MON_NAME(new) = xstrdup(mon_name))) {
-               if (NL_MY_NAME(new))
-                       free(NL_MY_NAME(new));
-               free(new);
-               return NULL;
-       }
+       NL_MY_NAME(new) = xstrdup(my_name);
+       NL_MON_NAME(new) = xstrdup(mon_name);
 
        return new;
 }