diff options
Diffstat (limited to 'src/hardware')
-rw-r--r-- | src/hardware/lsblk.c | 3 | ||||
-rw-r--r-- | src/hardware/smartctl.c | 3 | ||||
-rw-r--r-- | src/hardware/sysfs.c | 9 | ||||
-rw-r--r-- | src/hardware/utils.c | 5 |
4 files changed, 13 insertions, 7 deletions
diff --git a/src/hardware/lsblk.c b/src/hardware/lsblk.c index 611ab5c..45ba051 100644 --- a/src/hardware/lsblk.c +++ b/src/hardware/lsblk.c @@ -96,6 +96,7 @@ short lsblk_get_hdds(LsblkHdd **hdds, unsigned *hdds_nb) unsigned i, curr_hdd = 0, buffer_size = 0; char **buffer = NULL, *path, *type; struct stat sb; + char errbuf[STRERROR_BUF_LEN]; lsblk_free_hdds(hdds, hdds_nb); @@ -130,7 +131,7 @@ short lsblk_get_hdds(LsblkHdd **hdds, unsigned *hdds_nb) } if (stat(path, &sb) != 0) { warn("Stat() call on file \"%s\" failed: %s", - path, strerror(errno)); + path, strerror_r(errno, errbuf, sizeof(errbuf))); free(path); continue; } diff --git a/src/hardware/smartctl.c b/src/hardware/smartctl.c index 349f198..874475a 100644 --- a/src/hardware/smartctl.c +++ b/src/hardware/smartctl.c @@ -112,6 +112,7 @@ short scan_smctlhdd_devices(SmartctlHdd **hdds, unsigned *hdds_nb) unsigned i, curr_hdd = 0, buffer_size = 0, sec_buffer_size = 0; char **buffer = NULL, **sec_buffer = NULL; struct stat sb; + char errbuf[STRERROR_BUF_LEN]; smartctl_free_hdds(hdds, hdds_nb); @@ -147,7 +148,7 @@ short scan_smctlhdd_devices(SmartctlHdd **hdds, unsigned *hdds_nb) if (stat(sec_buffer[0], &sb) != 0) { warn("Stat() call on file \"%s\" failed: %s", - sec_buffer[0], strerror(errno)); + sec_buffer[0], strerror_r(errno, errbuf, sizeof(errbuf))); free_2d_buffer(&sec_buffer, &sec_buffer_size); continue; } diff --git a/src/hardware/sysfs.c b/src/hardware/sysfs.c index aab2ba6..5ed34ad 100644 --- a/src/hardware/sysfs.c +++ b/src/hardware/sysfs.c @@ -26,13 +26,14 @@ short path_get_unsigned(const char *path, unsigned *result) short ret = -1; unsigned buffer_size = 0; char **buffer = NULL; + char errbuf[STRERROR_BUF_LEN]; if (read_file(path, &buffer, &buffer_size) != 0 || buffer_size < 1) { goto done; } if (sscanf(buffer[0], "%u", result) != 1) { warn("Failed to parse file: \"%s\"; Error: %s", - path, strerror(errno)); + path, strerror_r(errno, errbuf, sizeof(errbuf))); goto done; } @@ -160,6 +161,7 @@ short sysfs_get_cpu_caches(SysfsCpuCache **caches, unsigned *caches_nb) DmiProcessor *dmi_cpus = NULL; unsigned dmi_cpus_nb = 0, cpus_nb = 0; LscpuProcessor lscpu; + char errbuf[STRERROR_BUF_LEN]; *caches_nb = 0; @@ -186,7 +188,7 @@ short sysfs_get_cpu_caches(SysfsCpuCache **caches, unsigned *caches_nb) dir = opendir(cache_dir); if (!dir) { warn("Failed to read directory: \"%s\"; Error: %s", - cache_dir, strerror(errno)); + cache_dir, strerror_r(errno, errbuf, sizeof(errbuf))); goto done; } while (readdir(dir)) { @@ -344,6 +346,7 @@ short sysfs_get_sizes_of_hugepages(unsigned **sizes, unsigned *sizes_nb) { short ret = -1; DIR *dir = NULL; + char errbuf[STRERROR_BUF_LEN]; *sizes_nb = 0; *sizes = NULL; @@ -353,7 +356,7 @@ short sysfs_get_sizes_of_hugepages(unsigned **sizes, unsigned *sizes_nb) dir = opendir(sizes_dir); if (!dir) { warn("Failed to read directory: \"%s\"; Error: %s", - sizes_dir, strerror(errno)); + sizes_dir, strerror_r(errno, errbuf, sizeof(errbuf))); goto done; } while (readdir(dir)) { diff --git a/src/hardware/utils.c b/src/hardware/utils.c index 305cc1e..fdce75d 100644 --- a/src/hardware/utils.c +++ b/src/hardware/utils.c @@ -132,6 +132,7 @@ short run_command(const char *command, char ***buffer, unsigned *buffer_size) { FILE *fp = NULL; short ret = -1; + char errbuf[STRERROR_BUF_LEN]; /* if command is empty */ if (!command || strlen(command) < 1) { @@ -144,7 +145,7 @@ short run_command(const char *command, char ***buffer, unsigned *buffer_size) fp = popen(command, "r"); if (!fp) { warn("Failed to run command: \"%s\"; Error: %s", - command, strerror(errno)); + command, strerror_r(errno, errbuf, sizeof(errbuf))); goto done; } @@ -159,7 +160,7 @@ done: int ret_code = pclose(fp); if (ret_code == -1) { warn("Failed to run command: \"%s\"; Error: %s", - command, strerror(errno)); + command, strerror_r(errno, errbuf, sizeof(errbuf))); if (ret == 0) { ret = -1; } |