[dovecot/core] dc38a5: lib/macros.h - protect old compilers from use of m...

GitHub noreply at github.com
Tue Dec 6 18:30:08 UTC 2016


  Branch: refs/heads/master
  Home:   https://github.com/dovecot/core
  Commit: dc38a5b101102ec57da9e25e6b80561ead3f54f8
      https://github.com/dovecot/core/commit/dc38a5b101102ec57da9e25e6b80561ead3f54f8
  Author: Phil Carmody <phil at dovecot.fi>
  Date:   2016-12-05 (Mon, 05 Dec 2016)

  Changed paths:
    M src/lib/macros.h

  Log Message:
  -----------
  lib/macros.h - protect old compilers from use of modern features

no_sanitize(integer) is not in 3.5 (debian stable's version), but is
documented in 3.9. Exactly when it appeared isn't immediately obvious.

Signed-off-by: Phil Carmody <phil at dovecot.fi>


  Commit: 0c75bec6f78ef541a8426905ab4dd9a5d06fb505
      https://github.com/dovecot/core/commit/0c75bec6f78ef541a8426905ab4dd9a5d06fb505
  Author: Phil Carmody <phil at dovecot.fi>
  Date:   2016-12-06 (Tue, 06 Dec 2016)

  Changed paths:
    M src/plugins/mail-crypt/doveadm-mail-crypt.c

  Log Message:
  -----------
  plugins: mail-crypt - fix static analysis pedantry

Clang cannot see that ret is -1, 0, or 1 upon assigment, and therefore
-1 or 0 upon entry into the if block. Therefore it considers ret==0
not to be a tautology if ret!=-1, and thus falsifiable. It concludes
that bad things can later happen.

The easiest way to persuade it otherwise and make it clear to a human
that things are sane is to make the first error check to be for any
negative ret value, which forces the else path to explicitly imply
ret==0, which means that clause can also be removed. Just removing the
ret==0 doesn't make it so clear to the human that there's no third case.

The final change is simply to mimic the ret==-1 to ret<0 change earlier.

clang's error message:

doveadm-mail-crypt.c:290:14: error: variable 'pubid' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized]
  } else if (ret == 0 &&
       ^~~~~~~~
doveadm-mail-crypt.c:304:35: note: uninitialized use occurs here
   res->id = p_strdup(_ctx->pool, pubid);
                            ^~~~~
doveadm-mail-crypt.c:290:14: note: remove the '&&' if its condition is always true
  } else if (ret == 0 &&
       ^~~~~~~~~~~

Signed-off-by: Phil Carmody <phil at dovecot.fi>


Compare: https://github.com/dovecot/core/compare/18535eaa6c3b...0c75bec6f78e


More information about the dovecot-cvs mailing list