Reformat source code with clang-tidy

Run with:

clang-format -i src/*

Closes #233.
This commit is contained in:
Andrew Gaul 2021-04-12 22:05:15 +09:00
parent 16f28f900c
commit 623f44d0a5
12 changed files with 253 additions and 271 deletions

View file

@ -16,7 +16,6 @@
*
*/
#include <sys/prctl.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -62,8 +61,7 @@ int read_pid()
if (file != NULL) {
fscanf(file, "%d", &pid);
fclose(file);
if (kill(pid, 0) == -1 && errno == ESRCH)
{ /* a process with such a pid does not exist, remove the pid file */
if (kill(pid, 0) == -1 && errno == ESRCH) { /* a process with such a pid does not exist, remove the pid file */
if (remove(PROGRAM_PID) == 0) {
return -1;
}
@ -198,15 +196,12 @@ void go_daemon(void (*fan_control)())
exit(EXIT_FAILURE);
}
/* Close out the standard file descriptors */
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
}
int current_pid = getpid();
if (read_pid() == -1) {
@ -229,7 +224,6 @@ void go_daemon(void (*fan_control)())
exit(EXIT_FAILURE);
}
fan_control();
if (daemonize) {

View file

@ -50,5 +50,4 @@ void signal_handler(int signal);
*/
void go_daemon(void (*function)());
#endif

View file

@ -127,7 +127,6 @@ bool is_modern_sensors_path()
return 0;
}
t_sensors *retrieve_sensors()
{
t_sensors *sensors_head = NULL;
@ -459,7 +458,6 @@ void retrieve_settings(const char* settings_path, t_fans* fans)
f = fopen(settings_path, "r");
}
if (f == NULL) {
/* Could not open configfile */
if (verbose) {
@ -556,7 +554,6 @@ void check_requirements(const char* program_path)
closedir(dir);
dir = opendir(APPLESMC_PATH);
if (ENOENT == errno) {
@ -565,8 +562,6 @@ void check_requirements(const char* program_path)
}
closedir(dir);
}
int get_max_mhz(void)
@ -578,9 +573,7 @@ int get_max_mhz(void)
}
struct dirent *ent;
while ((ent = readdir(dir)) != NULL) {
if (strncmp(ent->d_name, "cpu", 3) != 0 ||
strcmp(ent->d_name, "cpufreq") == 0 ||
strcmp(ent->d_name, "cpuidle") == 0) {
if (strncmp(ent->d_name, "cpu", 3) != 0 || strcmp(ent->d_name, "cpufreq") == 0 || strcmp(ent->d_name, "cpuidle") == 0) {
continue;
}
char *path = smprintf("/sys/devices/system/cpu/%s/cpufreq/scaling_cur_freq", ent->d_name);
@ -624,11 +617,9 @@ void mbpfan()
fan = fans;
while (fan != NULL) {
fan->step_up = (float)( fan->fan_max_speed - fan->fan_min_speed ) /
(float)( ( max_temp - high_temp ) * ( max_temp - high_temp + 1 ) / 2.0 );
fan->step_up = (float)(fan->fan_max_speed - fan->fan_min_speed) / (float)((max_temp - high_temp) * (max_temp - high_temp + 1) / 2.0);
fan->step_down = (float)( fan->fan_max_speed - fan->fan_min_speed ) /
(float)( ( max_temp - low_temp ) * ( max_temp - low_temp + 1 ) / 2.0 );
fan->step_down = (float)(fan->fan_max_speed - fan->fan_min_speed) / (float)((max_temp - low_temp) * (max_temp - low_temp + 1) / 2.0);
fan = fan->next;
}

View file

@ -39,8 +39,7 @@
#include "strmap.h"
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
typedef struct Settings Settings;

View file

@ -37,8 +37,7 @@
#define _STRMAP_H_
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
#include <stdlib.h>