Module Name:    src
Committed By:   mrg
Date:           Fri Oct  4 12:12:47 UTC 2019

Modified Files:
        src/common/lib/libc/misc: ubsan.c

Log Message:
workaround a GCC 8 warning:

- code that will be unreachable on platforms with
  sizeof(double) != sizeof(unsigned long) triggered an valid out
  of bounds warning.  avoid the error by using sizeof ul.
- also assert that the sizes are the same if entering here.

both from kamil@.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/misc/ubsan.c

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

Modified files:

Index: src/common/lib/libc/misc/ubsan.c
diff -u src/common/lib/libc/misc/ubsan.c:1.6 src/common/lib/libc/misc/ubsan.c:1.7
--- src/common/lib/libc/misc/ubsan.c:1.6	Mon Jun 17 18:55:37 2019
+++ src/common/lib/libc/misc/ubsan.c	Fri Oct  4 12:12:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ubsan.c,v 1.6 2019/06/17 18:55:37 kamil Exp $	*/
+/*	$NetBSD: ubsan.c,v 1.7 2019/10/04 12:12:47 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -38,9 +38,9 @@
 
 #include <sys/cdefs.h>
 #if defined(_KERNEL)
-__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.6 2019/06/17 18:55:37 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.7 2019/10/04 12:12:47 mrg Exp $");
 #else
-__RCSID("$NetBSD: ubsan.c,v 1.6 2019/06/17 18:55:37 kamil Exp $");
+__RCSID("$NetBSD: ubsan.c,v 1.7 2019/10/04 12:12:47 mrg Exp $");
 #endif
 
 #if defined(_KERNEL)
@@ -1403,7 +1403,8 @@ DeserializeFloatInlined(char *pBuffer, s
 
 	switch (zDeserializeTypeWidth(pType)) {
 	case WIDTH_64:
-		memcpy(&D, &ulNumber, sizeof(double));
+		ASSERT(sizeof(D) == sizeof(ulNumber));
+		memcpy(&D, &ulNumber, sizeof(ulNumber));
 		snprintf(pBuffer, zBUfferLength, "%g", D);
 		break;
 	case WIDTH_32:

Reply via email to