From a86ea846c82189cec7b2fad8679377d5475211c1 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Sat, 14 Nov 2009 15:25:49 -0700 Subject: [PATCH] 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 --- ChangeLog | 5 +++++ lib/fnmatch_loop.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4ff76e75b..a241c5b12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-11-14 Eric Blake + 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. diff --git a/lib/fnmatch_loop.c b/lib/fnmatch_loop.c index d1008c247..ad58bb266 100644 --- 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 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end, \ 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 \ -- 2.11.0