Closed
Bug 520672
Opened 15 years ago
Closed 15 years ago
Fix warnings "warning: overflow in implicit constant conversion" in jpeg/jdmaster.c
Categories
(Core :: Graphics: ImageLib, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: dholbert, Assigned: dholbert)
References
Details
(Whiteboard: [build_warning])
Attachments
(2 files)
73.00 KB,
text/plain
|
Details | |
607 bytes,
patch
|
bholley
:
review+
|
Details | Diff | Splinter Review |
When I'm building mozilla-central in the mozilla/jpeg/ directory, I get a ton of warning spam -- 512 consecutive copies of this warning:
> jdmaster.c:46: warning: overflow in implicit constant conversion
(ranging from lines 46 up to line 80, with multiple warnings per line)
These are because we're storing values from 0x80 up to 0xff (128 to 255) in an array of normal char values, whose range is restricted to -0x80 to 0x7F (-128 to +127).
We should really be using an _unsigned_ char for the storage -- that gets rid of these warnings.
Assignee | ||
Comment 1•15 years ago
|
||
simple fix: add "unsigned" to the array declaration.
Assignee | ||
Comment 2•15 years ago
|
||
I've noticed that some other files in the jpeg directory act like we can't assume unsigned chars -- e.g. this chunk of http://mxr.mozilla.org/mozilla-central/source/jpeg/jmorecfg.h:
64 #ifdef HAVE_UNSIGNED_CHAR
65
66 typedef unsigned char JSAMPLE;
67 #define GETJSAMPLE(value) ((int) (value))
68
69 #else /* not HAVE_UNSIGNED_CHAR */
70
71 typedef char JSAMPLE;
I could use " #ifdef HAVE_UNSIGNED_CHAR" here as well, if desired... I'm not sure if there are any platforms we care about that don't have unsigned char, or if that's just a stale keyword.
Assignee | ||
Updated•15 years ago
|
Attachment #404724 -
Flags: review?(pavlov)
Comment 3•15 years ago
|
||
Comment on attachment 404724 [details] [diff] [review]
fix
stuart's plate is pretty full and he's not in charge of imagelib anymore anyway. Reflagging joe.
Attachment #404724 -
Flags: review?(pavlov) → review?(joe)
Assignee | ||
Comment 4•15 years ago
|
||
Thanks bholley! I knew tagging stuart was probably a silly idea -- I just picked him 'cause I was in a hurry and I noticed he'd reviewed the last patch to touch this file. :)
Updated•15 years ago
|
Attachment #404724 -
Flags: review?(joe) → review+
Comment 5•15 years ago
|
||
Comment on attachment 404724 [details] [diff] [review]
fix
oh, I didn't actually look at the patch. Despite the fact that I'm a peer in libjpeg for name only, it's trivial enough for anyone to review.
r=bholley
Comment 6•15 years ago
|
||
make that r+ contingent on adding this to MOZCHANGES.
Comment 7•15 years ago
|
||
dholbert pointed out that the code he's changing was added in 2007 and MOZCHANGES hasn't been updated since 2003. So nevermind.
grumble grumble stuart grumble...
Assignee | ||
Comment 8•15 years ago
|
||
Also, regarding HAVE_UNSIGNED_CHAR - bholley pointed out that we use "unsigned char" elsewhere (e.g. PRUint8 & PRPackedBool are both typedefs for unsigned char in prtypes.h), so there's not really any point in pretending we accommodate platforms that don't support unsigned char in this particular spot.
Patch pushed:
http://hg.mozilla.org/mozilla-central/rev/dcd991f71c3f
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 9•15 years ago
|
||
Hrm, in retrospect, it'd probably be slightly cleaner to use "JSAMPLE" there instead of "char" (what it was before) *or* "unsigned char" (what this bug changed it to), because JSAMPLE is #typedef'd to unsigned char anyway, and the array size is computed based on sizeof(JSAMPLE).
Probably not a big deal though. I can push another patch to do that if desired.
Comment 10•15 years ago
|
||
if the array size is computed based on JSAMPLE, please do push another patch using it. r=bholley on it.
Assignee | ||
Comment 11•15 years ago
|
||
pushed follow-up from comment 10:
http://hg.mozilla.org/mozilla-central/rev/17fbbaf79612
Assignee | ||
Updated•15 years ago
|
Assignee: nobody → dholbert
Assignee | ||
Updated•15 years ago
|
Whiteboard: [build_warning]
You need to log in
before you can comment on or make changes to this bug.
Description
•