Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/lfs Suppress -Waddress-of-packed-member just for lfs...



details:   https://anonhg.NetBSD.org/src/rev/3372098af511
branches:  trunk
changeset: 938370:3372098af511
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Sep 07 02:28:12 2020 +0000

description:
Suppress -Waddress-of-packed-member just for lfs_accessors.h.

We can remove -Wno-error=address-of-packed-member from various
makefiles now.

diffstat:

 sys/ufs/lfs/lfs_accessors.h |  38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diffs (58 lines):

diff -r 89501c6be6de -r 3372098af511 sys/ufs/lfs/lfs_accessors.h
--- a/sys/ufs/lfs/lfs_accessors.h       Mon Sep 07 02:22:27 2020 +0000
+++ b/sys/ufs/lfs/lfs_accessors.h       Mon Sep 07 02:28:12 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_accessors.h,v 1.49 2020/03/21 06:11:05 riastradh Exp $     */
+/*     $NetBSD: lfs_accessors.h,v 1.50 2020/09/07 02:28:12 riastradh Exp $     */
 
 /*  from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp  */
 /*  from NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp  */
@@ -218,6 +218,31 @@
 
 
 /*
+ * Suppress spurious warnings -- we use
+ *
+ *     type *foo = &obj->member;
+ *
+ * in macros to verify that obj->member has the right type.  When the
+ * object is a packed structure with misaligned members, this causes
+ * some compiles to squeal that taking the address might lead to
+ * undefined behaviour later on -- which is helpful in general, not
+ * relevant in this case, because we don't do anything with foo
+ * afterward; we only declare it to get a type check and then we
+ * discard it.
+ */
+#ifdef __GNUC__
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Waddress-of-packed-member"
+#elif __GNUC_PREREQ__(9,0)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+#endif
+
+
+
+/*
  * directories
  */
 
@@ -1508,5 +1533,16 @@
 #define LFS_NRESERVE(F) (lfs_btofsb((F), (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(F)))
 
 
+/*
+ * Suppress spurious clang warnings
+ */
+#ifdef __GNUC__
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#elif __GNUC_PREREQ__(9,0)
+#pragma GCC diagnostic pop
+#endif
+#endif
+
 
 #endif /* _UFS_LFS_LFS_ACCESSORS_H_ */



Home | Main Index | Thread Index | Old Index