Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/string Bitwise operations on signed types are well-...



details:   https://anonhg.NetBSD.org/src/rev/ae5b9386db2e
branches:  trunk
changeset: 754059:ae5b9386db2e
user:      apb <apb%NetBSD.org@localhost>
date:      Sun Apr 18 10:51:33 2010 +0000

description:
Bitwise operations on signed types are well-defined if the values
happen to be positive, and indeed the values here were guaranteed
to be positive, but some compilers complained anyway, so convert
the bitwise operations to arithmetic operations.

diffstat:

 lib/libc/string/swab.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (30 lines):

diff -r 28f782b54a80 -r ae5b9386db2e lib/libc/string/swab.c
--- a/lib/libc/string/swab.c    Sun Apr 18 10:22:33 2010 +0000
+++ b/lib/libc/string/swab.c    Sun Apr 18 10:51:33 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: swab.c,v 1.15 2010/04/18 04:54:33 christos Exp $       */
+/*     $NetBSD: swab.c,v 1.16 2010/04/18 10:51:33 apb Exp $    */
 
 /*
  * Copyright (c) 1988, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)swab.c     8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: swab.c,v 1.15 2010/04/18 04:54:33 christos Exp $");
+__RCSID("$NetBSD: swab.c,v 1.16 2010/04/18 10:51:33 apb Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -62,9 +62,9 @@
        tp = (char *)to;
 #define        STEP    temp = *fp++,*tp++ = *fp++,*tp++ = temp
        /* round to multiple of 8 */
-       while ((--len & 07) != 0)
+       while ((--len % 8) != 0)
                STEP;
-       len >>= 3;
+       len /= 8;
        if (len == 0)
                return;
        while (len-- != 0) {



Home | Main Index | Thread Index | Old Index