summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--include/local-def.h7
-rw-r--r--plugins/media/media-api.c2
-rw-r--r--plugins/radio/radio-api.c2
-rw-r--r--src/rest-api.c20
5 files changed, 9 insertions, 26 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a29646b6..9cb17c17 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,8 +23,8 @@ add_compile_options(-ffunction-sections -fdata-sections)
add_compile_options(-Wl,--gc-sections)
add_compile_options(-fPIC)
-set(CMAKE_C_FLAGS_PROFILING "-g -O0 -pg -Wp,-U_FORTIFY_SOURCE")
-set(CMAKE_C_FLAGS_DEBUG "-g -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
+set(CMAKE_C_FLAGS_PROFILING "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
+set(CMAKE_C_FLAGS_DEBUG "-g -O2 -ggdb -Wp,-U_FORTIFY_SOURCE")
set(CMAKE_C_FLAGS_RELEASE "-g -O2")
set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage")
diff --git a/include/local-def.h b/include/local-def.h
index 0bf0294d..2deb8c04 100644
--- a/include/local-def.h
+++ b/include/local-def.h
@@ -189,12 +189,6 @@ typedef struct {
} AFB_config;
typedef struct {
- int len; // command number within application
- json_object *jtype;
-} AFB_privateApi;
-
-
-typedef struct {
char *msg;
size_t len;
} AFB_redirect_msg;
@@ -208,7 +202,6 @@ typedef struct {
AFB_sessionE session;
AFB_apiCB callback;
char *info;
- AFB_privateApi *privateapi;
} AFB_restapi;
// Plugin definition
diff --git a/plugins/media/media-api.c b/plugins/media/media-api.c
index 308745d5..92e195a9 100644
--- a/plugins/media/media-api.c
+++ b/plugins/media/media-api.c
@@ -103,6 +103,8 @@ STATIC json_object* selecting (AFB_request *request) { /* AFB_SESSION_CHECK */
jresp = json_object_new_object();
json_object_object_add (jresp, "index", json_object_new_string (value));
}
+ else
+ jresp = NULL;
return jresp;
}
diff --git a/plugins/radio/radio-api.c b/plugins/radio/radio-api.c
index 919a875f..ea17eb51 100644
--- a/plugins/radio/radio-api.c
+++ b/plugins/radio/radio-api.c
@@ -176,6 +176,8 @@ STATIC json_object* power (AFB_request *request) { /* AFB_SESSION_CHECK */
jresp = json_object_new_object();
json_object_object_add (jresp, "power", json_object_new_string ("off"));
}
+ else
+ jresp = NULL;
return jresp;
}
diff --git a/src/rest-api.c b/src/rest-api.c
index 756dc6f1..0fa27693 100644
--- a/src/rest-api.c
+++ b/src/rest-api.c
@@ -53,7 +53,7 @@ PUBLIC void endPostRequest(AFB_PostHandle *postHandle) {
STATIC AFB_error callPluginApi(AFB_request *request, int plugidx, void *context) {
json_object *jresp, *jcall, *jreqt;
int idx, status, sig;
- AFB_clientCtx *clientCtx;
+ AFB_clientCtx *clientCtx = NULL;
AFB_plugin *plugin = request->plugins[plugidx];
int signals[]= {SIGALRM, SIGSEGV, SIGFPE, 0};
@@ -368,7 +368,7 @@ PUBLIC int doRestApi(struct MHD_Connection *connection, AFB_session *session, co
AFB_error status;
struct MHD_Response *webResponse;
const char *serialized;
- AFB_request *request;
+ AFB_request *request = NULL;
AFB_PostHandle *postHandle;
AFB_PostRequest postRequest;
int ret;
@@ -539,7 +539,7 @@ ExitOnError:
// Loop on plugins. Check that they have the right type, prepare a JSON object with prefix
STATIC AFB_plugin ** RegisterJsonPlugins(AFB_plugin **plugins) {
- int idx, jdx;
+ int idx;
for (idx = 0; plugins[idx] != NULL; idx++) {
if (plugins[idx]->type != AFB_PLUGIN_JSON) {
@@ -559,20 +559,6 @@ STATIC AFB_plugin ** RegisterJsonPlugins(AFB_plugin **plugins) {
plugins[idx]->jtype = json_object_new_string(plugins[idx]->prefix);
json_object_get(plugins[idx]->jtype); // increase reference count to make it permanent
plugins[idx]->prefixlen = strlen(plugins[idx]->prefix);
-
-
- // Prebuild each API jtype to boost API json response
- for (jdx = 0; plugins[idx]->apis[jdx].name != NULL; jdx++) {
- AFB_privateApi *privateapi = malloc (sizeof (AFB_privateApi));
- if (plugins[idx]->apis[jdx].privateapi != NULL) {
- fprintf (stderr, "WARNING: plugin=%s api=%s private handle should be NULL=%p\n"
- ,plugins[idx]->prefix,plugins[idx]->apis[jdx].name, plugins[idx]->apis[jdx].privateapi);
- }
- privateapi->len = (int)strlen (plugins[idx]->apis[jdx].name);
- privateapi->jtype=json_object_new_string(plugins[idx]->apis[jdx].name);
- json_object_get(privateapi->jtype); // increase reference count to make it permanent
- plugins[idx]->apis[jdx].privateapi = privateapi;
- }
}
}
return (plugins);