Last Comment Bug 771819 - IdentityCryptoService.cpp:547:64: warning: narrowing conversion of ‘((hashAlg == (SECOidTag)4u) ? 20 : 32)’ from ‘int’ to ‘unsigned int’ inside { } [-Werror=narrowing]
: IdentityCryptoService.cpp:547:64: warning: narrowing conversion of ‘((hashAlg...
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Identity (show other bugs)
: Trunk
: x86_64 Linux
: -- normal (vote)
: ---
Assigned To: Daniel Holbert [:dholbert]
:
: Fernando Jiménez Moreno [:ferjm]
Mentors:
: 771851 (view as bug list)
Depends on:
Blocks: buildwarning 753238
  Show dependency treegraph
 
Reported: 2012-07-07 11:02 PDT by Daniel Holbert [:dholbert]
Modified: 2012-07-08 13:57 PDT (History)
4 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
fix (938 bytes, patch)
2012-07-07 11:05 PDT, Daniel Holbert [:dholbert]
no flags Details | Diff | Splinter Review

Description Daniel Holbert [:dholbert] 2012-07-07 11:02:16 PDT
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.
Comment 1 Daniel Holbert [:dholbert] 2012-07-07 11:05:08 PDT
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.)
Comment 2 Matthew N. [:MattN] (PM me if requests are blocking you) 2012-07-07 18:15:09 PDT
*** Bug 771851 has been marked as a duplicate of this bug. ***
Comment 3 Matthew N. [:MattN] (PM me if requests are blocking you) 2012-07-08 13:56:58 PDT
Comment on attachment 639973 [details] [diff] [review]
fix

Fixed by Gavin in https://hg.mozilla.org/mozilla-central/rev/1751d97cc9e4

Note You need to log in before you can comment on or make changes to this bug.