Bug 782614 - Don't return nsresult from main() (rdf/); r=bsmedberg
authorAryeh Gregor <ayg@aryeh.name>
Tue, 07 Aug 2012 20:17:27 +0300
changeset 108211 e4210bdcf836aa69f997cfb04c48093d0b4cc58d
parent 108210 e9e13da6a652b59008b6b0c312b34f608688e070
child 108212 84bf198836853a2b967ada4b2f05ce7b40b1b0b2
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs782614
milestone17.0a1
Bug 782614 - Don't return nsresult from main() (rdf/); r=bsmedberg
rdf/tests/rdfcat/rdfcat.cpp
rdf/tests/rdfpoll/rdfpoll.cpp
rdf/tests/triplescat/triplescat.cpp
--- a/rdf/tests/rdfcat/rdfcat.cpp
+++ b/rdf/tests/rdfcat/rdfcat.cpp
@@ -43,17 +43,17 @@
 static NS_DEFINE_CID(kRDFXMLDataSourceCID,  NS_RDFXMLDATASOURCE_CID);
 
 ////////////////////////////////////////////////////////////////////////
 // Blatantly stolen from netwerk/test/
 #define RETURN_IF_FAILED(rv, step) \
     PR_BEGIN_MACRO \
     if (NS_FAILED(rv)) { \
         printf(">>> %s failed: rv=%x\n", step, rv); \
-        return rv;\
+        return 1;\
     } \
     PR_END_MACRO
 
 ////////////////////////////////////////////////////////////////////////
 
 class ConsoleOutputStreamImpl : public nsIOutputStream
 {
 public:
@@ -129,26 +129,26 @@ main(int argc, char** argv)
     // Okay, this should load the XML file...
     rv = remote->Refresh(false);
     RETURN_IF_FAILED(rv, "datasource refresh");
 
     // Pump events until the load is finished
     nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
     bool done = false;
     while (!done) {
-        NS_ENSURE_STATE(NS_ProcessNextEvent(thread));
+        NS_ENSURE_TRUE(NS_ProcessNextEvent(thread), 1);
         remote->GetLoaded(&done);
     }
 
     // And this should write it back out. The do_QI() on the pointer
     // is a hack to make sure that the new object gets AddRef()-ed.
     nsCOMPtr<nsIOutputStream> out =
         do_QueryInterface(new ConsoleOutputStreamImpl, &rv);
     RETURN_IF_FAILED(rv, "creation of console output stream");
 
     nsCOMPtr<nsIRDFXMLSource> source = do_QueryInterface(ds);
     RETURN_IF_FAILED(rv, "QI to nsIRDFXMLSource");
 
     rv = source->Serialize(out);
     RETURN_IF_FAILED(rv, "datasoure serialization");
 
-    return NS_OK;
+    return 0;
 }
--- a/rdf/tests/rdfpoll/rdfpoll.cpp
+++ b/rdf/tests/rdfpoll/rdfpoll.cpp
@@ -224,46 +224,46 @@ main(int argc, char** argv)
     }
 
     // Create a stream data source and initialize it on argv[1], which
     // is hopefully a "file:" URL. (Actually, we can do _any_ kind of
     // URL, but only a "file:" URL will be written back to disk.)
     nsCOMPtr<nsIRDFDataSource> ds = do_CreateInstance(kRDFXMLDataSourceCID, &rv);
     if (NS_FAILED(rv)) {
         NS_ERROR("unable to create RDF/XML data source");
-        return rv;
+        return 1;
     }
 
     nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(ds);
     if (! remote)
-        return NS_ERROR_UNEXPECTED;
+        return 1;
 
     rv = remote->Init(argv[1]);
     NS_ASSERTION(NS_SUCCEEDED(rv), "unable to initialize data source");
-    if (NS_FAILED(rv)) return rv;
+    if (NS_FAILED(rv)) return 1;
 
     // The do_QI() on the pointer is a hack to make sure that the new
     // object gets AddRef()-ed.
     nsCOMPtr<nsIRDFObserver> observer = do_QueryInterface(new Observer);
     if (! observer)
-        return NS_ERROR_OUT_OF_MEMORY;
+        return 1;
 
     rv = ds->AddObserver(observer);
-    if (NS_FAILED(rv)) return rv;
+    if (NS_FAILED(rv)) return 1;
 
     while (1) {
         // Okay, this should load the XML file...
         rv = remote->Refresh(true);
         NS_ASSERTION(NS_SUCCEEDED(rv), "unable to open datasource");
-        if (NS_FAILED(rv)) return rv;
+        if (NS_FAILED(rv)) return 1;
 
         if (argc <= 2)
             break;
 
         PRInt32 pollinterval = atol(argv[2]);
         if (! pollinterval)
             break;
 
         PR_Sleep(PR_SecondsToInterval(pollinterval));
     }
 
-    return NS_OK;
+    return 0;
 }
--- a/rdf/tests/triplescat/triplescat.cpp
+++ b/rdf/tests/triplescat/triplescat.cpp
@@ -41,17 +41,17 @@
 #include "rdfISerializer.h"
 
 ////////////////////////////////////////////////////////////////////////
 // Blatantly stolen from netwerk/test/
 #define RETURN_IF_FAILED(rv, step) \
     PR_BEGIN_MACRO \
     if (NS_FAILED(rv)) { \
         printf(">>> %s failed: rv=%x\n", step, rv); \
-        return rv;\
+        return 1;\
     } \
     PR_END_MACRO
 
 ////////////////////////////////////////////////////////////////////////
 
 class ConsoleOutputStreamImpl : public nsIOutputStream
 {
 public:
@@ -128,26 +128,26 @@ main(int argc, char** argv)
     // Okay, this should load the XML file...
     rv = remote->Refresh(false);
     RETURN_IF_FAILED(rv, "datasource refresh");
 
     // Pump events until the load is finished
     nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
     bool done = false;
     while (!done) {
-        NS_ENSURE_STATE(NS_ProcessNextEvent(thread));
+        NS_ENSURE_TRUE(NS_ProcessNextEvent(thread), 1);
         remote->GetLoaded(&done);
     }
 
     nsCOMPtr<rdfIDataSource> rdfds = do_QueryInterface(ds, &rv);
     RETURN_IF_FAILED(rv, "QI to rdIDataSource");
     {
         nsCOMPtr<nsIOutputStream> out = new ConsoleOutputStreamImpl();
         nsCOMPtr<rdfISerializer> ser =
             do_CreateInstance(NS_RDF_SERIALIZER "ntriples", &rv);
         RETURN_IF_FAILED(rv, "Creation of NTriples Serializer");
         rv = ser->Serialize(rdfds, out);
         RETURN_IF_FAILED(rv, "Serialization to NTriples");
         out->Close();
     }
 
-    return NS_OK;
+    return 0;
 }