From 9d34c8ec51215ebdde429f406e015073818e3d13 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Wed, 16 May 2018 01:23:21 +0200 Subject: Improve reliability and function calls Don't calls two times the same function. As well as avoiding using the function return to get its length Change-Id: I26c37f9a376b2c243ffd7a5ad0ddf935c8b5d0e9 Signed-off-by: Romain Forlot --- ctl-lib/ctl-config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ctl-lib/ctl-config.c b/ctl-lib/ctl-config.c index 5503db1..cac8c75 100644 --- a/ctl-lib/ctl-config.c +++ b/ctl-lib/ctl-config.c @@ -44,8 +44,10 @@ int CtlConfigMagicNew() { json_object* CtlConfigScan(const char *dirList, const char *prefix) { char controlFile [CONTROL_MAXPATH_LEN]; + const char *binderName = GetBinderName(); + strncpy(controlFile, prefix, strlen(prefix)+1); - strncat(controlFile, GetBinderName(), strlen(GetBinderName())); + strncat(controlFile, binderName, strlen(binderName)); // search for default dispatch config file json_object* responseJ = ScanForConfig(dirList, CTL_SCAN_RECURSIVE, controlFile, ".json"); @@ -112,7 +114,7 @@ int CtlConfigExec(AFB_ApiT apiHandle, CtlConfigT *ctlConfig) { // load static LUA utilities LuaConfigExec(apiHandle); #endif - + // Loop on every section and process config int errcount=0; for (int idx = 0; ctlConfig->sections[idx].key != NULL; idx++) { -- cgit 1.2.3-korg