Skip to content

fix: src/main.c complexity reduced by refactoring functions#31

Merged
damachine merged 1 commit intomainfrom
patch-1
Sep 14, 2025
Merged

fix: src/main.c complexity reduced by refactoring functions#31
damachine merged 1 commit intomainfrom
patch-1

Conversation

@damachine
Copy link
Owner

No description provided.

*/
static FILE *try_open_version_file(const char *path)
{
int fd = open(path, O_RDONLY);

Check warning

Code scanning / Flawfinder (reported by Codacy)

Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). Warning

Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362).
int fd = open(path, O_RDONLY);
if (fd == -1)
{
return NULL;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
}

struct stat version_stat;
if (fstat(fd, &version_stat) != 0 || !S_ISREG(version_stat.st_mode))

Check notice

Code scanning / Cppcheck (reported by Codacy)

fstat is Y2038-unsafe Note

fstat is Y2038-unsafe
}

struct stat version_stat;
if (fstat(fd, &version_stat) != 0 || !S_ISREG(version_stat.st_mode))

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.1 rule Note

MISRA 12.1 rule
if (fstat(fd, &version_stat) != 0 || !S_ISREG(version_stat.st_mode))
{
close(fd);
return NULL;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
close(fd);
return NULL;
}

Check notice

Code scanning / Cppcheck (reported by Codacy)

stat is Y2038-unsafe Note

stat is Y2038-unsafe
remove_pid_file(config.paths_pid);
return EXIT_FAILURE;
print_coolercontrol_troubleshooting(config);
return -1;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule

// Get complete device info from cache (no API call)
if (get_liquidctl_data(&config, device_uid, sizeof(device_uid),
if (get_liquidctl_data(config, device_uid, sizeof(device_uid),

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
@damachine damachine merged commit a6c4f71 into main Sep 14, 2025
10 of 11 checks passed
@damachine damachine deleted the patch-1 branch September 14, 2025 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant