Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/mopd/common gcc-4.5 is picky about potential negati...



details:   https://anonhg.NetBSD.org/src/rev/90e12a991120
branches:  trunk
changeset: 768435:90e12a991120
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Aug 16 16:45:20 2011 +0000

description:
gcc-4.5 is picky about potential negative indexes. appease it.

diffstat:

 usr.sbin/mopd/common/Makefile |   7 +------
 usr.sbin/mopd/common/file.c   |  14 ++++++++++----
 2 files changed, 11 insertions(+), 10 deletions(-)

diffs (60 lines):

diff -r 0162b9624885 -r 90e12a991120 usr.sbin/mopd/common/Makefile
--- a/usr.sbin/mopd/common/Makefile     Tue Aug 16 16:37:07 2011 +0000
+++ b/usr.sbin/mopd/common/Makefile     Tue Aug 16 16:45:20 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.16 2011/06/22 02:49:45 mrg Exp $
+#      $NetBSD: Makefile,v 1.17 2011/08/16 16:45:20 christos Exp $
 
 LIBISPRIVATE=  yes
 
@@ -23,8 +23,3 @@
 .if defined(HAVE_GCC) || defined(HAVE_PCC)
 COPTS.print.c+=        -Wno-pointer-sign
 .endif
-
-# XXX
-.if ${HAVE_GCC} == 45
-COPTS.file.c+= -Wno-error
-.endif
diff -r 0162b9624885 -r 90e12a991120 usr.sbin/mopd/common/file.c
--- a/usr.sbin/mopd/common/file.c       Tue Aug 16 16:37:07 2011 +0000
+++ b/usr.sbin/mopd/common/file.c       Tue Aug 16 16:45:20 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: file.c,v 1.12 2009/10/20 00:51:13 snj Exp $    */
+/*     $NetBSD: file.c,v 1.13 2011/08/16 16:45:20 christos Exp $       */
 
 /*
  * Copyright (c) 1995-96 Mats O Jansson.  All rights reserved.
@@ -26,7 +26,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: file.c,v 1.12 2009/10/20 00:51:13 snj Exp $");
+__RCSID("$NetBSD: file.c,v 1.13 2011/08/16 16:45:20 christos Exp $");
 #endif
 
 #include "os.h"
@@ -115,7 +115,10 @@
        int i;
 
        for (i = 0; i < cnt; i++) {
-               ret = ret*256 + buf[idx+cnt-1-i];
+               int j = idx + cnt - 1 - i;
+               if (j < 0)
+                       abort();
+               ret = ret * 256 + buf[j];
        }
 
        return(ret);
@@ -130,7 +133,10 @@
        int i;
 
        for (i = 0; i < cnt; i++) {
-               ret = ret*256 + buf[idx+i];
+               int j = idx + i;
+               if (j < 0)
+                       abort();
+               ret = ret * 256 + buf[j];
        }
 
        return(ret);



Home | Main Index | Thread Index | Old Index