Last Comment Bug 716278 - "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
: "warning: invoking macro NS_ENSURE_TRUE argument 2: empty macro arguments are...
Status: RESOLVED FIXED
:
Product: MailNews Core
Classification: Components
Component: Backend (show other bugs)
: Trunk
: All All
: -- minor (vote)
: Thunderbird 18.0
Assigned To: :aceman
:
:
Mentors:
http://mxr.mozilla.org/mozilla-centra...
Depends on: 788242
Blocks: buildwarning 609210 731262
  Show dependency treegraph
 
Reported: 2012-01-07 13:54 PST by :aceman
Modified: 2012-09-24 15:15 PDT (History)
9 users (show)
bugzillamozillaorg_serge_20140323: in‑testsuite-
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
fix for all warnings except in 2 constructors. (12.62 KB, patch)
2012-01-21 05:42 PST, :aceman
no flags Details | Diff | Splinter Review
patch v2 (23.14 KB, patch)
2012-09-18 13:43 PDT, :aceman
neil: review+
Details | Diff | Splinter Review

Description :aceman 2012-01-07 13:54:58 PST
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
Comment 1 :aceman 2012-01-07 14:25:07 PST
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?
Comment 2 Kyle Huey [:khuey] (Exited; not receiving bugmail, email if necessary) 2012-01-09 03:49:53 PST
I think NS_ENSURE_SUCCESS(rv, /**/); is enough to shut the compiler up.
Comment 3 :aceman 2012-01-09 03:53:17 PST
Oh nice, I can try that.
Comment 4 :aceman 2012-01-09 12:06:30 PST
That didn't work. Gcc is probably smart enough to remove comments before expanding the macro. But ' (void)0 ' worked for me.
Comment 5 :aceman 2012-01-09 12:39:25 PST
That doesn't work in a constructor. Any ideas?
Comment 6 :aceman 2012-01-21 05:42:20 PST
Created attachment 590459 [details] [diff] [review]
fix for all warnings except in 2 constructors.
Comment 7 Mark Banner (:standard8, limited time in Dec) 2012-02-20 13:15:14 PST
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.
Comment 8 neil@parkwaycc.co.uk 2012-02-24 13:57:39 PST
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.
Comment 9 neil@parkwaycc.co.uk 2012-02-24 16:09:38 PST
Hmm... I'd accept semicolons, if they work...
Comment 10 Serge Gautherie (:sgautherie) 2012-03-08 08:05:33 PST
(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
Comment 11 :aceman 2012-04-15 06:08:27 PDT
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?
Comment 12 :aceman 2012-09-17 14:54:52 PDT
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!
Comment 13 :aceman 2012-09-18 13:43:01 PDT
Created attachment 662296 [details] [diff] [review]
patch v2

Neil, would you accept it now that they made the same in m-c?
Comment 14 neil@parkwaycc.co.uk 2012-09-18 14:31:18 PDT
Comment on attachment 662296 [details] [diff] [review]
patch v2

Seems reasonable to me.
Comment 15 Mark Banner (:standard8, limited time in Dec) 2012-09-24 13:37:38 PDT
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.
Comment 16 Ryan VanderMeulen [:RyanVM] 2012-09-24 15:15:09 PDT
https://hg.mozilla.org/comm-central/rev/c3d8cf23a2f2

Note You need to log in before you can comment on or make changes to this bug.