Patchwork parsers: fix 'unsigned expression is always true' warning (issue4142)

login
register
mail settings
Submitter David Soria Parra
Date Jan. 23, 2014, 6:12 p.m.
Message ID <a1293f8acae8a1e3e918.1390500744@davidsp-mbp.fritz.box>
Download mbox | patch
Permalink /patch/3403/
State Superseded
Commit 40f08c31844c69891c25e2849c9aaace3b841a76
Headers show

Comments

David Soria Parra - Jan. 23, 2014, 6:12 p.m.
# HG changeset patch
# User David Soria Parra <davidsp@fb.com>
# Date 1390500506 -3600
#      Thu Jan 23 19:08:26 2014 +0100
# Branch stable
# Node ID a1293f8acae8a1e3e918d32ecc88ed3525cc1b15
# Parent  dbf305f499613e6b833847b72f1eb5424f9331cc
parsers: fix 'unsigned expression is always true' warning (issue4142)

On Mac OS gcc-llvm throws an -Wtautological-compare warning because flen
is defined as an unsigned integer, therefore flen < 0 is always true.

Patch

diff -r dbf305f49961 -r a1293f8acae8 mercurial/parsers.c
--- a/mercurial/parsers.c	Tue Jan 21 14:44:40 2014 -0600
+++ b/mercurial/parsers.c	Thu Jan 23 19:08:26 2014 +0100
@@ -185,7 +185,7 @@ 
 		flen = getbe32(cur + 13);
 		pos += 17;
 		cur += 17;
-		if (flen > len - pos || flen < 0) {
+		if (flen > len - pos) {
 			PyErr_SetString(PyExc_ValueError, "overflow in dirstate");
 			goto quit;
 		}