Closed
Bug 795213
Opened 13 years ago
Closed 13 years ago
clang's -Wtautological-constant-out-of-range-compare warns on prnetdb.c
Categories
(NSPR :: NSPR, defect, P2)
NSPR
NSPR
Tracking
(Not tracked)
RESOLVED
FIXED
4.9.3
People
(Reporter: thakis, Assigned: thakis)
Details
Attachments
(1 file)
427 bytes,
patch
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.6 Safari/537.11
Steps to reproduce:
I built nspr with a very recent version of clang (r164143 or newer).
Actual results:
../../third_party/nss/mozilla/nsprpub/pr/src/misc/prnetdb.c:2081:16: error: comparison of constant 3 with expression of type 'PRStatus' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (rv == EAI_BADFLAGS && (hints.ai_flags & AI_ADDRCONFIG)) {
~~ ^ ~~~~~~~~~~~~
1 error generated.
Expected results:
No warning.
The warning is correct, GETADDRINFO(), which is declared further up in the file and returns int, not PRStatus. Since rv is currently PRStatus, it can only be PR_FAILURE = -1 or PR_SUCCESS = 0, never EAI_BADFLAGS = 3.
rv is only used for the return value of GETADDRINFO(), so the fix is to change it to int (see attached patch).
Comment 1•13 years ago
|
||
Thank you for the patch!
Patch checked in on the NSPR trunk (NSPR 4.9.3).
Checking in prnetdb.c;
/cvsroot/mozilla/nsprpub/pr/src/misc/prnetdb.c,v <-- prnetdb.c
new revision: 3.68; previous revision: 3.67
done
Assignee: wtc → thakis
Severity: normal → trivial
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Priority: -- → P2
Resolution: --- → FIXED
Target Milestone: --- → 4.9.3
Updated•13 years ago
|
Attachment #665785 -
Attachment is patch: true
You need to log in
before you can comment on or make changes to this bug.
Description
•