From: Andre Noll Date: Fri, 9 Jan 2009 00:16:44 +0000 (+0100) Subject: Merge commit 'meins/master' X-Git-Tag: v0.3.4~75^2~35 X-Git-Url: http://git.tuebingen.mpg.de/?a=commitdiff_plain;h=40de1dd2fdbb054444d585aa70e2d50166a66e07;hp=-c;p=paraslash.git Merge commit 'meins/master' --- 40de1dd2fdbb054444d585aa70e2d50166a66e07 diff --combined fd.c index 8fc1abad,d0b5c895..c675aaff --- a/fd.c +++ b/fd.c @@@ -285,9 -285,10 +285,10 @@@ int para_opendir(const char *dirname, D if (*dir) return 1; ret = -ERRNO_TO_PARA_ERROR(errno); - /* Ignore return value of fchdir() and close(). We're busted anyway. */ - if (cwd) - fchdir(*cwd); + /* Ignore return value of fchdir() and close(). We're busted anyway. */ + if (cwd) { + int __a_unused ret2 = fchdir(*cwd); /* STFU, gcc */ + } close_cwd: if (cwd) close(*cwd); @@@ -426,24 -427,3 +427,24 @@@ again goto again; return ret; } + +/** + * Ensure that file descriptors 0, 1, and 2 are valid. + * + * Common approach that opens /dev/null until it gets a file descriptor greater + * than two. + * + * \sa okir's Black Hats Manual. + */ +void valid_fd_012(void) +{ + while (1) { + int fd = open("/dev/null", O_RDWR); + if (fd < 0) + exit(EXIT_FAILURE); + if (fd > 2) { + close(fd); + break; + } + } +} diff --combined string.c index c73ec1e6,d23e43c1..bdc113d3 --- a/string.c +++ b/string.c @@@ -59,9 -59,10 +59,10 @@@ __must_check __malloc void *para_reallo */ __must_check __malloc void *para_malloc(size_t size) { - assert(size); - void *p = malloc(size); + void *p; + assert(size); + p = malloc(size); if (!p) { PARA_EMERG_LOG("malloc failed (size = %zu), aborting\n", size); @@@ -327,6 -328,27 +328,6 @@@ __must_check unsigned split_args(char * return n; } -/** - * Ensure that file descriptors 0, 1, and 2 are valid. - * - * Common approach that opens /dev/null until it gets a file descriptor greater - * than two. - * - * \sa okir's Black Hats Manual. - */ -void valid_fd_012(void) -{ - while (1) { - int fd = open("/dev/null", O_RDWR); - if (fd < 0) - exit(EXIT_FAILURE); - if (fd > 2) { - close(fd); - break; - } - } -} - /** * Get the own hostname. *