summaryrefslogtreecommitdiff
path: root/src/system.h
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2008-11-30 22:37:42 +0100
committerJim Meyering <meyering@redhat.com>2008-12-01 21:18:52 +0100
commitc58b5daa337b16416be50adfeb3e99e3c009c891 (patch)
treeed91dec7768322eb9f09427036069239b210f562 /src/system.h
parent80325aca2dc20c9f6ac0ac51fdfb2a12aee565eb (diff)
downloadcoreutils-c58b5daa337b16416be50adfeb3e99e3c009c891.tar.xz
avoid warnings about initialization of automatic aggregates
* 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.
Diffstat (limited to 'src/system.h')
-rw-r--r--src/system.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/system.h b/src/system.h
index d51caedf1..21182a47f 100644
--- a/src/system.h
+++ b/src/system.h
@@ -513,6 +513,19 @@ enum
# 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 */