mraa.c: check already initialised before anything else in mraa_init
authorBrendan Le Foll <brendan.le.foll@intel.com>
Tue, 9 Dec 2014 18:31:20 +0000 (18:31 +0000)
committerBrendan Le Foll <brendan.le.foll@intel.com>
Tue, 9 Dec 2014 18:39:21 +0000 (18:39 +0000)
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
src/mraa.c

index 6b3a5da..a98045e 100644 (file)
@@ -57,6 +57,10 @@ mraa_set_log_level(int level)
 mraa_result_t __attribute__((constructor))
 mraa_init()
 {
+    if (plat != NULL) {
+        return MRAA_ERROR_PLATFORM_ALREADY_INITIALISED;
+    }
+
 #ifdef DEBUG
     setlogmask(LOG_UPTO(LOG_DEBUG));
 #else
@@ -66,9 +70,6 @@ mraa_init()
     openlog("libmraa", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
     syslog(LOG_DEBUG, "libmraa initialised by user %d", getuid());
 
-    if (plat != NULL) {
-        return MRAA_ERROR_PLATFORM_ALREADY_INITIALISED;
-    }
 #ifdef SWIGPYTHON
     // Initialise python threads, this allows use to grab the GIL when we are
     // required to do so