Closed
Bug 424531
Opened 16 years ago
Closed 16 years ago
warning: ‘attrib’ may be used uninitialized in nsMsgSearchTerm::GetTermAsString
Categories
(MailNews Core :: Search, defect)
MailNews Core
Search
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla1.9
People
(Reporter: tuukka.tolvanen, Assigned: mkmelin)
Details
Attachments
(1 file, 1 obsolete file)
2.22 KB,
patch
|
mkmelin
:
review+
mkmelin
:
superreview+
|
Details | Diff | Splinter Review |
In member function ‘virtual nsresult nsMsgSearchTerm::GetTermAsString(nsACString_internal&)’: http://mxr.mozilla.org/mozilla/source/mailnews/base/search/src/nsMsgSearchTerm.cpp#498 warning: ‘attrib’ may be used uninitialized in this function assuming that 511 if (m_attribute > nsMsgSearchAttrib::OtherHeader && m_attribute < nsMsgSearchAttrib::kNumMsgSearchAttributes) // if arbitrary header, use it instead! happens whenever 507 ret = NS_MsgGetStringForAttribute(m_attribute, &attrib); didn't set attrib, this is harmless. It'd be clearer for the reader and the compiler if NS_MsgGetStringForAttribute wasn't uselessly called if its result isn't going to be used.
Assignee | ||
Comment 1•16 years ago
|
||
Assignee: nobody → mkmelin+mozilla
Status: NEW → ASSIGNED
Attachment #312673 -
Flags: superreview?(dmose)
Attachment #312673 -
Flags: review?(dmose)
Assignee | ||
Updated•16 years ago
|
Severity: normal → minor
OS: Linux → All
Hardware: PC → All
Target Milestone: --- → mozilla1.9
Reporter | ||
Comment 2•16 years ago
|
||
turns out this won't shut up the warning -- the warning happens because for NS_MsgGetStringForAttribute ret == NS_OK is unconditional and does not imply that attrib was set. (NS_MsgGetStringForOperator behaves better with operatorStr and the compiler sees that as the implementation is in the same file, and correctly doesn't complain.) I guess the "if arbitrary header" check is coincidental with the case of attrib not being set if nobody's crashed here since 1999, but g++ certainly doesn't find that relation :\
Comment 3•16 years ago
|
||
Comment on attachment 312673 [details] [diff] [review] proposed fix r+sr=dmose
Attachment #312673 -
Flags: superreview?(dmose)
Attachment #312673 -
Flags: superreview+
Attachment #312673 -
Flags: review?(dmose)
Attachment #312673 -
Flags: review+
Assignee | ||
Comment 4•16 years ago
|
||
Duh, I should have paid more attention to the compiler msgs... With this patch the string is set to an empty string if the attrib isn't found, to make the compiler happy.
Attachment #312673 -
Attachment is obsolete: true
Assignee | ||
Comment 5•16 years ago
|
||
Comment on attachment 312917 [details] [diff] [review] proposed fix, v2 Fix the actual compiler warning too.
Attachment #312917 -
Flags: superreview?(dmose)
Attachment #312917 -
Flags: review?(dmose)
Comment 6•16 years ago
|
||
r+sr=dmose. I wouldn't be entirely surprised, though, if some compiler out there wants to generate a warning about direct assignment to a string like that. |**string='\0'| might be safer.
Assignee | ||
Comment 7•16 years ago
|
||
Comment on attachment 312917 [details] [diff] [review] proposed fix, v2 +ing from the comment.
Attachment #312917 -
Flags: superreview?(dmose)
Attachment #312917 -
Flags: superreview+
Attachment #312917 -
Flags: review?(dmose)
Attachment #312917 -
Flags: review+
Assignee | ||
Comment 8•16 years ago
|
||
Fix checked in with the nit (one star though). Checking in mailnews/base/search/src/nsMsgSearchTerm.cpp; /cvsroot/mozilla/mailnews/base/search/src/nsMsgSearchTerm.cpp,v <-- nsMsgSearchTerm.cpp new revision: 1.156; previous revision: 1.155 done
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Updated•16 years ago
|
Product: Core → MailNews Core
You need to log in
before you can comment on or make changes to this bug.
Description
•