mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Remove redundant func
This commit is contained in:
parent
7bfb04861b
commit
2d65ca3a36
9 changed files with 30 additions and 44 deletions
|
|
@ -2,7 +2,7 @@ variables:
|
||||||
DEBUG: 'TRUE'
|
DEBUG: 'TRUE'
|
||||||
SOURCE_FOLDER: "."
|
SOURCE_FOLDER: "."
|
||||||
FLAWFINDER_OPTIONS: "-m 4 --error-level=5"
|
FLAWFINDER_OPTIONS: "-m 4 --error-level=5"
|
||||||
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/"
|
CPPCHECK_OPTIONS: "--enable=all --suppress=variableScope --suppress=unusedFunction --suppress=constParameter --suppress=knownConditionTrueFalse -DBBF_VENDOR_PREFIX=X_IOPSYS_EU_ -DBBFDM_ENABLE_DOTSO_PLUGIN -DBBFDM_ENABLE_DOTSO_PLUGIN -DBBF_TR181 -DBBF_VENDOR_IOPSYS -i test/"
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- project: 'iopsys/gitlab-ci-pipeline'
|
- project: 'iopsys/gitlab-ci-pipeline'
|
||||||
|
|
|
||||||
|
|
@ -1036,11 +1036,11 @@ static int bbfdm_service_handler(struct ubus_context *ctx, struct ubus_object *o
|
||||||
|
|
||||||
if (tb[BBF_SERVICE_OBJECTS]) {
|
if (tb[BBF_SERVICE_OBJECTS]) {
|
||||||
struct blob_attr *objs = tb[BBF_SERVICE_OBJECTS];
|
struct blob_attr *objs = tb[BBF_SERVICE_OBJECTS];
|
||||||
struct blob_attr *obj = NULL;
|
struct blob_attr *attr_obj = NULL;
|
||||||
size_t rem;
|
size_t rem;
|
||||||
|
|
||||||
blobmsg_for_each_attr(obj, objs, rem) {
|
blobmsg_for_each_attr(attr_obj, objs, rem) {
|
||||||
char *srv_obj = blobmsg_get_string(obj);
|
char *srv_obj = blobmsg_get_string(attr_obj);
|
||||||
res |= load_service(DEAMON_DM_ROOT_OBJ, &head_registered_service, srv_name, srv_parent_dm, srv_obj);
|
res |= load_service(DEAMON_DM_ROOT_OBJ, &head_registered_service, srv_name, srv_parent_dm, srv_obj);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1393,20 +1393,6 @@ static bool register_service(struct ubus_context *ctx)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool file_exists(const char *path)
|
|
||||||
{
|
|
||||||
struct stat buffer;
|
|
||||||
|
|
||||||
return stat(path, &buffer) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dir_exists(const char *path)
|
|
||||||
{
|
|
||||||
struct stat buffer;
|
|
||||||
|
|
||||||
return (stat(path, &buffer) == 0 && S_ISDIR(buffer.st_mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _parse_daemon_config_options(bbfdm_config_t *config, json_object *daemon_obj)
|
static int _parse_daemon_config_options(bbfdm_config_t *config, json_object *daemon_obj)
|
||||||
{
|
{
|
||||||
char *opt_val = NULL;
|
char *opt_val = NULL;
|
||||||
|
|
@ -1505,7 +1491,7 @@ static int _fill_daemon_input_option(bbfdm_config_t *config, char *sname)
|
||||||
strncpyt(config->in_name, opt_val, sizeof(config->in_name));
|
strncpyt(config->in_name, opt_val, sizeof(config->in_name));
|
||||||
|
|
||||||
snprintf(opt_val, MAX_DM_PATH, "%s/%s", BBFDM_DEFAULT_MICROSERVICE_MODULE_PATH, sname);
|
snprintf(opt_val, MAX_DM_PATH, "%s/%s", BBFDM_DEFAULT_MICROSERVICE_MODULE_PATH, sname);
|
||||||
if (dir_exists(opt_val)) {
|
if (folder_exists(opt_val)) {
|
||||||
strncpyt(config->in_plugin_dir, opt_val, sizeof(config->in_plugin_dir));
|
strncpyt(config->in_plugin_dir, opt_val, sizeof(config->in_plugin_dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ static struct blob_attr *get_results_array(struct blob_attr *msg)
|
||||||
return tb[0];
|
return tb[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __ubus_callback(struct ubus_request *req, int type __attribute__((unused)), struct blob_attr *msg)
|
static void __ubus_callback(struct ubus_request *req, int msgtype __attribute__((unused)), struct blob_attr *msg)
|
||||||
{
|
{
|
||||||
struct blob_attr *cur = NULL;
|
struct blob_attr *cur = NULL;
|
||||||
int rem = 0;
|
int rem = 0;
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ void prepare_result_blob(struct blob_buf *bb, struct list_head *pv_list)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
struct pvNode *pv = &sortedPV[i];
|
pv = &sortedPV[i];
|
||||||
ptr = pv->param;
|
ptr = pv->param;
|
||||||
if (list_empty(&result_stack)) {
|
if (list_empty(&result_stack)) {
|
||||||
DEBUG("stack empty Processing (%s)", ptr);
|
DEBUG("stack empty Processing (%s)", ptr);
|
||||||
|
|
|
||||||
|
|
@ -1229,9 +1229,10 @@ static int get_ubus_value(struct dmctx *dmctx, struct dmnode *node)
|
||||||
|
|
||||||
static int get_ubus_supported_dm(struct dmctx *dmctx, struct dmnode *node)
|
static int get_ubus_supported_dm(struct dmctx *dmctx, struct dmnode *node)
|
||||||
{
|
{
|
||||||
json_object *res = NULL, *res_obj = NULL;
|
json_object *res = NULL, *res_obj = NULL, *tmp_obj = NULL;
|
||||||
char *ubus_name = node->obj->checkdep;
|
char *ubus_name = node->obj->checkdep;
|
||||||
char *in_path = (dmctx->in_param[0] == '\0' || rootcmp(dmctx->in_param, "Device") == 0) ? node->current_object : dmctx->in_param;
|
char *in_path = (dmctx->in_param[0] == '\0' || rootcmp(dmctx->in_param, "Device") == 0) ? node->current_object : dmctx->in_param;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
json_object *in_args = json_object_new_object();
|
json_object *in_args = json_object_new_object();
|
||||||
json_object_object_add(in_args, "proto", json_object_new_string((dmctx->dm_type == BBFDM_BOTH) ? "both" : (dmctx->dm_type == BBFDM_CWMP) ? "cwmp" : "usp"));
|
json_object_object_add(in_args, "proto", json_object_new_string((dmctx->dm_type == BBFDM_BOTH) ? "both" : (dmctx->dm_type == BBFDM_CWMP) ? "cwmp" : "usp"));
|
||||||
|
|
@ -1288,10 +1289,10 @@ static int get_ubus_supported_dm(struct dmctx *dmctx, struct dmnode *node)
|
||||||
op->in = dmcalloc(in_nbre + 1, sizeof(char *));
|
op->in = dmcalloc(in_nbre + 1, sizeof(char *));
|
||||||
|
|
||||||
for (j = 0; j < in_nbre; j++) {
|
for (j = 0; j < in_nbre; j++) {
|
||||||
json_object *res_obj = json_object_array_get_idx(input_array, j);
|
tmp_obj = json_object_array_get_idx(input_array, j);
|
||||||
|
|
||||||
char *in_path = dmjson_get_value(res_obj, 1, "path");
|
tmp = dmjson_get_value(tmp_obj, 1, "path");
|
||||||
op->in[j] = dmstrdup(in_path);
|
op->in[j] = dmstrdup(tmp);
|
||||||
}
|
}
|
||||||
op->in[j] = NULL;
|
op->in[j] = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -1303,10 +1304,10 @@ static int get_ubus_supported_dm(struct dmctx *dmctx, struct dmnode *node)
|
||||||
op->out = dmcalloc(out_nbre + 1, sizeof(char *));
|
op->out = dmcalloc(out_nbre + 1, sizeof(char *));
|
||||||
|
|
||||||
for (j = 0; j < out_nbre; j++) {
|
for (j = 0; j < out_nbre; j++) {
|
||||||
json_object *res_obj = json_object_array_get_idx(output_array, j);
|
tmp_obj = json_object_array_get_idx(output_array, j);
|
||||||
|
|
||||||
char *in_path = dmjson_get_value(res_obj, 1, "path");
|
tmp = dmjson_get_value(tmp_obj, 1, "path");
|
||||||
op->out[j] = dmstrdup(in_path);
|
op->out[j] = dmstrdup(tmp);
|
||||||
}
|
}
|
||||||
op->out[j] = NULL;
|
op->out[j] = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -1324,10 +1325,10 @@ static int get_ubus_supported_dm(struct dmctx *dmctx, struct dmnode *node)
|
||||||
ev->param = dmcalloc(in_nbre + 1, sizeof(char *));
|
ev->param = dmcalloc(in_nbre + 1, sizeof(char *));
|
||||||
|
|
||||||
for (j = 0; j < in_nbre; j++) {
|
for (j = 0; j < in_nbre; j++) {
|
||||||
json_object *res_obj = json_object_array_get_idx(input_array, j);
|
tmp_obj = json_object_array_get_idx(input_array, j);
|
||||||
|
|
||||||
char *in_path = dmjson_get_value(res_obj, 1, "path");
|
tmp = dmjson_get_value(tmp_obj, 1, "path");
|
||||||
ev->param[j] = dmstrdup(in_path);
|
ev->param[j] = dmstrdup(tmp);
|
||||||
}
|
}
|
||||||
ev->param[j] = NULL;
|
ev->param[j] = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2126,15 +2126,15 @@ char *replace_str(const char *input_str, const char *old_substr, const char *new
|
||||||
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while (*input_str) {
|
while (*input_str) {
|
||||||
char *match = strstr(input_str, old_substr);
|
char *tmp = strstr(input_str, old_substr);
|
||||||
if (match == input_str) {
|
if (tmp == input_str) {
|
||||||
// Replace old_substr with new_substr
|
// Replace old_substr with new_substr
|
||||||
strncpy(&result[i], new_substr, new_substr_len);
|
strncpy(&result[i], new_substr, new_substr_len);
|
||||||
i += new_substr_len;
|
i += new_substr_len;
|
||||||
input_str += old_substr_len;
|
input_str += old_substr_len;
|
||||||
} else if (match) {
|
} else if (tmp) {
|
||||||
// Copy characters from input_str to result until the match
|
// Copy characters from input_str to result until the match
|
||||||
size_t len = match - input_str;
|
size_t len = tmp - input_str;
|
||||||
strncpy(&result[i], input_str, len);
|
strncpy(&result[i], input_str, len);
|
||||||
i += len;
|
i += len;
|
||||||
input_str += len;
|
input_str += len;
|
||||||
|
|
@ -2534,7 +2534,7 @@ long upload_file(const char *file_path, const char *url, const char *username, c
|
||||||
char dst_path[2046] = {0};
|
char dst_path[2046] = {0};
|
||||||
char buff[BUFSIZ] = {0};
|
char buff[BUFSIZ] = {0};
|
||||||
FILE *sfp, *dfp;
|
FILE *sfp, *dfp;
|
||||||
int n, count=0;
|
size_t n;
|
||||||
|
|
||||||
sfp = fopen(file_path, "rb");
|
sfp = fopen(file_path, "rb");
|
||||||
if (sfp == NULL) {
|
if (sfp == NULL) {
|
||||||
|
|
@ -2550,7 +2550,6 @@ long upload_file(const char *file_path, const char *url, const char *username, c
|
||||||
|
|
||||||
while ((n = fread(buff, 1, BUFSIZ, sfp)) != 0) {
|
while ((n = fread(buff, 1, BUFSIZ, sfp)) != 0) {
|
||||||
fwrite(buff, 1, n, dfp);
|
fwrite(buff, 1, n, dfp);
|
||||||
count+=n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(sfp);
|
fclose(sfp);
|
||||||
|
|
|
||||||
|
|
@ -1596,11 +1596,11 @@ static int set_value_from_mapping(json_object *param_obj, int json_version, char
|
||||||
if (!type_obj)
|
if (!type_obj)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
char *type = json_object_get_string(type_obj);
|
char *dm_type = json_object_get_string(type_obj);
|
||||||
if (!type)
|
if (!dm_type)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (DM_LSTRCMP(type, "boolean") == 0) {
|
if (DM_LSTRCMP(dm_type, "boolean") == 0) {
|
||||||
value = dmuci_string_to_boolean(value) ? "1" : "0";
|
value = dmuci_string_to_boolean(value) ? "1" : "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ void gre___get_tunnel_system_name(struct uci_section *iface_section, char *devic
|
||||||
{
|
{
|
||||||
char *proto = NULL;
|
char *proto = NULL;
|
||||||
|
|
||||||
if (!iface_section || !device_str_size || !device_str_size)
|
if (!iface_section || !device_str_size)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(iface_section, "proto", &proto);
|
dmuci_get_value_by_section_string(iface_section, "proto", &proto);
|
||||||
|
|
@ -481,7 +481,7 @@ char *ethernet___get_ethernet_interface_name(char *device_name)
|
||||||
|
|
||||||
dmuci_get_value_by_section_string(dev_s, "type", &type);
|
dmuci_get_value_by_section_string(dev_s, "type", &type);
|
||||||
if (DM_STRCMP(type, "8021ad") == 0) {
|
if (DM_STRCMP(type, "8021ad") == 0) {
|
||||||
char *has_vid = DM_STRRCHR(dev_name, '.');
|
has_vid = DM_STRRCHR(dev_name, '.');
|
||||||
if (has_vid)
|
if (has_vid)
|
||||||
*has_vid = '\0';
|
*has_vid = '\0';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,9 @@ static inline int init_wifi_radio_power(struct dm_data *curr_data)
|
||||||
char *dbm = dmjson_get_value(power, 1, "dbm");
|
char *dbm = dmjson_get_value(power, 1, "dbm");
|
||||||
if (!dbm)
|
if (!dbm)
|
||||||
continue;
|
continue;
|
||||||
int power = (int)strtod(dbm, NULL);
|
int power_dbm = (int)strtod(dbm, NULL);
|
||||||
if (ind < MAX_POWER_INDEX) {
|
if (ind < MAX_POWER_INDEX) {
|
||||||
curr_radio_power->transmit_power[ind] = power;
|
curr_radio_power->transmit_power[ind] = power_dbm;
|
||||||
ind++;
|
ind++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue