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)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: thakis, Assigned: thakis)

Details

Attachments

(1 file)

Attached patch nspr.patchSplinter 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).
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
Attachment #665785 - Attachment is patch: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: