Re: error: Support the compiler's control flow analysis better (was: copy-file: Silence gcc warnings)

2023-06-02 Thread Paul Eggert
On 2023-06-02 15:03, Paul Eggert wrote: How about changing this to use __builtin_constant_p instead of __OPTIMIZE__? I.e., use the comma expression if __builtin_constant_p (status), and use the statement expression otherwise. I gave that a shot by installing the attached.From cfd41b3ac199a4f95

Re: error: Support the compiler's control flow analysis better (was: copy-file: Silence gcc warnings)

2023-06-02 Thread Paul Eggert
On 6/2/23 11:10, Bruno Haible wrote: +/* Avoid evaluating STATUS twice, if this is possible without making the + "warning: this statement may fall through" reappear. */ +# if __OPTIMIZE__ +# define __gl_error_call(function, status, ...) \ That means semantics are different when optimizing;

Re: xasprintf and -Wanalyzer-possible-null-argument

2023-06-02 Thread Paul Eggert
On 6/2/23 11:47, Bruno Haible wrote: I'm therefore considering (c). Although it will mean that xasprintf will depend on vasnprintf, even on glibc systems. Sounds like the best way to go, unfortunately.

[PATCH] propername-lite: new module

2023-06-02 Thread Paul Eggert
propername_lite acts like propername_utf8 but needs less infrastructure, e.g., it does not worry about memory allocation. * MODULES.html.sh (func_all_modules): Mention it. * lib/propername.h (proper_name_lite): New decl. * lib/propername-lite.c, modules/propername-lite: New files. * pygnulib/GLEmit

warnings: Add ability to inhibit all warnings

2023-06-02 Thread Bruno Haible
In GNU gettext and other packages, some source files are being compiled twice. It's not useful to see the warnings twice, only once. Therefore a way to inhibit all warnings in a particular compiler invocation is useful. This patch adds this ability to the 'warnings' module. (Creating a separate mo

openmp-init: Silence "no previous prototype for 'openmp_init'" warning

2023-06-02 Thread Bruno Haible
The gcc -Wmissing-prototype / -Wmissing-declaration option is not something I would universally turn on, because sometimes functions are not defined for explicit invocation, but only for backward compatibility. But sometimes it can highlight maintainability problems. In particular, this warning se

term-style-control: Silence -Wshadow warning

2023-06-02 Thread Bruno Haible
The gcc -Wshadow warning option highlights possible maintainability problems. This one seemed worth fixing: libtextstyle/lib/term-style-control.c:740:17: warning: declaration of ‘sig’ shadows a parameter 2023-06-02 Bruno Haible term-style-control: Silence -Wshadow warning. *

pipe-filter-gi, pipe-filter-ii: Silence -Wunused-macro warning

2023-06-02 Thread Bruno Haible
The gcc -Wunused-macros warning option triggers many warnings, too many to regularly look at. But occasionally, it highlights code that can be cleaned up. Such as this one: gettext-tools/gnulib-lib/pipe-filter-aux.c:40: warning: macro "_" is not used 2023-06-02 Bruno Haible pipe-filt

xasprintf and -Wanalyzer-possible-null-argument

2023-06-02 Thread Bruno Haible
Another warning from gcc13's -Wanalyzer-possible-null-argument, seen in GNU gettext, is: gettext-tools/gnulib-lib/javacomp.c:296:20: warning: use of possibly-NULL 'javac' where non-null expected [CWE-690] The problem here is that we use xasprintf with a format string such as "%s -source %s" to

setenv, striconveha: Don't crash if malloc() returns NULL

2023-06-02 Thread Bruno Haible
The gcc 13 -Wanalyzer-possible-null-argument warning option reported a couple of bugs in GNU gettext. No false positives on this one. I can therefore highly recommend it. One of the warnings is: gettext-tools/gnulib-lib/striconveha.c:339:7: warning: use of possibly-NULL 'to_codeset_suffixed' whe

Re: error: Support the compiler's control flow analysis better (was: copy-file: Silence gcc warnings)

2023-06-02 Thread Bruno Haible
Paul Eggert wrote on 2023-05-30: > > +# define error(status, ...) \ > > + ((error)(0, __VA_ARGS__), (status) ? exit (status) : (void)0) > ... > Also, it's better to not evaluate 'status' twice. Not that I think > 'status' should have side effects or even that it does have side effects > in a