Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2009-10-27 21:11:29 -0500
committerDan McGee <dan@archlinux.org>2009-10-27 21:11:29 -0500
commit133a39e2bb78f2be1a60094a5a398f04315df64a (patch)
tree7482b24091d1595c8fef20331b86bcdc0bc06207
parentfff6d9dc2e6c61f67d6a50e2dde655f388c173a8 (diff)
Fix opendir error condition checks
Thanks to Laszlo Papp <djszapi@archlinux.us> for the following catch: opendir(path)) == (DIR *)-1; is maybe the result of misunderstanding the manpage. If an opendir() call isn't successful it returns NULL rather than '(DIR *)-1'. Noticed-by: Laszlo Papp <djszapi@archlinux.us> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/util.c3
-rw-r--r--src/pacman/util.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 082c095b..2b006e21 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -404,7 +404,8 @@ int _alpm_rmrf(const char *path)
}
}
} else {
- if((dirp = opendir(path)) == (DIR *)-1) {
+ dirp = opendir(path);
+ if(!dirp) {
return(1);
}
for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
diff --git a/src/pacman/util.c b/src/pacman/util.c
index a02b43cd..c68e6841 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -174,7 +174,8 @@ int rmrf(const char *path)
return(1);
}
- if((dirp = opendir(path)) == (DIR *)-1) {
+ dirp = opendir(path);
+ if(!dirp) {
return(1);
}
for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {