diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7c2ca02803b8e47766f33765f968f888bb4ad2a3..f795bab895edb8b363d1aee30f0199812ba4c0f8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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' diff --git a/gitlab-ci/install-dependencies.sh b/gitlab-ci/install-dependencies.sh index fb6675f7e38653a6b7e364024b5aa5b2d8555206..dbde775aa3a4013b1a9323d590eb400dab4f2e7a 100755 --- a/gitlab-ci/install-dependencies.sh +++ b/gitlab-ci/install-dependencies.sh @@ -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 diff --git a/src/datamodel.c b/src/datamodel.c index 4043c64f972eab3b27a75db0b6df72d20ac36c76..325036ab5b8bbeb77150673ff619221d32a873cb 100644 --- a/src/datamodel.c +++ b/src/datamodel.c @@ -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; } diff --git a/src/swmod.h b/src/swmod.h index ae469b28677a78c3b178f762e3b43540853429db..aa32048662689a97509931a413da977db7a705fc 100644 --- a/src/swmod.h +++ b/src/swmod.h @@ -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; diff --git a/src/swmod_common.h b/src/swmod_common.h index e5fad84dc2848dc0aa25ddb4cea3cdc5441a8e4d..1a8306a3d2acbedf78ae954bf9544baa454c4adf 100644 --- a/src/swmod_common.h +++ b/src/swmod_common.h @@ -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); diff --git a/src/tools.c b/src/tools.c index a6a395c98ca632f408289102dedc4284c4812e7d..a966fe979b4d91edb7040589cd56e23083dc80ef 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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)