Closed Bug 392055 Opened 17 years ago Closed 17 years ago

NS_ENSURE_SUCCESS should print out the error code

Categories

(Core :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9beta1

People

(Reporter: sdwilsh, Assigned: sdwilsh)

References

Details

Attachments

(2 files, 5 obsolete files)

As per discussion on irc.
Attached patch v1.0 (obsolete) — Splinter Review
Attachment #276503 - Flags: superreview?(bzbarsky)
Attachment #276503 - Flags: review?(benjamin)
Comment on attachment 276503 [details] [diff] [review]
v1.0

oops - s/%X/%#X/g
Attachment #276503 - Flags: superreview?(bzbarsky) → superreview+
oh fun, NSPR's doesn't support the %#X, so we'll have to manually add it.
Comment on attachment 276503 [details] [diff] [review]
v1.0

1) You need to do this only #ifdef DEBUG...

2) I don't like hardcoding a random dyndns.org address into our codebase... can you file a mozilla IT bug to get the nserror script hosted somewhere in the mozilla.org domain, or else leave out the URL?)
Attachment #276503 - Flags: review?(benjamin) → review-
Attached patch v1.1 (obsolete) — Splinter Review
* No more http link (revist in a followup?)
* Just does |if (NS_FAILED(res)) return ret;| in non-debug builds.
* uses |const char[]| instead of |const char *|
Attachment #276503 - Attachment is obsolete: true
Attachment #276975 - Flags: review?(benjamin)
Attached patch v1.2 (obsolete) — Splinter Review
This one actually compiles.  Sorry about that...
Attachment #276975 - Attachment is obsolete: true
Attachment #277001 - Flags: review?(benjamin)
Attachment #276975 - Flags: review?(benjamin)
Target Milestone: --- → mozilla1.9 M8
Attachment #277001 - Flags: review?(benjamin) → review+
bz isn't around for a while - any suggestions for an sr?
Target Milestone: mozilla1.9 M8 → mozilla1.9 M9
Attachment #277001 - Flags: superreview?(bzbarsky)
Comment on attachment 277001 [details] [diff] [review]
v1.2

>Index: xpcom/glue/nsDebug.h
>+  nsresult __rv = res;                                                    

Add a comment before the macro def that says that you're doing this to avoid evaluating |res| more than once, ok?

>+    char *msg = PR_smprintf(format, __rv, __rv);                          \

Only need one __rv there; the format only has one placeholder.

With those two nits picked, sr+a=bzbarsky
Attachment #277001 - Flags: superreview?(bzbarsky)
Attachment #277001 - Flags: superreview+
Attachment #277001 - Flags: approval1.9+
Attached patch v1.3 (obsolete) — Splinter Review
for checkin
Attachment #277001 - Attachment is obsolete: true
Checking in xpcom/glue/nsDebug.h;
new revision: 1.27; previous revision: 1.26
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Flags: in-testsuite-
Flags: in-litmus-
Resolution: --- → FIXED
Bustage fix on linux

Checking in embedding/browser/gtk/tests/Makefile.in;
new revision: 1.38; previous revision: 1.37
Won't this blow up terribly if the expression |res| happens to contain a % symbol?
In theory, yeah, but I'm not sure that would ever compile.  res and ret should be nsresults for things to compile nicely.
There are examples of function-call expressions inside NS_ENSURE_SUCCESS in our tree...
Backed this out at Shawn's request because of bustage.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Really not sure what is up with this - I figured my fix would have solved the issue :/

/tools/gcc-4.1.1/bin/g++   -fno-rtti -fno-exceptions -Wall -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-long-long -pedantic -fshort-wchar -pthread -pipe  -DDEBUG -D_DEBUG -DDEBUG_cltbld -DTRACING -g -fno-inline -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12   -o TestGtkEmbed TestGtkEmbed.o  -lpthread          -L../../../../dist/bin -L../../../../dist/lib  -lX11   ../../../../dist/lib/libxpcomglue.a -ldl -lm  -L/lib -lgtk-x11-2.0 -latk-1.0 -lgdk-x11-2.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgmodule-2.0 -ldl -lgobject-2.0 -lglib-2.0       
../../../../dist/lib/libxpcomglue.a(nsINIParser.o): In function `nsINIParser::Init(nsILocalFile*)':
/builds/tinderbox/Fx-Trunk-Memtest/Linux_2.6.18-8.el5_Depend/mozilla/obj/xpcom/glue/standalone/nsINIParser.cpp:89: undefined reference to `PR_smprintf'
/builds/tinderbox/Fx-Trunk-Memtest/Linux_2.6.18-8.el5_Depend/mozilla/obj/xpcom/glue/standalone/nsINIParser.cpp:89: undefined reference to `PR_smprintf_free'
collect2: ld returned 1 exit status
gmake[5]: *** [TestGtkEmbed] Error 1
gmake[5]: Leaving directory `/builds/tinderbox/Fx-Trunk-Memtest/Linux_2.6.18-8.el5_Depend/mozilla/obj/embedding/browser/gtk/tests'
Attached patch v1.4 (obsolete) — Splinter Review
OK, I *think* this works...just a bit difficult to test since I don't have linux...

We could also change those NS_ENSURE_SUCCESS's to something else, or doing a #define to disable the debug version in that file...
Attachment #282052 - Attachment is obsolete: true
Attachment #282110 - Flags: superreview?(bzbarsky)
Attachment #282110 - Flags: review?(benjamin)
If the idea of libxpcomglue is that it doesn't depend on NSPR, then it'd be good if it could #define something to turn this enhanced behaviour off. Or, maybe there's already something everyone else defines that xpcomglue doesn't that you could check for.
Hmm.  Jesse's question about '%'. Worries me.  Can we address that somehow?
Nothing really comes to mind as a quick way to deal with it :/
Of course right after I say that I came up with something

Not sure if it'd work, but we could rephrase the expression to something like "Ox#### was returned (NS_ENSURE_SUCCESS(#res, #ret))"

Clearly, that string sucks, but it demonstrates the point.
Comment on attachment 282110 [details] [diff] [review]
v1.4

Yeah, we need to deal better with the standalone glue case. When linking with the standalone glue you don't want to link with NSPR (because the whole point is that you don't know where mozilla/NSPR are yet). So the NSPR gunk here should be disabled if XPCOM_GLUE_AVOID_NSPR is defined (which comes from nsISupportsImpl.h currently).
Attachment #282110 - Flags: superreview?(bzbarsky)
Attachment #282110 - Flags: review?(benjamin)
Attachment #282110 - Flags: review-
Suggestions on what to do then?
So if XPCOM_GLUE_AVOID_NSPR we'll use the simpler NS_WARNING, and if !DEBUG the NS_WARNING evaluates do an empty do/while.
Attachment #282110 - Attachment is obsolete: true
Attachment #282359 - Flags: review?(benjamin)
Attachment #282359 - Flags: review?(benjamin) → review+
Attachment #282359 - Flags: superreview?(bzbarsky)
Comment on attachment 282359 [details] [diff] [review]
Address % in res, add XPCOM_GLUE_AVOID_NSPR check

sr=bzbarsky
Attachment #282359 - Flags: superreview?(bzbarsky) → superreview+
Attachment #282359 - Flags: approval1.9?
Attachment #282359 - Flags: approval1.9? → approval1.9+
Checking in nsDebug.h;
/cvsroot/mozilla/xpcom/glue/nsDebug.h,v  <--  nsDebug.h
new revision: 1.29; previous revision: 1.28
done
Status: REOPENED → RESOLVED
Closed: 17 years ago17 years ago
Resolution: --- → FIXED
Attachment #282755 - Flags: review+
Attachment #282755 - Flags: approval1.9+
Checking in glue/nsISupportsImpl.h;
/cvsroot/mozilla/xpcom/glue/nsISupportsImpl.h,v  <--  nsISupportsImpl.h
new revision: 3.52; previous revision: 3.51
done
Checking in base/nscore.h;
/cvsroot/mozilla/xpcom/base/nscore.h,v  <--  nscore.h
new revision: 1.103; previous revision: 1.102
done
Comment on attachment 282359 [details] [diff] [review]
Address % in res, add XPCOM_GLUE_AVOID_NSPR check

>+#define NS_ENSURE_SUCCESS_BODY(res, ret)                                  \
>+    char *msg = PR_smprintf("NS_ENSURE_SUCCESS(%s, %s) failed with "      \
>+                            "result 0x%X", #res, #ret, __rv);             \
So, this references __rv, instead of passing it as a macro argument...
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: