Module Name:    src
Committed By:   riastradh
Date:           Sun Dec 19 12:20:53 UTC 2021

Modified Files:
        src/sys/external/bsd/common/include/linux: overflow.h

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/external/bsd/common/include/linux/overflow.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/common/include/linux/overflow.h
diff -u src/sys/external/bsd/common/include/linux/overflow.h:1.1 src/sys/external/bsd/common/include/linux/overflow.h:1.2
--- src/sys/external/bsd/common/include/linux/overflow.h:1.1	Sun Dec 19 12:20:21 2021
+++ src/sys/external/bsd/common/include/linux/overflow.h	Sun Dec 19 12:20:53 2021
@@ -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 @@ __struct_size(size_t basesize, size_t el
 
 #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));	      \
 })
 

Reply via email to