coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [coreutils] [PATCH] maint: suppress some clang scan-build warnings


From: Jim Meyering
Subject: Re: [coreutils] [PATCH] maint: suppress some clang scan-build warnings
Date: Fri, 07 Jan 2011 08:38:48 +0100

Pádraig Brady wrote:
>
>     maint: suppress some clang scan-build warnings
>
>     * src/pr.c (char_to_clump): Remove a dead store.
>     * src/remove.c (fts_skip_tree): Likewise.
>     * src/sort.c (key_warnings): Likewise.
>     (sort): Suppress an uninitialized pointer warning.

Thanks!  That is fine, with one correction below.

I hope clang's analysis improves to the point
that we can make coreutils warning-free without too much effort.
I noticed that this warning about ln.c is bogus:

    203 && (backup_type == no_backups || !symbolic_link)
    204 && (!symbolic_link || stat (source, &source_stats) == 0)
    205 && SAME_INODE (source_stats, dest_stats)

      Within the expansion of the macro 'SAME_INODE':
      The left operand of '==' is a garbage value

Here's the expansion:
         ((source_stats).st_ino == (dest_stats).st_ino &&
          (source_stats).st_dev == (dest_stats).st_dev)

The problem is that clang made the assumption, a few lines above,
that "symbolic_link" was true, yet doesn't deduce the consequence:
whenever SAME_INODE is reached, the just-prior call to stat has
succeeded, and hence has defined "source_stats".

...
> diff --git a/src/sort.c b/src/sort.c
...
> @@ -3770,6 +3770,7 @@ sort (char *const *files, size_t nfiles, char const 
> *output_file,
>        size_t nthreads)
>  {
>    struct buffer buf;
> +  IF_LINT (buf.buf == NULL);

ETOOLATE ;-)  You must mean this:

    IF_LINT (buf.buf = NULL);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]