]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add WARN_UNUSED_RESULT to client init func
authorSam Lang <sam.lang@inktank.com>
Mon, 24 Sep 2012 21:09:43 +0000 (14:09 -0700)
committerSam Lang <sam.lang@inktank.com>
Thu, 27 Sep 2012 21:34:29 +0000 (14:34 -0700)
Adds the gcc attribute (if available) to client init functions to
ensure proper error handling.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
src/client/Client.cc
src/client/Client.h
src/client/SyntheticClient.cc
src/common/compiler_extensions.h

index a99faabd36c1556f45d4e75a87b0519c3e01ccb3..a25a0d553126a6b7bffb2b3eb827ae7b20c7fac0 100644 (file)
@@ -267,7 +267,7 @@ void Client::dump_cache()
   }
 }
 
-int Client::init() 
+int Client::init()
 {
   client_lock.Lock();
   assert(!initialized);
index 316a819fa7ea5fb495f67d3a93a448ef491b53db..02f6e89bc89c1cfa62d2c811efdb5204eddbc813 100644 (file)
@@ -43,6 +43,8 @@ using namespace __gnu_cxx;
 #include "common/Mutex.h"
 #include "common/Timer.h"
 
+#include "common/compiler_extensions.h"
+
 #include "osdc/ObjectCacher.h"
 
 class MDSMap;
@@ -371,7 +373,7 @@ protected:
 
   inodeno_t get_root_ino();
 
-  int init();
+  int init()  WARN_UNUSED_RESULT;
   void shutdown();
 
   // messaging
index 374543ca78579be5a5365d3ff823203c9d4911be..20c3bc02d16aa3a4ac597adf33778d0f8e623b9e 100644 (file)
@@ -318,9 +318,15 @@ string SyntheticClient::get_sarg(int seq)
 int SyntheticClient::run()
 { 
   dout(15) << "initing" << dendl;
-  client->init();
+  int err = client->init();
+  if (err < 0) {
+    char buf[80];
+    dout(0) << "failed to initialize: " << strerror_r(-err, buf, sizeof(buf)) << dendl;
+    return -1;
+  }
+
   dout(15) << "mounting" << dendl;
-  int err = client->mount("");
+  err = client->mount("");
   if (err < 0) {
     char buf[80];
     dout(0) << "failed to mount: " << strerror_r(-err, buf, sizeof(buf)) << dendl;
index 6a4956f86793520a0fd078c875fa8408a8e49236..2fd8f5c2d1367ed343e529c578cbe738ad4721cb 100644 (file)
@@ -23,7 +23,8 @@
 // GCC
 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
 #else
-// some other compiler
+// some other compiler - just make it a no-op
+#define WARN_UNUSED_RESULT
 #endif
 
 #endif