Fix warnings

This commit is contained in:
Suvendhu Hansa 2023-12-15 14:39:40 +00:00 committed by Amin Ben Romdhane
parent ec1fe4c5ad
commit c66b1b1168
8 changed files with 20 additions and 19 deletions

View file

@ -2,7 +2,7 @@ variables:
DEBUG: 'TRUE'
SOURCE_FOLDER: "."
FLAWFINDER_OPTIONS: "-m 4 --error-level=5"
CPPCHECK_OPTIONS: " --enable=information -DBBFDM_ENABLE_DOTSO_PLUGIN -DBBFDM_ENABLE_DOTSO_PLUGIN -DBBF_TR181 -DBBF_VENDOR_IOPSYS --inline-suppr -i test/"
CPPCHECK_OPTIONS: " --enable=warning --enable=performance --enable=portability --enable=information -DBBFDM_ENABLE_DOTSO_PLUGIN -DBBFDM_ENABLE_DOTSO_PLUGIN -DBBF_TR181 -DBBF_VENDOR_IOPSYS --inline-suppr -i test/"
include:
- project: 'iopsys/gitlab-ci-pipeline'

View file

@ -106,6 +106,7 @@ static void bbfdm_cleanup(struct bbfdm_context *u)
blob_buf_free(&u->dm_schema);
/* DotSo Plugin */
free_dotso_plugin(deamon_lib_handle);
deamon_lib_handle = NULL;
/* JSON Plugin */
free_json_plugin();

View file

@ -577,6 +577,7 @@ end:
bbf_global_clean(CLI_DM_ROOT_OBJ);
}
free_dotso_plugin(cli_lib_handle);
cli_lib_handle = NULL;
} else if (strcasecmp(cli_data->in_type, "JSON") == 0) {
if (CLI_DM_ROOT_OBJ) {
bbf_ctx_clean(&cli_data->bbf_ctx);

View file

@ -86,10 +86,8 @@ int load_dotso_plugin(void **lib_handle, const char *file_path,
int free_dotso_plugin(void *lib_handle)
{
if (lib_handle) {
if (lib_handle)
dlclose(lib_handle);
lib_handle = NULL;
}
return 0;
}

View file

@ -859,7 +859,7 @@ static char *get_value_by_reference(struct dmctx *ctx, char *value)
char buf_val[MAX_DM_PATH * 4] = {0};
bool path_resolved = false;
if (DM_STRLEN(value) == 0 || !DM_STRSTR(value, "=="))
if (DM_STRLEN(value) == 0 || !DM_LSTRSTR(value, "=="))
return value;
DM_STRNCPY(buf, value, sizeof(buf));
@ -884,7 +884,7 @@ static char *get_value_by_reference(struct dmctx *ctx, char *value)
if (DM_STRLEN(match_str) == 0)
goto end;
int n = sscanf(match_str, "%[^=]==\"%[^\"]\"", key_name, key_value);
int n = sscanf(match_str, "%255[^=]==\"%255[^\"]\"", key_name, key_value);
if (n != 2)
goto end;
@ -1089,12 +1089,12 @@ static int get_ubus_value(struct dmctx *dmctx, struct dmnode *node)
const char *flag = json_object_get_string(flag_obj);
if (DM_STRCMP(flag, "Reference") == 0) {
if (DM_LSTRCMP(flag, "Reference") == 0) {
data = get_value_by_reference(dmctx, data);
*dm_flags |= DM_FLAG_REFERENCE;
} else if (DM_STRCMP(flag, "Unique") == 0) {
} else if (DM_LSTRCMP(flag, "Unique") == 0) {
*dm_flags |= DM_FLAG_UNIQUE;
} else if (DM_STRCMP(flag, "Linker") == 0) {
} else if (DM_LSTRCMP(flag, "Linker") == 0) {
*dm_flags |= DM_FLAG_LINKER;
}
}
@ -1149,7 +1149,7 @@ static int get_ubus_supported_dm(struct dmctx *dmctx, struct dmnode *node)
char *data = dmjson_get_value(res_obj, 1, "data");
char *type = dmjson_get_value(res_obj, 1, "type");
if (DM_STRCMP(type, "xsd:object") == 0) { //Object
if (DM_LSTRCMP(type, "xsd:object") == 0) { //Object
const char **unique_keys = NULL;
json_object *input_array = dmjson_get_obj(res_obj, 1, "input");
@ -1169,7 +1169,7 @@ static int get_ubus_supported_dm(struct dmctx *dmctx, struct dmnode *node)
}
add_list_parameter(dmctx, dmstrdup(path), dmstrdup(data), "xsd:object", (char *)unique_keys);
} else if (DM_STRCMP(type, "xsd:command") == 0) { //Command Leaf
} else if (DM_LSTRCMP(type, "xsd:command") == 0) { //Command Leaf
operation_args *op = NULL;
op = dmcalloc(1, sizeof(operation_args));
@ -1205,7 +1205,7 @@ static int get_ubus_supported_dm(struct dmctx *dmctx, struct dmnode *node)
}
add_list_parameter(dmctx, dmstrdup(path), (char *)op, "xsd:command", dmstrdup(data));
} else if (DM_STRCMP(type, "xsd:event") == 0) { //Event Leaf
} else if (DM_LSTRCMP(type, "xsd:event") == 0) { //Event Leaf
event_args *ev = NULL;
json_object *input_array = dmjson_get_obj(res_obj, 1, "input");
@ -1400,7 +1400,7 @@ static bool is_reference_parameter(char *ubus_name, char *param_name, json_objec
char *flags_list = dmjson_get_value_array_all(res_obj, ",", 1, "flags");
return DM_STRSTR(flags_list, "Reference") ? true : false;
return DM_LSTRSTR(flags_list, "Reference") ? true : false;
}
static int set_ubus_value(struct dmctx *dmctx, struct dmnode *node)
@ -1628,7 +1628,7 @@ static int get_ubus_reference_value(struct dmctx *dmctx, struct dmnode *node)
const char *flag = json_object_get_string(flag_obj);
if (DM_STRCMP(flag, "Linker") == 0) {
if (DM_LSTRCMP(flag, "Linker") == 0) {
char *data = dmjson_get_value(res_obj, 1, "data");
dmctx->linker = data ? dmstrdup(data) : "";
dmctx->stop = true;
@ -2287,7 +2287,7 @@ static int mparam_set_value(DMPARAM_ARGS)
}
}
if ((leaf->dm_falgs & DM_FLAG_REFERENCE) && !DM_STRSTR(dmctx->in_value, "=>")) {
if ((leaf->dm_falgs & DM_FLAG_REFERENCE) && !DM_LSTRSTR(dmctx->in_value, "=>")) {
get_reference_paramater_value(dmctx, dmctx->in_value, param_value, sizeof(param_value));
} else {
snprintf(param_value, sizeof(param_value), "%s", dmctx->in_value);

View file

@ -957,7 +957,7 @@ char *remove_str_from_str_list(char *str_list, const char *delimitor, const char
for (pch = strtok_r(list, delimitor, &spch); pch != NULL; pch = strtok_r(NULL, delimitor, &spch)) {
if (DM_STRCMP(pch, str) == 0)
if (DM_LSTRCMP(str, pch) == 0)
continue;
pos += snprintf(&res[pos], len + 1 - pos, "%s%s", pch, delimitor);

View file

@ -330,7 +330,7 @@ static void dm_check_dynamic_obj(DMNODE *parent_node, DMOBJ *entryobj, char *ful
DMOBJ *find_entry_obj(DMOBJ *entryobj, char *obj_path)
{
if (!entryobj || !obj_path)
return false;
return NULL;
DMNODE node = {.current_object = ""};
DMOBJ *obj = NULL;
@ -441,9 +441,9 @@ int load_plugins(DMOBJ *dm_entryobj, DM_MAP_VENDOR *dm_VendorExtension[], DM_MAP
snprintf(buf, sizeof(buf), "%s/%s", plugin_path, files[i]);
if (DM_STRSTR(files[i], ".json")) {
if (DM_LSTRSTR(files[i], ".json")) {
load_json_plugins(dm_entryobj, buf);
} else if (DM_STRSTR(files[i], ".so")) {
} else if (DM_LSTRSTR(files[i], ".so")) {
load_dotso_plugins(dm_entryobj, buf);
}

View file

@ -1581,6 +1581,7 @@ static void parse_param(char *object, char *param, json_object *jobj, DMLEAF *pl
struct json_object *type = NULL, *protocols = NULL, *write = NULL, *async = NULL, *flags = NULL;
char full_param[512] = {0};
size_t n_proto, n_flags;
// cppcheck-suppress nullPointerRedundantCheck
char **in_p = NULL, **out_p = NULL, **ev_arg = NULL, **tmp = NULL;
if (!jobj || !pleaf)