Sat Feb 22 00:38:15 2020 UTC ()
Avoid unportable left shift construct

left shift of 9 by 28 places cannot be represented in type 'int'


(kamil)
diff -r1.6 -r1.7 src/lib/libc/gdtoa/gethex.c

cvs diff -r1.6 -r1.7 src/lib/libc/gdtoa/gethex.c (expand / switch to unified diff)

--- src/lib/libc/gdtoa/gethex.c 2013/04/19 10:41:53 1.6
+++ src/lib/libc/gdtoa/gethex.c 2020/02/22 00:38:14 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: gethex.c,v 1.6 2013/04/19 10:41:53 joerg Exp $ */ 1/* $NetBSD: gethex.c,v 1.7 2020/02/22 00:38:14 kamil Exp $ */
2 2
3/**************************************************************** 3/****************************************************************
4 4
5The author of this software is David M. Gay. 5The author of this software is David M. Gay.
6 6
7Copyright (C) 1998 by Lucent Technologies 7Copyright (C) 1998 by Lucent Technologies
8All Rights Reserved 8All Rights Reserved
9 9
10Permission to use, copy, modify, and distribute this software and 10Permission to use, copy, modify, and distribute this software and
11its documentation for any purpose and without fee is hereby 11its documentation for any purpose and without fee is hereby
12granted, provided that the above copyright notice appear in all 12granted, provided that the above copyright notice appear in all
13copies and that both that the copyright notice and this 13copies and that both that the copyright notice and this
14permission notice and warranty disclaimer appear in supporting 14permission notice and warranty disclaimer appear in supporting
@@ -199,27 +199,27 @@ gethex( CONST char **sp, CONST FPI *fpi, @@ -199,27 +199,27 @@ gethex( CONST char **sp, CONST FPI *fpi,
199 if (*--s1 == decimalpoint[i]) { 199 if (*--s1 == decimalpoint[i]) {
200 s1 -= i; 200 s1 -= i;
201 continue; 201 continue;
202 } 202 }
203#else 203#else
204 if (*--s1 == '.') 204 if (*--s1 == '.')
205 continue; 205 continue;
206#endif 206#endif
207 if (n == ULbits) { 207 if (n == ULbits) {
208 *x++ = L; 208 *x++ = L;
209 L = 0; 209 L = 0;
210 n = 0; 210 n = 0;
211 } 211 }
212 L |= (hexdig[(unsigned char)*s1] & 0x0f) << n; 212 L |= (unsigned int)(hexdig[(unsigned char)*s1] & 0x0f) << n;
213 n += 4; 213 n += 4;
214 } 214 }
215 *x++ = L; 215 *x++ = L;
216 b->wds = n = (int)(x - b->x); 216 b->wds = n = (int)(x - b->x);
217 n = ULbits*n - hi0bits(L); 217 n = ULbits*n - hi0bits(L);
218 nbits = fpi->nbits; 218 nbits = fpi->nbits;
219 lostbits = 0; 219 lostbits = 0;
220 x = b->x; 220 x = b->x;
221 if (n > nbits) { 221 if (n > nbits) {
222 n -= nbits; 222 n -= nbits;
223 if (any_on(b,n)) { 223 if (any_on(b,n)) {
224 lostbits = 1; 224 lostbits = 1;
225 k = n - 1; 225 k = n - 1;