summaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-config.c
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-05-26 19:55:05 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-12-13 15:02:55 +0100
commitc274ba569a2e500b5eb2c61af5b640cc90be4a93 (patch)
tree91b9507138b0e1dc08b7dedd380cf1939f40c467 /ctl-lib/ctl-config.c
parent7f90ca127eaabe77a60077946ce6bc0742d4d952 (diff)
Prevent lost of config file path when searching
Prevent lost of config file path when searching by keeping only the first file found. Add a warning if multiple files are found. Change-Id: I97262c4dbbc53bb921ef25b9100491cf3e29a056 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'ctl-lib/ctl-config.c')
-rw-r--r--ctl-lib/ctl-config.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ctl-lib/ctl-config.c b/ctl-lib/ctl-config.c
index 9d2bccf..8a0b07f 100644
--- a/ctl-lib/ctl-config.c
+++ b/ctl-lib/ctl-config.c
@@ -77,13 +77,17 @@ char* ConfigSearch(AFB_ApiT apiHandle, json_object *responseJ) {
AFB_ApiError(apiHandle, "CTL-INIT HOOPs invalid JSON entry= %s", json_object_get_string(entryJ));
}
- p_length = strlen(fullpath) + 1 + strlen(filename);
- filepath = malloc(p_length + 1);
- if (index == 0 && filepath) {
+ if (index == 0) {
+ p_length = strlen(fullpath) + 1 + strlen(filename);
+ filepath = malloc(p_length + 1);
+
strncpy(filepath, fullpath, p_length);
strncat(filepath, "/", p_length - strlen(filepath));
strncat(filepath, filename, p_length - strlen(filepath));
}
+ else {
+ AFB_ApiWarning(apiHandle, "CTL-INIT JSON file found but not used : %s/%s", fullpath, filename);
+ }
}
json_object_put(responseJ);