Module Name:    src
Committed By:   christos
Date:           Tue Oct 12 17:06:26 UTC 2021

Modified Files:
        src/sys/sys: socket.h

Log Message:
Revert previous change because it causes uninitialized warnings with KMSAN.
The previous code was correct. Add a comment explaining why. Requested by chuq@


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/sys/socket.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/sys/socket.h
diff -u src/sys/sys/socket.h:1.129 src/sys/sys/socket.h:1.130
--- src/sys/sys/socket.h:1.129	Sun Nov  4 11:30:29 2018
+++ src/sys/sys/socket.h	Tue Oct 12 13:06:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: socket.h,v 1.129 2018/11/04 16:30:29 christos Exp $	*/
+/*	$NetBSD: socket.h,v 1.130 2021/10/12 17:06:26 christos Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -392,10 +392,13 @@ struct sockcred {
 
 /*
  * Compute size of a sockcred structure with groups.
+ *
+ * The (ngrps - 1) is to account for struct sockcred being defined with
+ * already one group member. This code works correctly when ngroups == 0
+ * because of unsigned arithmetic wrap-around.
  */
 #define	SOCKCREDSIZE(ngrps) \
-	(/*CONSTCOND*/sizeof(struct sockcred) + (sizeof(gid_t) * \
-	    ((ngrps) ? ((ngrps) - 1) : 0)))
+	(/*LINTED*/sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
 #endif /* _NETBSD_SOURCE */
 
 

Reply via email to