<<< Date Index >>>     <<< Thread Index >>>

Compiler warnings and solutions



I get the following warnings on Linux/x86 (Debian unstable). Some of
them at least should probably be fixed.

crypt.c: In function `crypt_current_time':
crypt.c:66: warning: `%c' yields only last 2 digits of year in some locales

--> Should this be changed?

crypt.c: In function `crypt_valid_passphrase':
crypt.c:110: warning: unused variable `now'

--> I assume that the line

  time_t now = time (NULL);

should be removed.

curs_lib.c: In function `mutt_format_string':
curs_lib.c:598: warning: implicit declaration of function `wcwidth'

--> The wcwidth(3) man page says to #include <wchar.h>, but wcwidth
is declared only if __USE_XOPEN is defined. According to the glibc
documentation (Section 1.3.4 -- "Feature Test Macros"), some macro
should be defined. Using -D_GNU_SOURCE solves the problem. FYI:

  Macro: _GNU_SOURCE
      If you define this macro, everything is included: ISO C89, ISO
      C99, POSIX.1, POSIX.2, BSD, SVID, X/Open, LFS, and GNU
      extensions. In the cases where POSIX.1 conflicts with BSD, the
      POSIX definitions take precedence.

Is there an autoconf test for that?

edit.c:37: warning: string length `623' is greater than the length `509' ISO 
C89 compilers are required to support

--> I don't think this is a problem in practice.

enter.c: In function `my_wcwidth':
enter.c:37: warning: implicit declaration of function `wcwidth'

--> See above.

init.c: In function `mutt_init':
init.c:2252: warning: implicit declaration of function `getsid'

--> Also solved by using -D_GNU_SOURCE.

help.c: In function `print_macro':
help.c:106: warning: implicit declaration of function `wcwidth'

--> See above.

main.c:57: warning: string length `1235' is greater than the length `509' ISO 
C89 compilers are required to support

--> See above. I wonder if splitting the copyright into two (or more)
parts in the C source could ease translations when there are minor
updates.

main.c: In function `mutt_usage':
main.c:94: warning: string length `1491' is greater than the length `509' ISO 
C89 compilers are required to support

--> See above.

pager.c: In function `format_line':
pager.c:1126: warning: implicit declaration of function `wcwidth'

--> See above.

muttlib.c: In function `mutt_buffer_from':
muttlib.c:1335: warning: unused variable `n'

--> Indeed. I assume that it should be removed.

muttlib.c: In function `mutt_match_spam_list':
muttlib.c:1500: warning: dereferencing type-punned pointer will break 
strict-aliasing rules

--> Removing (void**) should solve the problem (is it OK?).

pgpkey.c: In function `pgp_getkeybyaddr':
pgpkey.c:819: warning: `this_key_has_strong' might be used uninitialized in 
this function

--> Probably a normal warning. Shouldn't be changed.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% validated (X)HTML - Acorn / RISC OS / ARM, free software, YP17,
Championnat International des Jeux Mathématiques et Logiques, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA