From 152923db5773ecc38d243566c19e4e94c37e892e Mon Sep 17 00:00:00 2001 From: Markus Volk Date: Sat, 1 Feb 2020 08:47:19 +0100 Subject: [PATCH] hdd_menu: fix -Wformat-truncation warnings it feels more sane to avoid possible truncation instead of just disarming the gcc test Signed-off-by: Markus Volk Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/bf355658477fc13005ff89d51d4169a1ef646c96 Author: Markus Volk Date: 2020-02-01 (Sat, 01 Feb 2020) ------------------ This commit was generated by Migit --- src/gui/hdd_menu.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index de5d113f3..0e2f2ea08 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -670,7 +670,7 @@ bool CHDDMenuHandler::scanDevices() printf("HDD: root_dev: 0x%04x\n", root_dev); for(int i = 0; i < n;i++) { - char str[256]; + char str[281]; char vendor[128] = { 0 }; char model[128] = { 0 }; int64_t bytes = 0; @@ -679,7 +679,7 @@ bool CHDDMenuHandler::scanDevices() bool isroot = false; printf("HDD: checking /sys/block/%s\n", namelist[i]->d_name); - snprintf(str, sizeof(str), "/dev/%s", namelist[i]->d_name) < 0 ? abort() : (void)0; + snprintf(str, sizeof(str), "/dev/%s", namelist[i]->d_name); int fd = open(str, O_RDONLY); if (fd >= 0) { if (ioctl(fd, BLKGETSIZE64, &bytes)) @@ -702,11 +702,11 @@ bool CHDDMenuHandler::scanDevices() megabytes = bytes/1000000; - snprintf(str, sizeof(str), "/sys/block/%s/device/vendor", namelist[i]->d_name) < 0 ? abort() : (void)0; + snprintf(str, sizeof(str), "/sys/block/%s/device/vendor", namelist[i]->d_name); FILE * f = fopen(str, "r"); if(!f) { printf("Cant open %s\n", str); - snprintf(str, sizeof(str), "/sys/block/%s/device/type", namelist[i]->d_name) < 0 ? abort() : (void)0; + snprintf(str, sizeof(str), "/sys/block/%s/device/type", namelist[i]->d_name); f = fopen(str, "r"); } if (f) { @@ -719,13 +719,13 @@ bool CHDDMenuHandler::scanDevices() /* the Tripledragon only has kernel 2.6.12 available.... :-( */ if (oldkernel) - snprintf(str, sizeof(str), "/proc/ide/%s/model", namelist[i]->d_name) < 0 ? abort() : (void)0; + snprintf(str, sizeof(str), "/proc/ide/%s/model", namelist[i]->d_name); else - snprintf(str, sizeof(str), "/sys/block/%s/device/model", namelist[i]->d_name) < 0 ? abort() : (void)0; + snprintf(str, sizeof(str), "/sys/block/%s/device/model", namelist[i]->d_name); f = fopen(str, "r"); if(!f) { printf("Cant open %s\n", str); - snprintf(str, sizeof(str), "/sys/block/%s/device/name", namelist[i]->d_name) < 0 ? abort() : (void)0; + snprintf(str, sizeof(str), "/sys/block/%s/device/name", namelist[i]->d_name); f = fopen(str, "r"); } if (f) { @@ -734,7 +734,7 @@ bool CHDDMenuHandler::scanDevices() } #if 0 int removable = 0; - snprintf(str, sizeof(str), "/sys/block/%s/removable", namelist[i]->d_name) < 0 ? abort() : (void)0; + snprintf(str, sizeof(str), "/sys/block/%s/removable", namelist[i]->d_name); f = fopen(str, "r"); if(!f) { printf("Cant open %s\n", str); @@ -756,7 +756,7 @@ bool CHDDMenuHandler::scanDevices() hdd_list.push_back(hdd); } - snprintf(str, sizeof(str), "%s %s %ld %s", vendor, model, (long)(megabytes < 10000 ? megabytes : megabytes/1000), megabytes < 10000 ? "MB" : "GB") < 0 ? abort() : (void)0; + snprintf(str, sizeof(str), "%s %s %ld %s", vendor, model, (long)(megabytes < 10000 ? megabytes : megabytes/1000), megabytes < 10000 ? "MB" : "GB"); printf("HDD: %s\n", str); devtitle[namelist[i]->d_name] = str; @@ -1454,10 +1454,10 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) printf("CHDDDestExec: noise %d sleep %d /dev/%s\n", g_settings.hdd_noise, g_settings.hdd_sleep, namelist[i]->d_name); - char M_opt[50],S_opt[50], opt[100]; + char M_opt[50],S_opt[50], opt[261]; snprintf(S_opt, sizeof(S_opt), "-S%d", g_settings.hdd_sleep); snprintf(M_opt, sizeof(M_opt), "-M%d", g_settings.hdd_noise); - snprintf(opt, sizeof(opt), "/dev/%s",namelist[i]->d_name) < 0 ? abort() : (void)0; + snprintf(opt, sizeof(opt), "/dev/%s",namelist[i]->d_name); if (have_nonbb_hdparm) my_system(4, hdparm, M_opt, S_opt, opt);