Source-Changes-HG archive

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

[src/trunk]: src/sys/external/bsd/common/include/linux linux: Allow non-VLA s...



details:   https://anonhg.NetBSD.org/src/rev/286e43cee1b2
branches:  trunk
changeset: 1028866:286e43cee1b2
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 12:20:53 2021 +0000

description:
linux: Allow non-VLA structs in struct_size.

Upstream sometimes uses

struct foo {
        int x;
        short y[1];
};

instead of  short y[]  with struct_size.

diffstat:

 sys/external/bsd/common/include/linux/overflow.h |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (18 lines):

diff -r f8b987e24f3b -r 286e43cee1b2 sys/external/bsd/common/include/linux/overflow.h
--- a/sys/external/bsd/common/include/linux/overflow.h  Sun Dec 19 12:20:46 2021 +0000
+++ b/sys/external/bsd/common/include/linux/overflow.h  Sun Dec 19 12:20:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: overflow.h,v 1.1 2021/12/19 12:20:21 riastradh Exp $   */
+/*     $NetBSD: overflow.h,v 1.2 2021/12/19 12:20:53 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
 
 #define        struct_size(p, member, n)                                             \
 ({                                                                           \
-       CTASSERT(sizeof(*(p)) == offsetof(__typeof__(*(p)), member));         \
+       CTASSERT(sizeof(*(p)) >= offsetof(__typeof__(*(p)), member));         \
        __struct_size(sizeof(*(p)), sizeof((p)->member[0]), (n));             \
 })
 



Home | Main Index | Thread Index | Old Index