diff options
Diffstat (limited to 'src/hardware/sysfs.c')
-rw-r--r-- | src/hardware/sysfs.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/hardware/sysfs.c b/src/hardware/sysfs.c index 2e02081..1e8de84 100644 --- a/src/hardware/sysfs.c +++ b/src/hardware/sysfs.c @@ -26,13 +26,13 @@ short path_get_unsigned(const char *path, unsigned *result) short ret = -1; unsigned buffer_size = 0; char **buffer = NULL; - char errbuf[STRERROR_BUF_LEN]; + char errbuf[BUFLEN]; 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", + lmi_warn("Failed to parse file: \"%s\"; Error: %s", path, strerror_r(errno, errbuf, sizeof(errbuf))); goto done; } @@ -60,7 +60,7 @@ short path_get_string(const char *path, char **result) } *result = trim(buffer[0], NULL); if (!(*result)) { - warn("Failed to parse file: \"%s\"", path); + lmi_warn("Failed to parse file: \"%s\"", path); goto done; } @@ -120,7 +120,7 @@ short check_sysfs_cpu_cache_attributes(SysfsCpuCache *cache) done: if (ret != 0) { - warn("Failed to allocate memory."); + lmi_warn("Failed to allocate memory."); } return ret; @@ -140,7 +140,7 @@ short copy_sysfs_cpu_cache(SysfsCpuCache *to, const SysfsCpuCache from) to->type = strdup(from.type); if (!to->id || !to->name || !to->type) { - warn("Failed to allocate memory."); + lmi_warn("Failed to allocate memory."); free(to->id); to->id = NULL; free(to->name); @@ -161,7 +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]; + char errbuf[BUFLEN]; *caches_nb = 0; @@ -178,7 +178,7 @@ short sysfs_get_cpu_caches(SysfsCpuCache **caches, unsigned *caches_nb) } else if (lscpu.processors > 0) { cpus_nb = lscpu.processors; } else { - warn("No processor found."); + lmi_warn("No processor found."); goto done; } @@ -187,7 +187,7 @@ short sysfs_get_cpu_caches(SysfsCpuCache **caches, unsigned *caches_nb) char *cache_dir = SYSFS_CPU_PATH "/cpu0/cache"; dir = opendir(cache_dir); if (!dir) { - warn("Failed to read directory: \"%s\"; Error: %s", + lmi_warn("Failed to read directory: \"%s\"; Error: %s", cache_dir, strerror_r(errno, errbuf, sizeof(errbuf))); goto done; } @@ -201,14 +201,14 @@ short sysfs_get_cpu_caches(SysfsCpuCache **caches, unsigned *caches_nb) /* if no cache was found */ if (*caches_nb < 1) { - warn("No processor cache was found in sysfs."); + lmi_warn("No processor cache was found in sysfs."); goto done; } /* allocate memory for caches */ *caches = (SysfsCpuCache *)calloc(*caches_nb * cpus_nb, sizeof(SysfsCpuCache)); if (!(*caches)) { - warn("Failed to allocate memory."); + lmi_warn("Failed to allocate memory."); *caches_nb = 0; goto done; } @@ -237,13 +237,13 @@ short sysfs_get_cpu_caches(SysfsCpuCache **caches, unsigned *caches_nb) } if (asprintf(&(*caches)[i].id, format_str, level) < 0) { (*caches)[i].id = NULL; - warn("Failed to allocate memory."); + lmi_warn("Failed to allocate memory."); goto done; } if (asprintf(&(*caches)[i].name, "Level %u %s cache", level, buf) < 0) { (*caches)[i].name = NULL; - warn("Failed to allocate memory."); + lmi_warn("Failed to allocate memory."); goto done; } (*caches)[i].type = buf; @@ -346,7 +346,7 @@ short sysfs_get_sizes_of_hugepages(unsigned **sizes, unsigned *sizes_nb) { short ret = -1; DIR *dir = NULL; - char errbuf[STRERROR_BUF_LEN]; + char errbuf[BUFLEN]; *sizes_nb = 0; *sizes = NULL; @@ -355,7 +355,7 @@ short sysfs_get_sizes_of_hugepages(unsigned **sizes, unsigned *sizes_nb) char *sizes_dir = SYSFS_KERNEL_MM "/hugepages"; dir = opendir(sizes_dir); if (!dir) { - warn("Failed to read directory: \"%s\"; Error: %s", + lmi_warn("Failed to read directory: \"%s\"; Error: %s", sizes_dir, strerror_r(errno, errbuf, sizeof(errbuf))); goto done; } @@ -368,14 +368,14 @@ short sysfs_get_sizes_of_hugepages(unsigned **sizes, unsigned *sizes_nb) /* if no size was found */ if (*sizes_nb < 1) { - warn("Looks like kernel doesn't support huge memory pages."); + lmi_warn("Looks like kernel doesn't support huge memory pages."); goto done; } /* allocate memory for sizes */ *sizes = (unsigned *)calloc(*sizes_nb, sizeof(unsigned)); if (!(*sizes)) { - warn("Failed to allocate memory."); + lmi_warn("Failed to allocate memory."); *sizes_nb = 0; goto done; } |