opendir(path)) == (DIR *)-1 is maybe the result of miss understanding of the man page, if the opendir wasn't successful it gives back NULL instead of '(DIR *)-1'. The ambiguity while cycle with EINTR condition was refactored for a do {} while () cycle to be easier to read/understand Signed-off-by: Laszlo Papp <djszapi@archlinux.us> --- I was very supprised on this post. It was very rude and not constructive in this way even I did bad thing in it. I've never said I'm proficient and I do failures sometimes because of missunderstanding e.g., and I don't think it was a big error that can't be corrected. but Dan! I spend(spent?) with my freetime with helping you and pacman... I've never experienced this nowhere in any community when some one try to be helpful and he is named foolish and crappy. I think so it's absolutely uncorrect and unfair... Why is it hard to keep the contructive way ? It would be much easier for you and me too. lib/libalpm/trans.c | 5 ++++- lib/libalpm/util.c | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index aea71db..59b0c87 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -243,6 +243,7 @@ int SYMEXPORT alpm_trans_interrupt() int SYMEXPORT alpm_trans_release() { pmtrans_t *trans; + int fd; ALPM_LOG_FUNC; @@ -261,7 +262,9 @@ int SYMEXPORT alpm_trans_release() /* unlock db */ if(!nolock_flag) { if(handle->lckfd != -1) { - while(close(handle->lckfd) == -1 && errno == EINTR); + do { + fd = close(handle->lckfd); + } while(fd == -1 && errno == EINTR); handle->lckfd = -1; } if(_alpm_lckrm()) { diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 1340da9..0719096 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -224,8 +224,9 @@ int _alpm_lckmk() _alpm_makepath(dir); FREE(dir); - while((fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0000)) == -1 - && errno == EINTR); + do { + fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0000); + } while ( fd == -1 && errno == EINTR); if(fd > 0) { FILE *f = fdopen(fd, "w"); fprintf(f, "%ld\n", (long)getpid()); @@ -401,7 +402,7 @@ int _alpm_rmrf(const char *path) } } } else { - if((dirp = opendir(path)) == (DIR *)-1) { + if((dirp = opendir(path)) == NULL) { return(1); } for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { @@ -522,7 +523,9 @@ int _alpm_run_chroot(const char *root, const char *cmd) /* this code runs for the parent only (wait on the child) */ pid_t retpid; int status; - while((retpid = waitpid(pid, &status, 0)) == -1 && errno == EINTR); + do { + retpid = waitpid(pid, &status, 0); + } while(retpid == -1 && errno == EINTR); if(retpid == -1) { _alpm_log(PM_LOG_ERROR, _("call to waitpid failed (%s)\n"), strerror(errno)); -- 1.6.5.1