Skip to content

Commit

Permalink
Modify the error print
Browse files Browse the repository at this point in the history
Signed-off-by: Willy Liu <[email protected]>
  • Loading branch information
Willy Liu committed Jan 7, 2025
1 parent 995b156 commit b86e327
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int sysfs_count = 0;
int safe_snprintf(char *buffer, size_t buffer_size, const char *path1, const char *path2) {
size_t needed_size = strlen(path1) + strlen(path2) + 2; /* 1 for '/', 1 for '\0' */
if (needed_size > buffer_size) {
fprintf(stderr, "Path too long: %s/%s\n", path1, path2);
AIM_LOG_ERROR("Path too long: %s/%s\n", path1, path2);
return -1;
}
snprintf(buffer, buffer_size, "%s/%s", path1, path2);
Expand Down Expand Up @@ -116,11 +116,11 @@ static onlp_thermal_info_t linfo[] = {

int initialize_regex() {
if (regcomp(&dir_regex, "^hwmon[0-9]+$", REG_EXTENDED) != 0) {
fprintf(stderr, "Failed to compile directory regex\n");
AIM_LOG_ERROR("Failed to compile directory regex\n");
return -1;
}
if (regcomp(&file_regex, "^temp([0-9]+)_input$", REG_EXTENDED) != 0) {
fprintf(stderr, "Failed to compile file regex\n");
AIM_LOG_ERROR("Failed to compile file regex\n");
regfree(&dir_regex);
return -1;
}
Expand All @@ -136,7 +136,7 @@ void cleanup_regex() {
void scan_hwmon_files(const char *parent_path) {
DIR *parent_dir = opendir(parent_path);
if (!parent_dir) {
perror("Failed to open parent directory");
AIM_LOG_ERROR("Failed to open parent directory");
return;
}

Expand All @@ -155,7 +155,7 @@ void scan_hwmon_files(const char *parent_path) {

DIR *subdir = opendir(subdir_path);
if (!subdir) {
perror("Failed to open subdirectory");
AIM_LOG_ERROR("Failed to open subdirectory");
continue;
}

Expand All @@ -164,7 +164,7 @@ void scan_hwmon_files(const char *parent_path) {
regmatch_t pmatch[2];
if (regexec(&file_regex, sub_entry->d_name, 2, pmatch, 0) == 0) {
if (count >= MAX_ENTRIES) {
fprintf(stderr, "Maximum entries reached. Ignoring additional files.\n");
AIM_LOG_ERROR("Maximum entries reached. Ignoring additional files.\n");
break;
}

Expand Down Expand Up @@ -229,7 +229,6 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
/* Set the onlp_oid_hdr_t and capabilities */
*info = linfo[tid];
if(tid == THERMAL_CPU_CORE) {

for (size_t i = 0; i < sysfs_count; i++) {
if (onlp_file_read_int(&coretemp_temp, temp_entries[i].name) < 0) {
AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", temp_entries[i].name);
Expand Down

0 comments on commit b86e327

Please sign in to comment.