From 2e075a16da4963f54cd556403ca9e15a68de27fd Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 23 Jun 2006 14:38:33 +1000 Subject: Fix various issues discovered by Coverity Thanks to Michael Halcrow for finding them. --- support/misc/mountpoint.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'support/misc/mountpoint.c') diff --git a/support/misc/mountpoint.c b/support/misc/mountpoint.c index 6d0f34e..2cf1324 100644 --- a/support/misc/mountpoint.c +++ b/support/misc/mountpoint.c @@ -20,15 +20,21 @@ is_mountpoint(char *path) */ char *dotdot; struct stat stb, pstb; + int rv; dotdot = malloc(strlen(path)+4); + if (!dotdot) + return 0; strcat(strcpy(dotdot, path), "/.."); if (lstat(path, &stb) != 0 || lstat(dotdot, &pstb) != 0) - return 0; - - if (stb.st_dev != pstb.st_dev - || stb.st_ino == pstb.st_ino) - return 1; - return 0; + rv = 0; + else + if (stb.st_dev != pstb.st_dev || + stb.st_ino == pstb.st_ino) + rv = 1; + else + rv = 0; + free(dotdot); + return rv; } -- cgit From 0523fd513c6baa8dbf45d1a7afea2044262aeb3d Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 23 Jun 2006 17:10:56 +1000 Subject: Further coverity related cleanups. Greg Banks suggested some variations, particularly improved use of xmalloc/xstrdup functions. Thanks. --- support/misc/mountpoint.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'support/misc/mountpoint.c') diff --git a/support/misc/mountpoint.c b/support/misc/mountpoint.c index 2cf1324..750b6e8 100644 --- a/support/misc/mountpoint.c +++ b/support/misc/mountpoint.c @@ -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) -- cgit