Skip to content
Snippets Groups Projects
Commit 13dfd514 authored by Vivek Dutta's avatar Vivek Dutta
Browse files

Fix cppcheck errors

parent 3e2a5d7e
No related branches found
No related tags found
1 merge request!112Fix Pipeline
Pipeline #182724 passed
......@@ -3,7 +3,7 @@ variables:
#BUILDX_VERSION: "v0.10.4"
#BUILDX_ARCH: "linux-amd64"
SOURCE_FOLDER: "./src"
FLAWFINDER_OPTIONS: "-m 4 --error-level=5"
CPPCHECK_OPTIONS: "--suppress=cert-MSC24-C --suppress=cert-EXP05-C"
include:
- project: 'iopsys/gitlab-ci-pipeline'
......
......@@ -9,5 +9,7 @@ echo "Installing required packages"
exec_cmd apt update
exec_cmd apt install -y uuid-dev lxc-dev lxc
echo "Installing datamodel support"
install_bbfdm
if [ ! -d "/opt/dev/bbfdm" ]; then
echo "Installing datamodel support"
install_bbfdm
fi
......@@ -669,13 +669,8 @@ static int get_SoftwareModulesExecutionUnit_ExecEnvLabel(char *refparam, struct
ee_name = dmjson_get_value(p->json_object, 1, "ee_name");
eu_name = dmjson_get_value(p->json_object, 1, "eu_name");
if (ee_name == NULL)
ee_name = "";
if (eu_name == NULL)
eu_name = "";
dmasprintf(value, "%.32s%.32s", ee_name, eu_name);
dmasprintf(value, "%.32s%.32s", (ee_name)?(ee_name):"", (eu_name)?(eu_name):"");
return 0;
}
......
......@@ -63,9 +63,10 @@ typedef struct {
typedef struct ExecUnit {
bool eu_exists;
char euid[MAX_LEN_65]; //EUID
bool autostart;
int disk_space; //DiskSpaceInUse
int memory_space; //MemoryInUse
char euid[MAX_LEN_65]; //EUID
char name[MAX_LEN_32]; // //Execution Unit Name
char state[MAX_LEN_32]; // //Execution Unit Name
char command[MAX_LEN_32]; //Execution Unit Command
......@@ -77,7 +78,6 @@ typedef struct ExecUnit {
char req_state[MAX_LEN_16];
char du_name[MAX_LEN_64]; // //Deployment Unit Name
char eu_alias[MAX_LEN_65];
bool autostart;
char fault_code[MAX_LEN_32];
} ExecUnit;
......
......@@ -28,15 +28,15 @@ enum swmod_du_opration_enum {
typedef struct {
time_t start;
int operation;
unsigned long instance;
struct uci_section *section;
char env_var[MAX_ENV_VAR_BUFF];
char url[2049];
char uname[257];
char psw[257];
char uuid[37];
char env_name[32];
int operation;
unsigned long instance;
struct uci_section *section;
} PkgInfo;
bool memory_available(unsigned long req_kb, const char *dst);
......
......@@ -227,12 +227,12 @@ char *generate_duid(bool sysnchronise, int number)
char euid_num[8] = {0};
for (i = 0; i < 3; i++)
euid[i] = buf[rand() % div];
euid[i] = buf[rand() % div]; //cppcheck-suppress cert-MSC30-c
snprintf(euid_num, sizeof(euid_num), "%04d", number);
strncat(euid, euid_num, 4);
} else {
for (i = 0; i < 7; i++)
euid[i] = buf[rand() % div];
euid[i] = buf[rand() % div]; //cppcheck-suppress cert-MSC30-c
}
euid[7] = '\0';
......@@ -261,14 +261,15 @@ int run_cmd(const char *cmd, char *output, size_t out_len)
if (cmd == NULL) // null command to run, silently ignore
return 0;
if (output == NULL || out_len == 0) {
return ret;
}
// init the buffer
memset(output, 0, out_len);
pp = popen(cmd, "r"); // flawfinder: ignore
if (output == NULL || out_len == 0) {
return ret;
}
if (pp != NULL) {
char line[512] = {0};
......@@ -288,13 +289,7 @@ int run_cmd(const char *cmd, char *output, size_t out_len)
/* when command has no output or output is not needed */
int run_cmd_no_output(const char *cmd)
{
if (cmd == NULL)
return 0;
if (0 != system(cmd)) // flawfinder: ignore
return -1;
return 0;
return run_cmd(cmd, NULL, 0);
}
int get_env_type(const char *type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment