From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18278 invoked from network); 2 May 2021 15:19:05 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 2 May 2021 15:19:05 -0000 Received: (qmail 15857 invoked by uid 550); 2 May 2021 15:19:03 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 15836 invoked from network); 2 May 2021 15:19:03 -0000 Date: Sun, 2 May 2021 11:18:51 -0400 From: Rich Felker To: Vincent Torri Cc: musl@lists.openwall.com Message-ID: <20210502151850.GC2546@brightrain.aerifal.cx> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Warnings in fnmatch implementation On Sun, May 02, 2021 at 02:11:03PM +0200, Vincent Torri wrote: > Hello > > > when compiling fnmatch.c, I have there following warnings : > > > fnmatch.c: In function 'str_next': > fnmatch.c:34:13: warning: comparison of integer expressions of > different signedness: 'char' and 'unsigned int' [-Wsign-compare] > 34 | if (str[0] >= 128U) { > | ^~ > fnmatch.c: In function 'pat_next': > fnmatch.c:87:13: warning: comparison of integer expressions of > different signedness: 'char' and 'unsigned int' [-Wsign-compare] > 87 | if (pat[0] >= 128U) { > | ^~ > fnmatch.c: In function 'match_bracket': > fnmatch.c:129:24: warning: comparison of integer expressions of > different signedness: 'unsigned int' and 'int' [-Wsign-compare] > 129 | if ((unsigned)k-wc <= wc2-wc || > | ^~ > fnmatch.c:130:28: warning: comparison of integer expressions of > different signedness: 'unsigned int' and 'int' [-Wsign-compare] > 130 | (unsigned)kfold-wc <= wc2-wc) > | ^~ > fnmatch.c:150:10: warning: comparison of integer expressions of > different signedness: 'char' and 'unsigned int' [-Wsign-compare] > 150 | if (*p < 128U) { > | ^ > fnmatch.c: In function 'fnmatch_internal': > fnmatch.c:232:13: warning: comparison of integer expressions of > different signedness: 'char' and 'unsigned int' [-Wsign-compare] > 232 | if (s[-1] < 128U || MB_CUR_MAX==1) s--; > | ^ > > All the 128U can be replaced by just 128, and (unsigned) by just (int) They definitely can't be replaced with just 128. Changing them to 128 changes the meaning of the expression and introduces a serious bug (prevents handling of any non-ASCII characters on archs where plain char is a signed type). For example -64 < 128 is true but -64 < 128U is false. Rich