From 782e78760b1d4643894d66ff812547f2c3473d47 Mon Sep 17 00:00:00 2001 From: Quinn Date: Mon, 11 Aug 2025 15:34:48 +0200 Subject: [PATCH] update formatting --- src/cpu.c | 6 +++--- src/error.c | 2 +- src/error.h | 2 +- src/main.c | 4 ++-- src/opts.c | 6 +++--- src/opts.h | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cpu.c b/src/cpu.c index 11f9a28..12c690b 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -5,7 +5,7 @@ #include #include -char const* const cpu_path = "/sys/devices/system/cpu/cpu%i/online"; +const char *const cpu_path = "/sys/devices/system/cpu/cpu%i/online"; bool getcpu(uint32_t id) { // get the file path @@ -18,7 +18,7 @@ bool getcpu(uint32_t id) { // read a character from the file, store in state char state = '\0'; - FILE* f = fopen(path, "r"); + FILE *f = fopen(path, "r"); fread(&state, 1, 1, f); fclose(f); @@ -33,7 +33,7 @@ void setcpu(uint32_t id, bool state) { char s = 0x30 + (char)state; // convert the state to a character // write the state to the file (creates file if it doesn't exist) - FILE* f = fopen(path, "w"); + FILE *f = fopen(path, "w"); fwrite(&s, 1, 1, f); fclose(f); } diff --git a/src/error.c b/src/error.c index ef9881b..3ad500c 100644 --- a/src/error.c +++ b/src/error.c @@ -6,7 +6,7 @@ #include #include -noreturn void fatal(char const* fmt, ...) { +noreturn void fatal(const char *fmt, ...) { char buf[128]; va_list args; va_start(args, fmt); diff --git a/src/error.h b/src/error.h index e3d2a56..07b98e8 100644 --- a/src/error.h +++ b/src/error.h @@ -4,4 +4,4 @@ #include // prints an error message and aborts execution -noreturn void fatal(char const*, ...); +noreturn void fatal(const char *, ...); diff --git a/src/main.c b/src/main.c index c4a5dc5..f7e6c17 100644 --- a/src/main.c +++ b/src/main.c @@ -23,7 +23,7 @@ static inline void print_cpu_count(int32_t mcpus) { printf("%i/%i cpus enabled.\n", get_nprocs(), mcpus); // get the number of available processors } -int32_t main(int32_t argc, char** argv) { +int32_t main(int32_t argc, char **argv) { if (geteuid() != 0) fatal("must be executed as the root user!"); int32_t ncpus; // the number of CPUs to activate @@ -42,7 +42,7 @@ int32_t main(int32_t argc, char** argv) { if (ncpus > mcpus) fatal("%i exeeds the maximum numbers of cpus available (%i)", ncpus, mcpus); if (ncpus < 1) fatal("may not keep less than 1 cpu enabled, requested to enable %i", ncpus); - char const* const cpu_set_log = "set cpu %i to %hi\n"; + const char *const cpu_set_log = "set cpu %i to %hi\n"; for (int32_t id = 1; id < mcpus; id++) { // start at CPU 1, as CPU 0 is not writeable // whilst the id is less then the amount of cpus to enable if (id < ncpus) { diff --git a/src/opts.c b/src/opts.c index 33d14d8..b42e2d6 100644 --- a/src/opts.c +++ b/src/opts.c @@ -6,11 +6,11 @@ #include "error.h" -uint8_t getoptions(int32_t argc, char* const* argv, int32_t* ncpus) { +uint8_t getoptions(int32_t argc, char *const *argv, int32_t *ncpus) { uint8_t opts = 0; char opt; - char const* const msg = "-%c has already been set"; + const char *const msg = "-%c has already been set"; while ((opt = getopt(argc, argv, "lavi")) != -1) { switch (opt) { case 'l': @@ -35,7 +35,7 @@ uint8_t getoptions(int32_t argc, char* const* argv, int32_t* ncpus) { } if (optind < argc) { - char* num = argv[optind]; + char *num = argv[optind]; *ncpus = atoi(num); } else if (opts & OPT_LIST_CORES) { *ncpus = -1; diff --git a/src/opts.h b/src/opts.h index 9daf00a..7568c9a 100644 --- a/src/opts.h +++ b/src/opts.h @@ -8,4 +8,4 @@ enum opt { OPT_INVERT = 8, // 'num' now represents the amount of cores to disable }; -uint8_t getoptions(int32_t, char* const*, int32_t*); +uint8_t getoptions(int32_t, char *const *, int32_t *);