Closed Bug 497832 Opened 15 years ago Closed 15 years ago

compiler spam: bug 374336 added 139 instances of warning "nsIdentityChecking.cpp:418: warning: deprecated conversion from string constant to ‘char*’"

Categories

(Core :: Security: PSM, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: dholbert, Assigned: KaiE)

References

Details

(Whiteboard: [build_warning])

Attachments

(1 file)

As mentioned in bug 374336 comment 42, that bug's patch removed some 'const' keywords and subsequently triggered 139 new g++ compiler warnings, all of the form:
> nsIdentityChecking.cpp:418: warning: deprecated conversion from string constant
to ‘char*’

I'm filing this bug on fixing those warnings, for reduced compiler-spam.
Note that in bug 374336, the 'const' keyword was removed in response to a suggestion in bug 374336 comment 30, because the newly-introduced free() calls expect a 'void*' argument (rather than a 'const void*').

I'm attaching a patch that restores the const keyword, and works around the 'free()' issue by using const_cast to remove the 'const' solely for the 'free' calls.

IMHO this is a cleaner solution than the existing situation. The idea here is this:
 - At the superclass level (for "struct nsMyTrustedEVInfo"), our char-pointers may be pointing to mutable or immutable memory, so it's safest & most correct to make them "const".
 - In the subclass ("class nsMyTrustedEVInfoClass : public nsMyTrustedEVInfo"), we know that all of its instances will have char-pointers directed at mutable (heap-allocated) memory, so we can allow ourselves to explicitly cast away the constness when we need to. (in just one place -- the destructor)
Attachment #382933 - Flags: review?(neil)
I love reducing compiler spam - is there a reason you didn't tag kaie for the review, since he wrote the orginal code, iinm?
Attachment #382933 - Flags: review?(neil) → review+
Comment on attachment 382933 [details] [diff] [review]
fix: restore const-ness, and cast it away for 'free' call

I am not a PSM peer, but I agree that this seems the simplest solution.
Comment on attachment 382933 [details] [diff] [review]
fix: restore const-ness, and cast it away for 'free' call

> is there a reason you didn't tag kaie for the
> review, since he wrote the orginal code, iinm?

No, no good reasons. :) (It was late, and I tagged neil because wrote bug 374336 comment 30 and posted the final copy of the patch on that bug.)

Thanks for the suggestion -- tagging kaie for additional review.
Attachment #382933 - Flags: review?(kaie)
Attachment #382933 - Flags: review?(kaie) → review+
Patch pushed to mozilla-central:
http://hg.mozilla.org/mozilla-central/rev/f7e29a820cc0
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Whiteboard: [build_warning]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: