Fixed warnings and removed unused function

This commit is contained in:
Benjamin Braunfels
2024-04-26 14:35:50 +02:00
parent 61126f0af0
commit 2b383b167e
6 changed files with 117 additions and 69 deletions

View File

@@ -290,13 +290,33 @@ static void doLoad (int argc, char *argv [])
if (!moduleLoaded (module1))
{
sprintf (cmd, "%s %s%s", findExecutable (MODPROBE), module1, args1) ;
system (cmd) ;
int ret = system(cmd);
if (ret == -1) {
perror("Error executing command");
} else if (WIFEXITED(ret)) {
int exit_status = WEXITSTATUS(ret);
if (exit_status != 0) {
fprintf(stderr, "Command failed with exit status %d\n", exit_status);
}
} else {
fprintf(stderr, "Command terminated by signal\n");
}
}
if (!moduleLoaded (module2))
{
sprintf (cmd, "%s %s%s", findExecutable (MODPROBE), module2, args2) ;
system (cmd) ;
int ret = system(cmd);
if (ret == -1) {
perror("Error executing command");
} else if (WIFEXITED(ret)) {
int exit_status = WEXITSTATUS(ret);
if (exit_status != 0) {
fprintf(stderr, "Command failed with exit status %d\n", exit_status);
}
} else {
fprintf(stderr, "Command terminated by signal\n");
}
}
if (!moduleLoaded (module2))
@@ -350,13 +370,33 @@ static void doUnLoad (int argc, char *argv [])
if (moduleLoaded (module1))
{
sprintf (cmd, "%s %s", findExecutable (RMMOD), module1) ;
system (cmd) ;
int ret = system(cmd);
if (ret == -1) {
perror("Error executing command");
} else if (WIFEXITED(ret)) {
int exit_status = WEXITSTATUS(ret);
if (exit_status != 0) {
fprintf(stderr, "Command failed with exit status %d\n", exit_status);
}
} else {
fprintf(stderr, "Command terminated by signal\n");
}
}
if (moduleLoaded (module2))
{
sprintf (cmd, "%s %s", findExecutable (RMMOD), module2) ;
system (cmd) ;
int ret = system(cmd);
if (ret == -1) {
perror("Error executing command");
} else if (WIFEXITED(ret)) {
int exit_status = WEXITSTATUS(ret);
if (exit_status != 0) {
fprintf(stderr, "Command failed with exit status %d\n", exit_status);
}
} else {
fprintf(stderr, "Command terminated by signal\n");
}
}
}
@@ -562,14 +602,14 @@ static volatile int globalCounter ;
void printgpioflush(const char* text) {
if (gpioDebug) {
printf(text);
printf("%s", text);
fflush(stdout);
}
}
void printgpio(const char* text) {
if (gpioDebug) {
printf(text);
printf("%s", text);
fflush(stdout);
}
}
@@ -1371,7 +1411,10 @@ static void doVersion (char *argv [])
{
if ((fd = fopen ("/proc/device-tree/model", "r")) != NULL)
{
fgets (name, 80, fd) ;
if (fgets(name, sizeof(name), fd) == NULL) {
// Handle error or end of file condition
perror("Error reading /proc/device-tree/model");
}
fclose (fd) ;
printf (" *--> %s\n", name) ;
}