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

View file

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

View file

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

View file

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

View file

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