fixed warnings

This commit is contained in:
maliakal_d 2021-11-17 09:25:36 +01:00
parent 6e276770eb
commit 00775b543e
5 changed files with 15 additions and 18 deletions

View File

@ -137,8 +137,6 @@ sls_enable_cxx_warning("-Wnull-dereference")
sls_enable_cxx_warning("-Wduplicated-cond")
sls_disable_cxx_warning("-Wclass-memaccess")
sls_disable_c_warning("-Wstringop-truncation")
sls_disable_c_warning("-Wformat-nonliteral")
sls_disable_c_warning("-Wformat-truncation")
if(SLS_USE_SANITIZER)

View File

@ -465,9 +465,9 @@ int setupDetectorServer(char *mess, char *sname) {
LOG(logINFO, ("\tinittab: DetectoServer line deleted\n"));
// add new link name to /etc/inittab
char *format = "echo 'ttyS0::respawn:/./%s' >> /etc/inittab";
if (snprintf(cmd, MAX_STR_LENGTH, format, LINKED_SERVER_NAME) >=
MAX_STR_LENGTH) {
if (snprintf(cmd, MAX_STR_LENGTH,
"echo 'ttyS0::respawn:/./%s' >> /etc/inittab",
LINKED_SERVER_NAME) >= MAX_STR_LENGTH) {
strcpy(mess, "Could not copy detector server. Command "
"to add new server for spawning is too long\n");
LOG(logERROR, (mess));
@ -560,8 +560,8 @@ int moveBinaryFile(char *mess, char *dest, char *src, char *errorPrefix) {
// one can move into the current process binary (will not interfere in
// kernel mode)
char *format = "mv %s %s";
if (snprintf(cmd, MAX_STR_LENGTH, format, src, dest) >= MAX_STR_LENGTH) {
if (snprintf(cmd, MAX_STR_LENGTH, "mv %s %s", src, dest) >=
MAX_STR_LENGTH) {
sprintf(mess, "Could not %s. Command to move binary is too long\n",
errorPrefix);
LOG(logERROR, (mess));

View File

@ -222,8 +222,7 @@ int emptyTempFolder(char *mess) {
char cmd[MAX_STR_LENGTH] = {0};
char retvals[MAX_STR_LENGTH] = {0};
char *format = "rm -fr %s";
if (snprintf(cmd, MAX_STR_LENGTH, format,
if (snprintf(cmd, MAX_STR_LENGTH, "rm -fr %s",
TEMP_PROG_FOLDER_NAME_ALL_FILES) >= MAX_STR_LENGTH) {
sprintf(mess,
"Could not update %s. Command to empty %s folder is too long\n",
@ -429,8 +428,7 @@ int eraseFlash(char *mess) {
#endif
char cmd[MAX_STR_LENGTH] = {0};
char retvals[MAX_STR_LENGTH] = {0};
char *format = "flash_eraseall %s";
if (snprintf(cmd, MAX_STR_LENGTH, format, flashDriveName) >=
if (snprintf(cmd, MAX_STR_LENGTH, "flash_eraseall %s", flashDriveName) >=
MAX_STR_LENGTH) {
sprintf(mess, "Could not %s. Command to erase flash is too long\n",
messageType);

View File

@ -167,8 +167,7 @@ int eraseFlash(char *mess) {
char cmd[MAX_STR_LENGTH] = {0};
char retvals[MAX_STR_LENGTH] = {0};
char *format = "flash_erase %s 0 0";
if (snprintf(cmd, MAX_STR_LENGTH, format, flashDriveName) >=
if (snprintf(cmd, MAX_STR_LENGTH, "flash_erase %s 0 0", flashDriveName) >=
MAX_STR_LENGTH) {
sprintf(mess, "Could not %s. Command to erase flash is too long\n",
messageType);

View File

@ -4094,9 +4094,8 @@ int copy_detector_server(int file_des) {
char cmd[MAX_STR_LENGTH] = {0};
// tftp server
char *format = "tftp %s -r %s -g";
if (snprintf(cmd, MAX_STR_LENGTH, format, hostname, sname) >=
MAX_STR_LENGTH) {
if (snprintf(cmd, MAX_STR_LENGTH, "tftp %s -r %s -g", hostname,
sname) >= MAX_STR_LENGTH) {
ret = FAIL;
strcpy(mess, "Could not copy detector server. Command to copy "
"server too long\n");
@ -9205,8 +9204,11 @@ int get_kernel_version(int file_des) {
// get only
ret = getKernelVersion(retvals);
if (ret == FAIL) {
snprintf(mess, MAX_STR_LENGTH, "Could not get kernel version. %s\n",
retvals);
if (snprintf(mess, MAX_STR_LENGTH, "Could not get kernel version. %s\n",
retvals) >= MAX_STR_LENGTH) {
ret = FAIL;
strcpy(mess, "Could not get kernel version. Reason too long to copy\n");
}
LOG(logERROR, (mess));
} else {
LOG(logDEBUG1, ("kernel version: [%s]\n", retvals));