Module Name:    src
Committed By:   joerg
Date:           Sat Sep 12 19:03:11 UTC 2015

Modified Files:
        src/external/bsd/bind/dist/lib/isc/unix/include/isc: offset.h

Log Message:
Replace arithmetic using undefined behavior with exhaustive list of type
size limits.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
    src/external/bsd/bind/dist/lib/isc/unix/include/isc/offset.h

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

Modified files:

Index: src/external/bsd/bind/dist/lib/isc/unix/include/isc/offset.h
diff -u src/external/bsd/bind/dist/lib/isc/unix/include/isc/offset.h:1.4 src/external/bsd/bind/dist/lib/isc/unix/include/isc/offset.h:1.5
--- src/external/bsd/bind/dist/lib/isc/unix/include/isc/offset.h:1.4	Wed Dec 10 04:38:01 2014
+++ src/external/bsd/bind/dist/lib/isc/unix/include/isc/offset.h	Sat Sep 12 19:03:11 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: offset.h,v 1.4 2014/12/10 04:38:01 christos Exp $	*/
+/*	$NetBSD: offset.h,v 1.5 2015/09/12 19:03:11 joerg Exp $	*/
 
 /*
  * Copyright (C) 2004, 2005, 2007, 2008  Internet Systems Consortium, Inc. ("ISC")
@@ -32,17 +32,12 @@
 
 typedef off_t isc_offset_t;
 
-/*%
- * POSIX says "Additionally, blkcnt_t and off_t are extended signed integral
- * types", so the maximum value is all 1s except for the high bit.
- * This definition is more complex than it really needs to be because it was
- * crafted to keep both the SunOS 5.6 and the HP/UX 11 compilers quiet about
- * integer overflow.  For example, though this is equivalent to just left
- * shifting 1 to the high bit and then inverting the bits, the SunOS compiler
- * is unhappy about shifting a positive "1" to negative in a signed integer.
- */
 #define ISC_OFFSET_MAXIMUM \
-	(~(((off_t)-1 >> (sizeof(off_t) * CHAR_BIT - 1)) \
-		      << (sizeof(off_t) * CHAR_BIT - 1)))
+    (sizeof(off_t) == sizeof(char) ? INT_MAX : \
+     (sizeof(off_t) == sizeof(short) ? SHRT_MAX : \
+      (sizeof(off_t) == sizeof(int) ? INT_MAX : \
+       (sizeof(off_t) == sizeof(long) ? LONG_MAX : \
+        (sizeof(off_t) == sizeof(long long) ? LLONG_MAX : INTMAX_MAX)))))
+
 
 #endif /* ISC_OFFSET_H */

Reply via email to