_alpm_log(handle, ALPM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
handle->root, strerror(errno));
_alpm_archive_read_free(archive);
- CLOSE(fd);
+ close(fd);
ret = -1;
goto cleanup;
}
errors += extract_single_file(handle, archive, entry, newpkg, oldpkg);
}
_alpm_archive_read_free(archive);
- CLOSE(fd);
+ close(fd);
/* restore the old cwd if we have it */
if(cwdfd >= 0) {
_alpm_log(handle, ALPM_LOG_ERROR,
_("could not restore working directory (%s)\n"), strerror(errno));
}
- CLOSE(cwdfd);
+ close(cwdfd);
}
if(errors) {
if(!changelog) {
pkg->handle->pm_errno = ALPM_ERR_MEMORY;
_alpm_archive_read_free(archive);
- CLOSE(fd);
+ close(fd);
return NULL;
}
changelog->archive = archive;
}
/* we didn't find a changelog */
_alpm_archive_read_free(archive);
- CLOSE(fd);
+ close(fd);
errno = ENOENT;
return NULL;
int ret;
struct package_changelog *changelog = fp;
ret = _alpm_archive_read_free(changelog->archive);
- CLOSE(changelog->fd);
+ close(changelog->fd);
free(changelog);
return ret;
}
}
_alpm_archive_read_free(archive);
- CLOSE(fd);
+ close(fd);
/* internal fields for package struct */
newpkg->origin = ALPM_PKG_FROM_FILE;
_alpm_pkg_free(newpkg);
_alpm_archive_read_free(archive);
if(fd >= 0) {
- CLOSE(fd);
+ close(fd);
}
return NULL;
cleanup:
_alpm_archive_read_free(archive);
if(fd >= 0) {
- CLOSE(fd);
+ close(fd);
}
return count;
}
fchmod(fd, ~(_getumask()) & 0666) ||
!(fp = fdopen(fd, payload->tempfile_openmode))) {
unlink(randpath);
- CLOSE(fd);
+ close(fd);
_alpm_log(payload->handle, ALPM_LOG_ERROR,
_("failed to create temporary file for download\n"));
free(randpath);
cleanup:
free(buf);
if(in >= 0) {
- CLOSE(in);
+ close(in);
}
if(out >= 0) {
- CLOSE(out);
+ close(out);
}
return ret;
}
_alpm_archive_read_free(*archive);
*archive = NULL;
if(fd >= 0) {
- CLOSE(fd);
+ close(fd);
}
RET_ERR(handle, error, -1);
}
cleanup:
umask(oldmask);
_alpm_archive_read_free(archive);
- CLOSE(fd);
+ close(fd);
if(cwdfd >= 0) {
if(fchdir(cwdfd) != 0) {
_alpm_log(handle, ALPM_LOG_ERROR,
_("could not restore working directory (%s)\n"), strerror(errno));
}
- CLOSE(cwdfd);
+ close(cwdfd);
}
return ret;
if(pid == 0) {
/* this code runs for the child only (the actual chroot/exec) */
- CLOSE(1);
- CLOSE(2);
+ close(1);
+ close(2);
while(dup2(pipefd[1], 1) == -1 && errno == EINTR);
while(dup2(pipefd[1], 2) == -1 && errno == EINTR);
- CLOSE(pipefd[0]);
- CLOSE(pipefd[1]);
+ close(pipefd[0]);
+ close(pipefd[1]);
/* use fprintf instead of _alpm_log to send output through the parent */
if(chroot(handle->root) != 0) {
int status;
FILE *pipe_file;
- CLOSE(pipefd[1]);
+ close(pipefd[1]);
pipe_file = fdopen(pipefd[0], "r");
if(pipe_file == NULL) {
- CLOSE(pipefd[0]);
+ close(pipefd[0]);
retval = 1;
} else {
while(!feof(pipe_file)) {
_alpm_log(handle, ALPM_LOG_ERROR,
_("could not restore working directory (%s)\n"), strerror(errno));
}
- CLOSE(cwdfd);
+ close(cwdfd);
}
return retval;
MD5_Update(&ctx, buf, n);
}
- CLOSE(fd);
+ close(fd);
free(buf);
if(n < 0) {
}
}
- CLOSE(fd);
+ close(fd);
free(buf);
if(n < 0) {
#endif
#define OPEN(fd, path, flags) do { fd = open(path, flags | O_BINARY); } while(fd == -1 && errno == EINTR)
-#define CLOSE(fd) do { int _ret; do { _ret = close(fd); } while(_ret == -1 && errno == EINTR); } while(0)
/**
* Used as a buffer/state holder for _alpm_archive_fgets().
cleanup:
/* restore the old cwd if we have it */
if(cwdfd >= 0) {
- int close_ret;
if(fchdir(cwdfd) != 0) {
pm_printf(ALPM_LOG_ERROR, _("could not restore working directory (%s)\n"),
strerror(errno));
}
- do {
- close_ret = close(cwdfd);
- } while(close_ret == -1 && errno == EINTR);
+ close(cwdfd);
}
if(ret == -1) {