"warning: invoking macro NS_ENSURE_TRUE argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98" compiler warnings in some Mailnews files

RESOLVED FIXED in Thunderbird 18.0

Status

MailNews Core
Backend
--
minor
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: aceman, Assigned: aceman)

Tracking

(Blocks: 1 bug)

Trunk
Thunderbird 18.0
Dependency tree / graph
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

6 years ago
Similar GCC warnings are output for several files in mailnews:

mailnews/base/src/nsMsgMailSession.cpp:625:32: warning: invoking macro NS_ENSURE_TRUE argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgMailSession.cpp:626:52: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgMailSession.cpp:626:52: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgContentPolicy.cpp:548:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgContentPolicy.cpp:548:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgContentPolicy.cpp:552:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgContentPolicy.cpp:552:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgContentPolicy.cpp:555:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO 
mailnews/base/src/nsMsgContentPolicy.cpp:555:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgContentPolicy.cpp:596:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgContentPolicy.cpp:596:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgContentPolicy.cpp:600:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgContentPolicy.cpp:600:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgContentPolicy.cpp:613:27: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/base/src/nsMsgContentPolicy.cpp:613:27: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp:333:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp:333:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/addrbook/src/nsAbAddressCollector.cpp:382:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/addrbook/src/nsAbAddressCollector.cpp:382:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/addrbook/src/nsAbAddressCollector.cpp:385:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/addrbook/src/nsAbAddressCollector.cpp:385:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/addrbook/src/nsAbAddressCollector.cpp:389:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/addrbook/src/nsAbAddressCollector.cpp:389:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/imap/src/nsImapMailFolder.cpp:4257:28: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/imap/src/nsImapMailFolder.cpp:4257:28: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/imap/src/nsImapMailFolder.cpp:4263:30: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/imap/src/nsImapMailFolder.cpp:4263:30: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/imap/src/nsImapMailFolder.cpp:7388:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/imap/src/nsImapMailFolder.cpp:7388:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/imap/src/nsImapMailFolder.cpp:7447:29: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/imap/src/nsImapMailFolder.cpp:7447:29: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/imap/src/nsAutoSyncManager.cpp:361:34: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/imap/src/nsAutoSyncManager.cpp:361:34: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/local/src/nsLocalMailFolder.cpp:2166:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/local/src/nsLocalMailFolder.cpp:2166:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/local/src/nsLocalMailFolder.cpp:2190:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
mailnews/local/src/nsLocalMailFolder.cpp:2190:25: warning: invoking macro NS_ENSURE_SUCCESS argument 2: empty macro arguments are undefined in ISO C90 and ISO C++98
(Assignee)

Comment 1

6 years ago
They are caused by constructs like 'NS_ENSURE_SUCCESS(rv, );' (second argument is empty) inside of void functions. Can this be resolved in some way?
I think NS_ENSURE_SUCCESS(rv, /**/); is enough to shut the compiler up.
(Assignee)

Comment 3

6 years ago
Oh nice, I can try that.
(Assignee)

Comment 4

6 years ago
That didn't work. Gcc is probably smart enough to remove comments before expanding the macro. But ' (void)0 ' worked for me.
(Assignee)

Comment 5

6 years ago
That doesn't work in a constructor. Any ideas?
(Assignee)

Comment 6

6 years ago
Created attachment 590459 [details] [diff] [review]
fix for all warnings except in 2 constructors.
Attachment #590459 - Flags: feedback?(mbanner)
Comment on attachment 590459 [details] [diff] [review]
fix for all warnings except in 2 constructors.

Seems reasonable to me, but I'd like to see what Neil thinks as well.
Attachment #590459 - Flags: feedback?(mbanner) → feedback?(neil)

Comment 8

6 years ago
Comment on attachment 590459 [details] [diff] [review]
fix for all warnings except in 2 constructors.

Sorry, but my personal preference is not to do this.
Attachment #590459 - Flags: feedback?(neil)

Comment 9

6 years ago
Hmm... I'd accept semicolons, if they work...
Blocks: 731262
(In reply to neil@parkwaycc.co.uk from comment #9)
> Hmm... I'd accept semicolons, if they work...

That would expand to "return ;;", which might cause a "not reached" warning or whatever.

The "only" purpose of NS_ENSURE_SUCCESS() is to print a runtime warning.

Then 2 clean solutions should be:
*if the warning is not needed, just use "if NS_FAILED() return;" or the like.
*if the warning is wanted, add a "#define NS_ENSURE_SUCCESS(res)" etc.

***

As well fix mozilla-central too:
http://mxr.mozilla.org/comm-central/search?string=NS_ENSURE_SUCCESS(rv%2C+)%3B&case=on
Severity: trivial → minor
Flags: in-testsuite-
(Assignee)

Updated

6 years ago
Blocks: 609210
(Assignee)

Updated

6 years ago
Blocks: 187528
(Assignee)

Comment 11

5 years ago
See bug 609210 comment 11. Bsmedberg does not want the new single argument macros in Core.

So either we define them in mailnews only (but would need to be in some header file included everywhere) or we just expand the few occurrences we have and open-code them as he is proposing.

Neil, Mark, Serge?
(Assignee)

Updated

5 years ago
Depends on: 788242
(Assignee)

Comment 12

5 years ago
According to bug 788242 this causes build failures in some configs so they were forced to accept the single argument macros into Core.

I'll jump on it when it lands!
(Assignee)

Comment 13

5 years ago
Created attachment 662296 [details] [diff] [review]
patch v2

Neil, would you accept it now that they made the same in m-c?
Attachment #590459 - Attachment is obsolete: true
Attachment #662296 - Flags: review?(neil)
(Assignee)

Updated

5 years ago
Attachment #662296 - Flags: review?(mbanner)
Comment on attachment 662296 [details] [diff] [review]
patch v2

Seems reasonable to me.
Attachment #662296 - Flags: review?(neil) → review+
Comment on attachment 662296 [details] [diff] [review]
patch v2

Review of attachment 662296 [details] [diff] [review]:
-----------------------------------------------------------------

As Neil's reviewed this, I don't need to.
Attachment #662296 - Flags: review?(mbanner)
(Assignee)

Updated

5 years ago
Keywords: checkin-needed
OS: Linux → All
Hardware: x86 → All
https://hg.mozilla.org/comm-central/rev/c3d8cf23a2f2
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 18.0
You need to log in before you can comment on or make changes to this bug.