update formatting

This commit is contained in:
2025-08-11 15:34:48 +02:00
parent 2bd68392cb
commit 782e78760b
6 changed files with 11 additions and 11 deletions

View File

@@ -5,7 +5,7 @@
#include <stdio.h>
#include <unistd.h>
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);
}

View File

@@ -6,7 +6,7 @@
#include <stdlib.h>
#include <stdnoreturn.h>
noreturn void fatal(char const* fmt, ...) {
noreturn void fatal(const char *fmt, ...) {
char buf[128];
va_list args;
va_start(args, fmt);

View File

@@ -4,4 +4,4 @@
#include <stdnoreturn.h>
// prints an error message and aborts execution
noreturn void fatal(char const*, ...);
noreturn void fatal(const char *, ...);

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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 *);