From: Andre Noll Date: Tue, 23 Jul 2013 07:23:32 +0000 (+0200) Subject: Avoid gcc warning on FreeBSD. X-Git-Tag: v0.5.1~12^2~1 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=fb9209248297242c899ac270afa5ad45b2d084f7;hp=778af7a6c357d7c784e6e32781c06351cdff56a7 Avoid gcc warning on FreeBSD. FreeBSD 9.1 ships a patched gcc-4.2.1 which complains about use of an initialized variable: fd.c: In function 'for_each_file_in_dir': fd.c:728: warning: 'dir' may be used uninitialized in this function This warning is bogus since para_opendir() only leaves the dir pointer unset on failures. But in this case for_each_file_in_dir() returns early without using the pointer. This commit changes para_opendir() to set dir to NULL before doing anything else. This avoids the warning at almost no cost. --- diff --git a/fd.c b/fd.c index 3ab5cad0..4d4a859b 100644 --- a/fd.c +++ b/fd.c @@ -526,6 +526,7 @@ static int para_opendir(const char *dirname, DIR **dir, int *cwd) { int ret; + *dir = NULL; if (cwd) { ret = para_open(".", O_RDONLY, 0); if (ret < 0)