]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
uniq: pacify GCC -fanalyzer
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 31 Jul 2021 18:14:43 +0000 (11:14 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 31 Jul 2021 18:17:18 +0000 (11:17 -0700)
Pacify GCC 11.1 -fanalyzer.
* src/uniq.c (check_file): Use simpler test to check whether this
is the first time through the loop.  Although the old test was
correct, the new one is easier to understand and perhaps a tiny
bit more efficient.

src/uniq.c

index 8963e94b91b275e61b9fd3b852245b01d27e401c..8f6e97352ee553f49773562d00e228c0a4516340 100644 (file)
@@ -352,7 +352,7 @@ check_file (char const *infile, char const *outfile, char delimiter)
   */
   if (output_unique && output_first_repeated && countmode == count_none)
     {
-      char *prevfield IF_LINT ( = NULL);
+      char *prevfield = NULL;
       size_t prevlen IF_LINT ( = 0);
       bool first_group_printed = false;
 
@@ -368,7 +368,7 @@ check_file (char const *infile, char const *outfile, char delimiter)
           thisfield = find_field (thisline);
           thislen = thisline->length - 1 - (thisfield - thisline->buffer);
 
-          new_group = (prevline->length == 0
+          new_group = (!prevfield
                        || different (thisfield, prevfield, thislen, prevlen));
 
           if (new_group && grouping != GM_NONE