From e9297d8283fd8cf80cfc19a397462e8aa392275b Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Tue, 9 Dec 2014 18:31:20 +0000 Subject: [PATCH] mraa.c: check already initialised before anything else in mraa_init Signed-off-by: Brendan Le Foll --- src/mraa.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mraa.c b/src/mraa.c index 6b3a5da..a98045e 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -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