From c0180dc6d961e036c16649a171e81db6541e7d4a Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 16 Aug 2011 16:45:20 +0000 Subject: [PATCH] gcc-4.5 is picky about potential negative indexes. appease it. --- common/Makefile | 7 +------ common/file.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/common/Makefile b/common/Makefile index 2994880..6b4beba 100644 --- a/common/Makefile +++ b/common/Makefile @@ -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 @@ version.c: VERSION .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 --git a/common/file.c b/common/file.c index 5a45477..ff2a2cf 100644 --- a/common/file.c +++ b/common/file.c @@ -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 #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 @@ mopFileGetLX(buf, idx, cnt) 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 @@ mopFileGetBX(buf, idx, cnt) 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);