diff --git a/CMakeLists.txt b/CMakeLists.txt index e2b4b1403..4db277142 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/slsDetectorServers/slsDetectorServer/src/common.c b/slsDetectorServers/slsDetectorServer/src/common.c index 3723efc75..45ebc9413 100644 --- a/slsDetectorServers/slsDetectorServer/src/common.c +++ b/slsDetectorServers/slsDetectorServer/src/common.c @@ -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)); diff --git a/slsDetectorServers/slsDetectorServer/src/programViaBlackfin.c b/slsDetectorServers/slsDetectorServer/src/programViaBlackfin.c index 3e5d8538b..a29215061 100644 --- a/slsDetectorServers/slsDetectorServer/src/programViaBlackfin.c +++ b/slsDetectorServers/slsDetectorServer/src/programViaBlackfin.c @@ -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); diff --git a/slsDetectorServers/slsDetectorServer/src/programViaNios.c b/slsDetectorServers/slsDetectorServer/src/programViaNios.c index bcb8fabc6..c81598650 100644 --- a/slsDetectorServers/slsDetectorServer/src/programViaNios.c +++ b/slsDetectorServers/slsDetectorServer/src/programViaNios.c @@ -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); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 409550138..5a2976a8a 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -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));