aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/Makefile5
-rw-r--r--libc/conv.c4
-rw-r--r--libc/cpu.c12
-rw-r--r--libc/inc/assert.h6
-rw-r--r--libc/inc/conv.h4
-rw-r--r--libc/inc/cpu.h12
6 files changed, 22 insertions, 21 deletions
diff --git a/libc/Makefile b/libc/Makefile
index a290445..0b7e279 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -16,7 +16,8 @@ LD = ccache ../cross/opt/bin/i686-elf-ld
AR = ccache ../cross/opt/bin/i686-elf-ar
AS = ccache nasm
-CFLAGS = -Wall -Wextra -nostdlib -nostdinc -fno-builtin -mgeneral-regs-only -std=c99 -m32 -pedantic-errors -Iinc/ -Ofast
+WARNINGS = -Wall -Wextra -pedantic-errors -Wshadow -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wnested-externs -Wno-long-long
+CFLAGS = $(WARNINGS) -nostdlib -nostdinc -fno-builtin -mgeneral-regs-only -std=c99 -m32 -Iinc/ -Ofast
ASFLAGS = -f elf32
@@ -29,7 +30,7 @@ libc: $(COBJS)
@mkdir -p ../build/
@$(AR) rcs ../build/libc.a crt0.o $+
-libk: CFLAGS += -Dkernel -ffreestanding
+libk: CFLAGS += -Dkernel -ffreestanding $(CFLAGS_EXTRA)
libk: $(COBJS)
@mkdir -p ../build/
@$(AR) rcs ../build/libk.a $+
diff --git a/libc/conv.c b/libc/conv.c
index 3bde4ec..d0a9a59 100644
--- a/libc/conv.c
+++ b/libc/conv.c
@@ -8,7 +8,7 @@
static const char HTOA_TABLE[] = "0123456789ABCDEF";
static const char ITOA_TABLE[] = "0123456789";
-int atoi(char *str)
+int atoi(const char *str)
{
u32 s_str = strlen(str);
if (!s_str)
@@ -58,7 +58,7 @@ char *htoa(u32 n)
return ret;
}
-int htoi(char *str)
+int htoi(const char *str)
{
u32 s_str = strlen(str);
diff --git a/libc/cpu.c b/libc/cpu.c
index 1f0b7e4..52c0280 100644
--- a/libc/cpu.c
+++ b/libc/cpu.c
@@ -76,35 +76,35 @@ char *cpu_string(char buf[13])
return buf;
}
-void cpu_print()
+void cpu_print(void)
{
char buf[13] = { 0 };
printf("%s\n", cpu_string(buf));
}
#ifdef kernel
-void cli()
+void cli(void)
{
__asm__ volatile("cli");
}
-void sti()
+void sti(void)
{
__asm__ volatile("sti");
}
-void hlt()
+void hlt(void)
{
__asm__ volatile("hlt");
}
-void idle()
+void idle(void)
{
while (1)
hlt();
}
-void loop()
+void loop(void)
{
cli();
idle();
diff --git a/libc/inc/assert.h b/libc/inc/assert.h
index f4fa4b4..3e45f44 100644
--- a/libc/inc/assert.h
+++ b/libc/inc/assert.h
@@ -10,9 +10,9 @@
#define assert(exp) \
if (!(exp)) { \
printf("%s:%d: %s: Assertion '%s' failed\n", __FILE__, __LINE__, __func__, #exp); \
- struct proc *proc = proc_current(); \
- if (proc) \
- proc_exit(proc, 1); \
+ struct proc *assert_proc = proc_current(); \
+ if (assert_proc) \
+ proc_exit(assert_proc, 1); \
else \
__asm__ volatile("cli\nhlt"); \
}
diff --git a/libc/inc/conv.h b/libc/inc/conv.h
index d878deb..adf9003 100644
--- a/libc/inc/conv.h
+++ b/libc/inc/conv.h
@@ -5,9 +5,9 @@
#include <def.h>
-int atoi(char *str);
+int atoi(const char *str);
char *htoa(u32 n);
-int htoi(char *str);
+int htoi(const char *str);
char *itoa(int n);
char *conv_base(int value, char *result, int base, int is_signed);
diff --git a/libc/inc/cpu.h b/libc/inc/cpu.h
index e742390..033743d 100644
--- a/libc/inc/cpu.h
+++ b/libc/inc/cpu.h
@@ -18,14 +18,14 @@ void outl(u16 port, u32 data);
void cpuid(int code, u32 *a, u32 *b, u32 *c, u32 *d);
char *cpu_string(char buf[12]);
-void cpu_print();
+void cpu_print(void);
#ifdef kernel
-void cli();
-void sti();
-void hlt();
-void idle();
-void loop();
+void cli(void);
+void sti(void);
+void hlt(void);
+void idle(void);
+void loop(void);
#endif
static inline void spinlock(int *ptr)