Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/db/hash Avoid undefined behavior in *BIT macros
details: https://anonhg.NetBSD.org/src/rev/7f48197ee5cd
branches: trunk
changeset: 745030:7f48197ee5cd
user: kamil <kamil%NetBSD.org@localhost>
date: Fri Feb 21 22:04:06 2020 +0000
description:
Avoid undefined behavior in *BIT macros
hash_page.c:792:2, left shift of 1 by 31 places cannot be represented in type 'int'
hash_page.c:855:2, left shift of 1 by 31 places cannot be represented in type 'int'
hash_page.c:779:3, left shift of 1 by 31 places cannot be represented in type 'int'
diffstat:
lib/libc/db/hash/hash.h | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diffs (22 lines):
diff -r c530fbd85c78 -r 7f48197ee5cd lib/libc/db/hash/hash.h
--- a/lib/libc/db/hash/hash.h Fri Feb 21 18:34:37 2020 +0000
+++ b/lib/libc/db/hash/hash.h Fri Feb 21 22:04:06 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hash.h,v 1.16 2015/11/18 18:22:42 christos Exp $ */
+/* $NetBSD: hash.h,v 1.17 2020/02/21 22:04:06 kamil Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -156,9 +156,9 @@
#define BITS_PER_MAP 32
/* Given the address of the beginning of a big map, clear/set the nth bit */
-#define CLRBIT(A, N) ((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP)))
-#define SETBIT(A, N) ((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP)))
-#define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP)))
+#define CLRBIT(A, N) ((A)[(N)/BITS_PER_MAP] &= ~(1U<<((N)%BITS_PER_MAP)))
+#define SETBIT(A, N) ((A)[(N)/BITS_PER_MAP] |= (1U<<((N)%BITS_PER_MAP)))
+#define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1U<<((N)%BITS_PER_MAP)))
/* Overflow management */
/*
Home |
Main Index |
Thread Index |
Old Index