Closed Bug 68036 Opened 24 years ago Closed 24 years ago

warnings in nsAutoLock.h when I build an optimized build

Categories

(SeaMonkey :: General, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: sspitzer, Assigned: sspitzer)

References

Details

Attachments

(3 files)

here comes a patch, chris or scott, can you review?
I guess the other choice is to #ifdef DEBUG the whole thing, e.g., #ifndef DEBUG PR_ExitMonitor(mMonitor) #else PRStatus status = PR_ExitMonitor(...) NS_ASSERTION(PR_SUCCEEDED(status) #endif I think I'll defer to whatever scc and waterson want to do for this.
What is the warning, and wow does this fix it?
sorry, it's an unused variable warning. in optimized builds, NS_ASSERTION() is a no-op, so we never checked status. Unused variable `PRStatus status'
But with your changes, isn't the variable *still* unused? Seems like doing something like bienvenu suggests, or even hackier: #ifdef DEBUG PRStatus status = #endif PR_EnterMonitor(mMonitor); Would be necessary.
I like waterson's minimal-change #ifdef. /be
no, it isn't unused, because we declare it, and the use it by assigning to it. but agree, I like waterson's trick better. I'll submit a new patch.
Seth, i'm going to be a style whiner: for short (fits in one page or screenful) #ifdef...#endif blocks, the trailing comment after the #endif that restates or summarizes the #if or #ifdef condition tends to be clutter; does it not get in the way here, for you, when reading from the status declaration onward? Also, compiler pedantry alert: a def (or set) is not a use. A use of foo would be a statement of the form bar = foo; or baz(foo); while a set of foo does not use the value. Therefore, assigning to status whether in the initializer or in a separate statement sets a value that is not used. /be
Status: NEW → ASSIGNED
some background: I build with --enable-pedantic, I've found that if I fix all the warnings I find I'm less likely to break the ports. my original patch (declare, then assign) removed the 'unused variable' warning, the patch seemed reasonable, the compiler was quiet, so I was happy. new patch coming...
Hah! A gcc --pedantic bug! I don't care enough to report it. I hope someone does, just to get an uber-pedantic rationale for the bogus difference between an initialized declaration and an uninitialized one followed by an assignment. /be
checked in to the mailnews perf branch, it will come over in the merge...
Thanks for fixing the warning - it is very annoying, because it seems to come up for every 3. file that is compiled optimzed, i.e. thousands of times.
after we land, I'll bring this fix over by hand.
fixed.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
*** Bug 50083 has been marked as a duplicate of this bug. ***
Depends on: 187530
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: