commit 86a5224f3c4427f232a98d909330e2815b4cc622
parent 155a29d9b336b1d331f163e3a859772dd041b388
Author: Daniel Barlow <dan@telent.net>
Date: Sat, 4 Nov 2023 23:53:11 +0000
preinit: fix compiler warnings
Diffstat:
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/pkgs/preinit/Makefile b/pkgs/preinit/Makefile
@@ -1,4 +1,5 @@
CFLAGS+=-Os -fno-stack-protector -fpic -fPIC
LDFLAGS=-static
+CFLAGS+=-Wall -Werror
preinit: preinit.o parseopts.o
diff --git a/pkgs/preinit/preinit.c b/pkgs/preinit/preinit.c
@@ -1,9 +1,12 @@
#include <string.h>
+#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mount.h>
#include <sys/wait.h>
#include <string.h>
+#include <stdint.h>
+#include <errno.h>
#include <asm/setup.h> /* for COMMAND_LINE_SIZE */
@@ -12,15 +15,6 @@ void parseopts(char * cmdline, char **root, char **rootfstype);
#define ERR(x) write(2, x, strlen(x))
#define AVER(c) do { if(c < 0) ERR("failed: " #c); } while(0)
-static int begins_with(char * str, char * prefix)
-{
- while(*prefix) {
- if(*str == '\0') return 0;
- if(*str != *prefix) return 0;
- str++;
- prefix++;
- }
- return 1;
}
static int fork_exec(char * command, char *args[])
@@ -28,7 +22,7 @@ static int fork_exec(char * command, char *args[])
int fork_pid = fork();
AVER(fork_pid);
if(fork_pid > 0)
- wait(NULL);
+ return wait(NULL);
else
return execve(command, args, NULL);
}
@@ -40,7 +34,7 @@ int main(int argc, char *argv[], char *envp[])
{
char *rootdevice = 0;
char *rootfstype = 0;
- char *p = buf;
+
write(1, banner, strlen(banner));
mount("none", "/proc", "proc", 0, NULL);