* src/system.h (DZA_CONCAT0, DZA_CONCAT): New macros.
(DECLARE_ZEROED_AGGREGATE): New macro.
* src/ls.c (quote_name): Use it.
* src/pathchk.c (portable_chars_only): Use it.
* src/shred.c (main): Use it.
* src/stty.c (main): Use it.
* src/wc.c (SUPPORT_OLD_MBRTOWC): Use it.
reach its end, replacing each non-printable multibyte
character with a single question mark. */
{
- mbstate_t mbstate = { 0, };
+ DECLARE_ZEROED_AGGREGATE (mbstate_t, mbstate);
do
{
wchar_t wc;
if (*invalid)
{
- mbstate_t mbstate = { 0, };
+ DECLARE_ZEROED_AGGREGATE (mbstate_t, mbstate);
size_t charlen = mbrlen (invalid, filelen - validlen, &mbstate);
error (0, 0,
_("nonportable character %s in file name %s"),
main (int argc, char **argv)
{
bool ok = true;
- struct Options flags = { 0, };
+ DECLARE_ZEROED_AGGREGATE (struct Options, flags);
char **file;
int n_files;
int c;
{
/* Initialize to all zeroes so there is no risk memcmp will report a
spurious difference in an uninitialized portion of the structure. */
- struct termios mode = { 0, };
+ DECLARE_ZEROED_AGGREGATE (struct termios, mode);
enum output_type output_type;
int optc;
{
/* Initialize to all zeroes so there is no risk memcmp will report a
spurious difference in an uninitialized portion of the structure. */
- struct termios new_mode = { 0, };
+ DECLARE_ZEROED_AGGREGATE (struct termios, new_mode);
if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode))
error (EXIT_FAILURE, errno, "%s", device_name);
# define IF_LINT(Code) /* empty */
#endif
+/* With -Dlint, avoid warnings from gcc about code like mbstate_t m = {0,};
+ by wasting space on a static variable of the same type, that is thus
+ guaranteed to be initialized to 0, and use that on the RHS. */
+#define DZA_CONCAT0(x,y) x ## y
+#define DZA_CONCAT(x,y) DZA_CONCAT0 (x, y)
+#ifdef lint
+# define DECLARE_ZEROED_AGGREGATE(Type, Var) \
+ static Type DZA_CONCAT (s0_, __LINE__); Type Var = DZA_CONCAT (s0_, __LINE__)
+#else
+# define DECLARE_ZEROED_AGGREGATE(Type, Var) \
+ Type Var = { 0, }
+#endif
+
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(x) /* empty */
{
bool in_word = false;
uintmax_t linepos = 0;
- mbstate_t state = { 0, };
+ DECLARE_ZEROED_AGGREGATE (mbstate_t, state);
bool in_shift = false;
# if SUPPORT_OLD_MBRTOWC
/* Back-up the state before each multibyte character conversion and