Closed Bug 94685 Opened 25 years ago Closed 25 years ago

Warnings irk me

Categories

(NSS :: Libraries, defect)

x86
Windows NT
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: timeless, Assigned: wtc)

Details

Attachments

(10 files)

Based on the NSS windows tinderbox, i have sorted the issues based on warning type.
Attached file () must return a value —
Attached patch Fix DLI, MRV, PM — — Splinter Review
r=dbradley
Timeless, thank you very much for taking the time to file this bug report on compiler warnings in NSS, complete with links to the source files. I did not notice that you attached a patch and had been wondering what the r=dbradley was for. I just went through the attachments again and spotted a patch (attach_id=45369) titled "Fix DLI, MRV, PM". I will review it and check it in.
Status: NEW → ASSIGNED
Timeless, I checked in your patch on the trunk of NSS. I did not check in your change for cmsdigest.c because the (void *) cast for the argument to PORT_Free is not necessary.
OK, I looked closer and found that your (void *) cast is intended to cast away to 'const'. I will think about this.
I think Microsoft Visual C++ 6.0 incorrectly warns about the following: ------------------ #include <stdlib.h> int main() { const char **p = NULL; free(p); return 0; } ------------------ When I compile it with -W4, the compiler gives the following warnings: foo.c(6) : warning C4090: 'function' : different 'const' qualifiers foo.c(6) : warning C4022: 'free' : pointer mismatch for actual parameter 1 But 'p' is not const. 'p' is a non-const pointer pointing at const char. Brendan, what do you think?
Correction: my last sentence should read: But 'p' is not pointing to const data. 'p' is pointing to a pointer that points at const data.
Timeless: I've reviewed all the compiler warnings you found and fixed the serious ones and the simple ones. I didn't fix the 'const' warnings whose fix requires touching a lot of functions (the infamous 'const' propagation effect). However the simple 'const' warnings have all been fixed. I didn't fix the "conversion from () to (), possible loss of data" and "integral size mismatch in argument; conversion supplied" warnings because they are either not serious (the "conversion supplied" ones) or not simple to fix (adding a cast merely shuts up the compiler without addressing the "possible loss of data" issue). If you are satisfied with what I have done, I'll close the bug. Otherwise, I will leave it open but will assign a low priority to fixing the rest of the warnings. Again, thank you for this bug report. It is much easier than sifting through the build logs.
I'm sure that warning is useless -- I detest all warnings about pointer const mismatch when passing a pointer by value to free. Still, 'different const qualifiers' seems to me a true observation by MSVC of the type types: free takes void*, you're passing const char**, and the types do indeed have different const qualifiers. free is going to scribble on the memory as it goes back to the malloc heap (for debug builds, all over it; otherwise, perhaps to store backward list linkage in the first word). It's true that you can store that first word too, via *p = "hello"; or some such. So the const difference is meaningless as far as free is concerned. So MSVC is whining about a distinction without a practical difference. That makes for needless warning noise to precious warning signal, which we ignore at our peril. File a bug via msdn? And don't hold your breath for a fix. /be
If p is declared this way, const char *p = NULL; then I agree free(p) should get a warning. This is because it is illegal to say: *p = '\0'; But if p is declared like this: const char **p = NULL; then p is not pointing to const data and free(p) should not get a warning. This is because it is legal to say: *p = NULL;
brendan: never mind. I read your comments again and now I understand what you said.
wtc: right, we're in agreement -- but I still think that if free could be known by the compiler as the standard free (the one that goes with malloc), no warning of any const difference between actual and formal parameter types should be given -- no such warning is helpful in the real world, it seems to me. /be
Well, I'd like to fix some of the things after the current fix, I think () unreferenced label, unless you already fixed that. If that's fixed then i think we can close this.
Timeless: I should have been more clear. I reviewed not only your patch but also all the compiler warnings you listed. I fixed the more serious warnings and the warnings that are easy to fix, including all the unreferenced labels.
ok
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: