Closed Bug 896026 Opened 11 years ago Closed 11 years ago

DOMStorageDBThread.cpp:859:9: warning: variable 'usage' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 886184

People

(Reporter: dholbert, Unassigned)

References

(Blocks 1 open bug)

Details

Clang gives me this build warning: { /mozilla-central/dom/src/storage/DOMStorageDBThread.cpp:859:9: warning: variable 'usage' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (exists) { ^~~~~~ /mozilla-central/dom/src/storage/DOMStorageDBThread.cpp:864:23: note: uninitialized use occurs here mUsage->LoadUsage(usage); ^~~~~ /mozilla-central/dom/src/storage/DOMStorageDBThread.cpp:859:5: note: remove the 'if' if its condition is always true if (exists) { ^~~~~~~~~~~~ /mozilla-central/dom/src/storage/DOMStorageDBThread.cpp:858:18: note: initialize the variable 'usage' to silence this warning int64_t usage; ^ = 0 } The code in question is: > 854 bool exists; > 855 rv = stmt->ExecuteStep(&exists); [...] > 858 int64_t usage; > 859 if (exists) { > 860 rv = stmt->GetInt64(0, &usage); > 861 NS_ENSURE_SUCCESS(rv, rv); > 862 } > 863 > 864 mUsage->LoadUsage(usage); > 865 break; Indeed, if 'exists' is false, then we pass a bogus uninitialized value to mUsage->LoadUsage... That seems bad. mayhemer, do you know what we should be doing instead? (If it matters, the clang build that's reporting this to me is version 3.3 (svn revision 176869), the one currently recommended for our ASAN builds.)
Flags: needinfo?(honzab.moz)
Similar to bug 886184: - int64_t usage; + int64_t usage = 0;
Flags: needinfo?(honzab.moz)
It's about the same line of code, actually. Looks like bug 896026 just needs checking in.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.