hdd_menu.cpp: circumvent format-truncation-warning

Signed-off-by: MarkusVolk <f_l_k@t-online.de>
Signed-off-by: Thilo Graf <dbt@novatux.de>


Origin commit data
------------------
Commit: dcc3e44437
Author: Markus Volk <f_l_k@t-online.de>
Date: 2020-01-09 (Thu, 09 Jan 2020)
This commit is contained in:
Markus Volk
2020-01-09 21:37:16 +01:00
committed by vanhofen
parent 2c2ff6aec8
commit 7c4b6976d9

View File

@@ -679,7 +679,7 @@ bool CHDDMenuHandler::scanDevices()
bool isroot = false; bool isroot = false;
printf("HDD: checking /sys/block/%s\n", namelist[i]->d_name); printf("HDD: checking /sys/block/%s\n", namelist[i]->d_name);
snprintf(str, sizeof(str), "/dev/%s", namelist[i]->d_name); snprintf(str, sizeof(str), "/dev/%s", namelist[i]->d_name) < 0 ? abort() : (void)0;
int fd = open(str, O_RDONLY); int fd = open(str, O_RDONLY);
if (fd >= 0) { if (fd >= 0) {
if (ioctl(fd, BLKGETSIZE64, &bytes)) if (ioctl(fd, BLKGETSIZE64, &bytes))
@@ -702,11 +702,11 @@ bool CHDDMenuHandler::scanDevices()
megabytes = bytes/1000000; megabytes = bytes/1000000;
snprintf(str, sizeof(str), "/sys/block/%s/device/vendor", namelist[i]->d_name); snprintf(str, sizeof(str), "/sys/block/%s/device/vendor", namelist[i]->d_name) < 0 ? abort() : (void)0;
FILE * f = fopen(str, "r"); FILE * f = fopen(str, "r");
if(!f) { if(!f) {
printf("Cant open %s\n", str); printf("Cant open %s\n", str);
snprintf(str, sizeof(str), "/sys/block/%s/device/type", namelist[i]->d_name); snprintf(str, sizeof(str), "/sys/block/%s/device/type", namelist[i]->d_name) < 0 ? abort() : (void)0;
f = fopen(str, "r"); f = fopen(str, "r");
} }
if (f) { if (f) {
@@ -719,13 +719,13 @@ bool CHDDMenuHandler::scanDevices()
/* the Tripledragon only has kernel 2.6.12 available.... :-( */ /* the Tripledragon only has kernel 2.6.12 available.... :-( */
if (oldkernel) if (oldkernel)
snprintf(str, sizeof(str), "/proc/ide/%s/model", namelist[i]->d_name); snprintf(str, sizeof(str), "/proc/ide/%s/model", namelist[i]->d_name) < 0 ? abort() : (void)0;
else else
snprintf(str, sizeof(str), "/sys/block/%s/device/model", namelist[i]->d_name); snprintf(str, sizeof(str), "/sys/block/%s/device/model", namelist[i]->d_name) < 0 ? abort() : (void)0;
f = fopen(str, "r"); f = fopen(str, "r");
if(!f) { if(!f) {
printf("Cant open %s\n", str); printf("Cant open %s\n", str);
snprintf(str, sizeof(str), "/sys/block/%s/device/name", namelist[i]->d_name); snprintf(str, sizeof(str), "/sys/block/%s/device/name", namelist[i]->d_name) < 0 ? abort() : (void)0;
f = fopen(str, "r"); f = fopen(str, "r");
} }
if (f) { if (f) {
@@ -734,7 +734,7 @@ bool CHDDMenuHandler::scanDevices()
} }
#if 0 #if 0
int removable = 0; int removable = 0;
snprintf(str, sizeof(str), "/sys/block/%s/removable", namelist[i]->d_name); snprintf(str, sizeof(str), "/sys/block/%s/removable", namelist[i]->d_name) < 0 ? abort() : (void)0;
f = fopen(str, "r"); f = fopen(str, "r");
if(!f) { if(!f) {
printf("Cant open %s\n", str); printf("Cant open %s\n", str);
@@ -755,7 +755,7 @@ bool CHDDMenuHandler::scanDevices()
hdd_list.push_back(hdd); 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"); snprintf(str, sizeof(str), "%s %s %ld %s", vendor, model, (long)(megabytes < 10000 ? megabytes : megabytes/1000), megabytes < 10000 ? "MB" : "GB") < 0 ? abort() : (void)0;
printf("HDD: %s\n", str); printf("HDD: %s\n", str);
devtitle[namelist[i]->d_name] = str; devtitle[namelist[i]->d_name] = str;
@@ -1456,7 +1456,7 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&)
char M_opt[50],S_opt[50], opt[100]; char M_opt[50],S_opt[50], opt[100];
snprintf(S_opt, sizeof(S_opt), "-S%d", g_settings.hdd_sleep); 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(M_opt, sizeof(M_opt), "-M%d", g_settings.hdd_noise);
snprintf(opt, sizeof(opt), "/dev/%s",namelist[i]->d_name); snprintf(opt, sizeof(opt), "/dev/%s",namelist[i]->d_name) < 0 ? abort() : (void)0;
if (have_nonbb_hdparm) if (have_nonbb_hdparm)
my_system(4, hdparm, M_opt, S_opt, opt); my_system(4, hdparm, M_opt, S_opt, opt);