mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-03-14 21:20:28 +01:00
Fix static code warnings
This commit is contained in:
parent
e303eb6130
commit
d522d8011b
12 changed files with 63 additions and 48 deletions
|
|
@ -12,7 +12,7 @@ stages:
|
|||
variables:
|
||||
DEBUG: 'TRUE'
|
||||
SOURCE_FOLDER: "."
|
||||
RUN_CPPCHECK: "cppcheck --enable=all --error-exitcode=1 --suppress=unusedFunction --suppress=unreadVariable --suppress=knownConditionTrueFalse --suppress=duplicateCondition ."
|
||||
RUN_CPPCHECK: "cppcheck --enable=all --error-exitcode=1 -DBBF_VENDOR_IOPSYS -DBBF_VENDOR_OPENWRT --include=/usr/local/include/json-c/json.h -I./include/ --suppress=unusedFunction --suppress=unreadVariable --suppress=knownConditionTrueFalse --suppress=nullPointerRedundantCheck --suppress=unknownMacro --suppress=internalAstError"
|
||||
|
||||
run_unit_test:
|
||||
stage: unit_test
|
||||
|
|
@ -122,10 +122,10 @@ doxygen:
|
|||
|
||||
run_uspd:
|
||||
stage: uspd
|
||||
inherit:
|
||||
variables: false
|
||||
variables:
|
||||
UPSTREAM_BBF_SHA: $CI_COMMIT_SHA
|
||||
SOURCE_FOLDER: "src"
|
||||
RUN_CPPCHECK: "cppcheck --enable=all --error-exitcode=1 --suppress=unusedFunction ./src"
|
||||
allow_failure: false
|
||||
trigger:
|
||||
project: iopsys/uspd
|
||||
|
|
|
|||
|
|
@ -984,24 +984,25 @@ static int fill_string_arguments(struct json_object *json_obj, int *min_length,
|
|||
}
|
||||
|
||||
json_object_object_get_ex(json_obj, "enumerations", &enum_obj);
|
||||
if (enum_obj && json_object_get_type(enum_obj) == json_type_array) {
|
||||
int enum_len = (enum_obj) ? json_object_array_length(enum_obj) + 1 : 1;
|
||||
|
||||
for (int i = 0; i < enum_len - 1; i++) {
|
||||
struct json_object *enum_val = NULL;
|
||||
|
||||
if ((enum_val = json_object_array_get_idx(enum_obj, i)) == NULL)
|
||||
return -1;
|
||||
|
||||
enumeration[i] = json_object_get_string(enum_val);
|
||||
|
||||
}
|
||||
enumeration[enum_len - 1] = NULL;
|
||||
|
||||
if (enum_obj && json_object_get_type(enum_obj) != json_type_array) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int enum_len = (enum_obj) ? json_object_array_length(enum_obj) + 1 : 1;
|
||||
for (int i = 0; i < enum_len - 1; i++) {
|
||||
struct json_object *enum_val = NULL;
|
||||
|
||||
if ((enum_val = json_object_array_get_idx(enum_obj, i)) == NULL)
|
||||
return -1;
|
||||
|
||||
enumeration[i] = json_object_get_string(enum_val);
|
||||
|
||||
}
|
||||
enumeration[enum_len - 1] = NULL;
|
||||
|
||||
|
||||
json_object_object_get_ex(json_obj, "pattern", &pattern_obj);
|
||||
if (pattern_obj && json_object_get_type(pattern_obj) == json_type_array) {
|
||||
if ((pattern_obj != NULL) && json_object_get_type(pattern_obj) == json_type_array) {
|
||||
int pattern_len = (pattern_obj) ? json_object_array_length(pattern_obj) + 1 : 1;
|
||||
|
||||
for (int i = 0; i < pattern_len - 1; i++) {
|
||||
|
|
@ -1146,7 +1147,7 @@ static int dm_validate_value(json_object *json_obj, char *value)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void uci_set_value(json_object *mapping_obj, int json_version, char *refparam, struct dmctx *ctx, void *data, char *instance, char *value)
|
||||
static void uci_set_value(json_object *mapping_obj, int json_version, char *refparam, struct dmctx *ctx, const void *data, char *instance, char *value)
|
||||
{
|
||||
struct json_object *uci_obj = NULL;
|
||||
struct json_object *file = NULL;
|
||||
|
|
@ -1347,7 +1348,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, *version = NULL;;
|
||||
char full_param[512] = {0};
|
||||
size_t n_proto;
|
||||
char **in_p = NULL, **out_p = NULL, **ev_arg = NULL;
|
||||
char **in_p = NULL, **out_p = NULL, **ev_arg = NULL, **tmp = NULL;
|
||||
|
||||
if (!jobj || !pleaf)
|
||||
return;
|
||||
|
|
@ -1394,26 +1395,33 @@ static void parse_param(char *object, char *param, json_object *jobj, DMLEAF *pl
|
|||
//getvalue
|
||||
if (pleaf[i].type == DMT_EVENT) {
|
||||
int param_count = 0;
|
||||
json_object_object_foreach(jobj, param, val) {
|
||||
if (valid_event_param(param)) {
|
||||
json_object_object_foreach(jobj, key, val) {
|
||||
if (valid_event_param(key)) {
|
||||
param_count++;
|
||||
if (!ev_arg) {
|
||||
ev_arg = malloc(sizeof(char*) * param_count);
|
||||
if (!ev_arg)
|
||||
break;
|
||||
} else {
|
||||
ev_arg = realloc(ev_arg, sizeof(char*) * param_count);
|
||||
if (!ev_arg)
|
||||
tmp = realloc(ev_arg, sizeof(char*) * param_count);
|
||||
if (tmp == NULL) {
|
||||
FREE(ev_arg);
|
||||
break;
|
||||
}
|
||||
ev_arg = tmp;
|
||||
}
|
||||
|
||||
ev_arg[param_count - 1] = dm_dynamic_strdup(&json_memhead, param);
|
||||
ev_arg[param_count - 1] = dm_dynamic_strdup(&json_memhead, key);
|
||||
}
|
||||
}
|
||||
|
||||
if (ev_arg) {
|
||||
param_count++;
|
||||
ev_arg = realloc(ev_arg, sizeof(char*) * param_count);
|
||||
tmp = realloc(ev_arg, sizeof(char*) * param_count);
|
||||
if (tmp == NULL) {
|
||||
FREE(ev_arg);
|
||||
}
|
||||
ev_arg = tmp;
|
||||
ev_arg[param_count - 1] = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ static int browseServicesVoiceServiceDECTPortableInst(struct dmctx *dmctx, DMNOD
|
|||
static int get_ServicesVoiceServiceDECT_BaseNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
size_t num = 0;
|
||||
json_object *res, *base;
|
||||
json_object *res = NULL, *base;
|
||||
|
||||
dmubus_call("dect", "status", UBUS_ARGS{0}, 0, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
|
|
@ -96,7 +96,7 @@ static int get_ServicesVoiceServiceDECT_BaseNumberOfEntries(char *refparam, stru
|
|||
static int get_ServicesVoiceServiceDECT_PortableNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
size_t num = 0;
|
||||
json_object *res, *handsets;
|
||||
json_object *res = NULL, *handsets;
|
||||
|
||||
dmubus_call("dect", "status", UBUS_ARGS{0}, 0, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
|
|
|
|||
|
|
@ -2123,7 +2123,8 @@ static int get_BridgingBridgePort_Enable(char *refparam, struct dmctx *ctx, void
|
|||
// network config => device sections
|
||||
|
||||
json_object *res = NULL;
|
||||
dmubus_call("network.device", "status", UBUS_ARGS{{"name", device ? device : "", String}}, 1, &res);
|
||||
char *dev = device ? device : "";
|
||||
dmubus_call("network.device", "status", UBUS_ARGS{{"name", dev, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
char *up = dmjson_get_value(res, 1, "up");
|
||||
*value = up ? "1" :"0";
|
||||
|
|
|
|||
|
|
@ -714,7 +714,7 @@ static int get_DeviceInfoFirmwareImage_Status(char *refparam, struct dmctx *ctx,
|
|||
/*#Device.DeviceInfo.MemoryStatus.Total!UBUS:router.system/memory//total*/
|
||||
static int get_memory_status_total(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res;
|
||||
json_object *res = NULL;
|
||||
dmubus_call("router.system", "memory", UBUS_ARGS{{}}, 0, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 1, "total");
|
||||
|
|
@ -724,7 +724,7 @@ static int get_memory_status_total(char* refparam, struct dmctx *ctx, void *data
|
|||
/*#Device.DeviceInfo.MemoryStatus.Free!UBUS:router.system/memory//free*/
|
||||
static int get_memory_status_free(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res;
|
||||
json_object *res = NULL;
|
||||
dmubus_call("router.system", "memory", UBUS_ARGS{{}}, 0, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 1, "free");
|
||||
|
|
@ -734,7 +734,7 @@ static int get_memory_status_free(char* refparam, struct dmctx *ctx, void *data,
|
|||
/*#Device.DeviceInfo.ProcessStatus.CPUUsage!UBUS:router.system/process//cpu_usage*/
|
||||
static int get_process_cpu_usage(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res;
|
||||
json_object *res = NULL;
|
||||
dmubus_call("router.system", "process", UBUS_ARGS{{}}, 0, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 1, "cpu_usage");
|
||||
|
|
|
|||
|
|
@ -1324,7 +1324,8 @@ static int get_IPInterface_Name(char *refparam, struct dmctx *ctx, void *data, c
|
|||
/*#Device.IP.Interface.{i}.LastChange!UBUS:network.interface/status/interface,@Name/uptime*/
|
||||
static int get_IPInterface_LastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res;
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name((struct uci_section *)data), String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 1, "uptime");
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ static int set_management_server_periodic_inform_time(char *refparam, struct dmc
|
|||
|
||||
static int network_get_ipaddr(char *iface, int ipver, char **value)
|
||||
{
|
||||
json_object *res, *jobj;
|
||||
json_object *res = NULL, *jobj = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", iface, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ static int get_PPPInterface_LastChange(char *refparam, struct dmctx *ctx, void *
|
|||
struct uci_section *ppp_s = ((struct ppp_args *)data)->iface_s;
|
||||
|
||||
if (ppp_s) {
|
||||
json_object *res;
|
||||
json_object *res = NULL;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(ppp_s), String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
|
|
|
|||
|
|
@ -720,7 +720,7 @@ int set_mcasts_filter_enable(char *refparam, struct dmctx *ctx, void *data, char
|
|||
int get_mcasts_filter_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *d_sec = NULL;
|
||||
char *f_inst, *ip_addr;
|
||||
char *f_inst, *ip_addr = NULL;
|
||||
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter",
|
||||
"section_name", section_name((struct uci_section *)data), d_sec) {
|
||||
|
|
@ -731,7 +731,7 @@ int get_mcasts_filter_address(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
}
|
||||
}
|
||||
|
||||
if (ip_addr[0] == '\0') {
|
||||
if (DM_STRLEN(ip_addr) == 0) {
|
||||
*value = "";
|
||||
} else {
|
||||
*value = dmstrdup(ip_addr);
|
||||
|
|
@ -1784,7 +1784,7 @@ static int set_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da
|
|||
static int get_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *igmpp_s = NULL;
|
||||
char *igmpp_ifname, *f_inst;
|
||||
char *igmpp_ifname = NULL, *f_inst = NULL;
|
||||
char sec_name[16] = {0};
|
||||
int found = 0;
|
||||
|
||||
|
|
@ -1797,7 +1797,7 @@ static int get_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da
|
|||
}
|
||||
}
|
||||
|
||||
if ((found == 0) || (igmpp_ifname[0] == '\0')) {
|
||||
if ((found == 0) || DM_STRLEN(igmpp_ifname) == 0) {
|
||||
*value = "";
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
4
dmtree/vendor/iopsys/tr181/x_iopsys_eu_mld.c
vendored
4
dmtree/vendor/iopsys/tr181/x_iopsys_eu_mld.c
vendored
|
|
@ -500,7 +500,7 @@ static int set_mldp_interface_iface(char *refparam, struct dmctx *ctx, void *dat
|
|||
static int get_mldp_interface_iface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *mldp_s = NULL;
|
||||
char *mldp_ifname, *f_inst;
|
||||
char *mldp_ifname = NULL, *f_inst;
|
||||
char sec_name[16] = {0};
|
||||
int found = 0;
|
||||
|
||||
|
|
@ -513,7 +513,7 @@ static int get_mldp_interface_iface(char *refparam, struct dmctx *ctx, void *dat
|
|||
}
|
||||
}
|
||||
|
||||
if ((found == 0) || (mldp_ifname[0] == '\0')) {
|
||||
if ((found == 0) || DM_STRLEN(mldp_ifname) == 0) {
|
||||
*value = "";
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,11 +215,12 @@ struct dmubus_event_data {
|
|||
static void dmubus_receive_event(struct ubus_context *ctx, struct ubus_event_handler *ev,
|
||||
const char *type, struct blob_attr *msg)
|
||||
{
|
||||
struct dmubus_event_data *data = container_of(ev, struct dmubus_event_data, ev);
|
||||
struct dmubus_event_data *data;
|
||||
|
||||
if (!msg)
|
||||
if (!msg || !ev)
|
||||
return;
|
||||
|
||||
data = container_of(ev, struct dmubus_event_data, ev);
|
||||
if (validate_blob_message(data->ev_msg, msg) == true) {
|
||||
uloop_end();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -859,18 +859,20 @@ int dynamicdm_init(struct ubus_context *ctx, char *ubus_name, DMOBJ *entry)
|
|||
int dynamicdm_init_plugin_object(struct ubus_context *ctx, char *ubus_name, DM_MAP_OBJ *entry)
|
||||
{
|
||||
int i;
|
||||
DMOBJ *tEntryObj = NULL;
|
||||
DMOBJ *tEntryObj = NULL, *tmp = NULL;
|
||||
|
||||
if (!entry)
|
||||
return -1;
|
||||
|
||||
for (i = 0; entry[i].path != NULL; i++) {
|
||||
tEntryObj = (DMOBJ*)realloc(tEntryObj, sizeof(DMOBJ) * (i+1));
|
||||
if (!tEntryObj) {
|
||||
tmp = (DMOBJ*)realloc(tEntryObj, sizeof(DMOBJ) * (i+1));
|
||||
if (tmp == NULL) {
|
||||
FREE(tEntryObj);
|
||||
printf("No Memory exists\n\r");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tEntryObj = tmp;
|
||||
memset(&tEntryObj[i], 0, sizeof(DMOBJ));
|
||||
|
||||
tEntryObj[i].obj = entry[i].path;
|
||||
|
|
@ -881,12 +883,14 @@ int dynamicdm_init_plugin_object(struct ubus_context *ctx, char *ubus_name, DM_M
|
|||
}
|
||||
|
||||
/* Make the last empty entry */
|
||||
tEntryObj = (DMOBJ*)realloc(tEntryObj, sizeof(DMOBJ) * (i+1));
|
||||
if (!tEntryObj) {
|
||||
tmp = (DMOBJ*)realloc(tEntryObj, sizeof(DMOBJ) * (i+1));
|
||||
if (tmp == NULL) {
|
||||
FREE(tEntryObj);
|
||||
printf("No Memory exists\n\r");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tEntryObj = tmp;
|
||||
memset(&tEntryObj[i], 0, sizeof(DMOBJ));
|
||||
|
||||
if (0 != dynamicdm_init(ctx, ubus_name, tEntryObj)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue