IdentityCryptoService.cpp:547:64: warning: narrowing conversion of ‘((hashAlg == (SECOidTag)4u) ? 20 : 32)’ from ‘int’ to ‘unsigned int’ inside { } [-Werror=narrowing]

RESOLVED FIXED

Status

()

Core
Identity
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

(Blocks: 1 bug)

Trunk
x86_64
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

5 years ago
New GCC 4.7 build warning:

{
toolkit/identity/IdentityCryptoService.cpp:547:64: warning: narrowing conversion of ‘((hashAlg == (SECOidTag)4u) ? 20 : 32)’ from ‘int’ to ‘unsigned int’ inside { } [-Werror=narrowing]
}

For this chunk of code:
http://hg.mozilla.org/integration/mozilla-inbound/diff/88070ff09ccd/toolkit/identity/IdentityCryptoService.cpp#l1.550


>        SECItem hashItem = { siBuffer, hash,
>                             hashAlg == SEC_OID_SHA1 ? 20 : 32 };

Looks like the compiler is treating the result of "bool ? 20 : 32" as a signed int, and then has to jam that into an unsigned int (for some member-var in SECItem)

Simple fix -- just add a "u" suffix to the raw numbers.
(Assignee)

Comment 1

5 years ago
Created attachment 639973 [details] [diff] [review]
fix

(forgot to mention: this warning is only on inbound so far, since the cset hasn't made it over to mozilla-central yet.)
Attachment #639973 - Flags: review?(dolske)
Duplicate of this bug: 771851
Comment on attachment 639973 [details] [diff] [review]
fix

Fixed by Gavin in https://hg.mozilla.org/mozilla-central/rev/1751d97cc9e4
Attachment #639973 - Flags: review?(dolske)
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.