changeset 12293:9eca5d75491d

fnmatch: avoid compiler warning cond ? (size_t) : (char* - char* + 1) varies in signedness, but using 1LU coerces the latter half to unsigned math. * lib/fnmatch_loop.c (NEW_PATTERN): Coerce addition to unsigned, to silence compiler warning about mismatch signedness in ?:. Reported by Robert Millan. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Sat, 14 Nov 2009 15:25:49 -0700
parents 3fd0a39c1a0b
children bae59d8f043a
files ChangeLog lib/fnmatch_loop.c
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-11-14  Eric Blake  <ebb9@byu.net>
 
+	fnmatch: avoid compiler warning
+	* lib/fnmatch_loop.c (NEW_PATTERN): Coerce addition to unsigned,
+	to silence compiler warning about mismatch signedness in ?:.
+	Reported by Robert Millan.
+
 	intprops: add double-inclusion guard
 	* lib/intprops.h: Allow idempotent includes.
 	Suggested by Bruce Korb.
--- a/lib/fnmatch_loop.c
+++ b/lib/fnmatch_loop.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006
+/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2009
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -1071,7 +1071,7 @@
 									      \
 	    plen = (opt == L_('?') || opt == L_('@')			      \
 		    ? pattern_len					      \
-		    : p - startp + 1);					      \
+		    : p - startp + 1UL);				      \
 	    plensize = plen * sizeof (CHAR);				      \
 	    newpsize = offsetof (struct patternlist, str) + plensize;	      \
 	    if ((size_t) -1 / sizeof (CHAR) < plen			      \