]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: avoid a static analysis warning in expand-common
authorPádraig Brady <P@draigBrady.com>
Mon, 20 Mar 2017 06:00:05 +0000 (23:00 -0700)
committerPádraig Brady <P@draigBrady.com>
Sun, 26 Mar 2017 22:20:26 +0000 (15:20 -0700)
* src/expand-common.c (next_file): We're dependent on calling
this function with NULL to initialize things appropriately.
So enforce this with assert(), which avoids a warning from
clang-anaylzer.

src/expand-common.c

index 0728e70d0d9b59cfc3615d139428ad6a92b897c4..e1b549fab1010c4806d3729a79ec714d8f3d4821 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <config.h>
 
+#include <assert.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include "system.h"
@@ -282,6 +283,7 @@ next_file (FILE *fp)
 
   if (fp)
     {
+      assert (prev_file);
       if (ferror (fp))
         {
           error (0, errno, "%s", quotef (prev_file));