aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile10
-rw-r--r--bam.lua25
-rw-r--r--src/common/include/debug.h8
-rw-r--r--src/common/libalgo/btree.c2
-rw-r--r--src/kernel/core/sys.c2
-rw-r--r--src/kernel/dev/pciide.c4
-rw-r--r--src/kernel/dev/vesa.c2
-rw-r--r--src/lib/libkogata/mainloop.c2
9 files changed, 48 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 0268822..e3904bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
tags
+debuglog/*
build/*
.bam/*
diff --git a/Makefile b/Makefile
index e7a3dfc..fd1bdc0 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,16 @@ all:
clean:
bam -c
+analyze:
+ scan-build -V bam
+
+reanalyze: clean analyze
+
+splint:
+ splint -I src/common/include src/common/*/*.c
+ splint -I src/common/include -I src/kernel/include src/kernel/*/*.c
+ splint -I src/common/include -I src/lib/include src/lib/*/*.c src/sysbin/*/*.c
+
rebuild: clean all
mrproper: clean
diff --git a/bam.lua b/bam.lua
index 47fc5f1..be75fe5 100644
--- a/bam.lua
+++ b/bam.lua
@@ -15,13 +15,32 @@ end
--
host_settings = NewSettings()
+common_settings = NewSettings()
+
+if os.getenv('CC') and string.match(os.getenv('CC'), '.*analyzer$') then
+ print("Detected clang-analyzer")
+ SetDriversGCC(host_settings)
+ host_settings.cc.exe_c = 'CCC_CC=gcc ' .. os.getenv('CC')
+ host_settings.cc.exe_cxx = 'CCC_CXX=g++ ' .. os.getenv('CXX')
+
+ SetDriversGCC(common_settings)
+ common_settings.cc.flags:Add('-U__linux__')
+ common_settings.cc.exe_c = 'CCC_CC=i586-elf-gcc ' .. os.getenv('CC')
+ common_settings.cc.exe_cxx = 'CCC_CXX=i586-elf-g++ ' .. os.getenv('CXX')
+ common_settings.link.exe = 'CCC_CC=i586-elf-gcc ' .. os.getenv('CC')
+else
+ common_settings.cc.exe_c = "i586-elf-gcc"
+ common_settings.cc.exe_cxx = "i586-elf-g++"
+ common_settings.link.exe = "i586-elf-gcc"
+end
+
+
host_settings.cc.Output = BuildOutput
host_settings.cc.extension = ".host.o"
host_settings.cc.includes:Add("src/lib/include/proto",
"src/common/include")
host_settings.link.extension = ".bin"
-common_settings = NewSettings()
common_settings.compile.mappings['s'] = function(settings, input)
local output = BuildOutput(settings, input) .. settings.cc.extension
@@ -31,8 +50,6 @@ common_settings.compile.mappings['s'] = function(settings, input)
return output
end
-common_settings.cc.exe_c = "i586-elf-gcc"
-common_settings.cc.exe_cxx = "i586-elf-g++"
common_settings.cc.Output = BuildOutput
common_settings.cc.includes:Add("src/common/include", ".")
common_settings.cc.flags:Add("-m32",
@@ -43,7 +60,6 @@ common_settings.cc.flags:Add("-m32",
"-Wno-unused-function",
"-g", "-O0")
-common_settings.link.exe = "i586-elf-gcc"
common_settings.link.extension = ".bin"
common_settings.link.flags:Add("-ffreestanding",
"-nostdlib",
@@ -51,6 +67,7 @@ common_settings.link.flags:Add("-ffreestanding",
common_settings.link.libs:Add("gcc")
common_settings.link.Output = BuildOutput
+
user_settings = TableDeepCopy(common_settings)
user_settings.cc.includes:Add('src/lib/include')
diff --git a/src/common/include/debug.h b/src/common/include/debug.h
index a4b8b6f..285343c 100644
--- a/src/common/include/debug.h
+++ b/src/common/include/debug.h
@@ -3,8 +3,12 @@
#include <stddef.h>
#include <stdint.h>
-void panic(const char* message, const char* file, int line);
-void panic_assert(const char* assertion, const char* file, int line);
+void panic(const char* message, const char* file, int line)
+__attribute__((__noreturn__));
+
+void panic_assert(const char* assertion, const char* file, int line)
+__attribute__((__noreturn__));
+
#define PANIC(s) panic(s, __FILE__, __LINE__);
#define ASSERT(s) { if (!(s)) panic_assert(#s, __FILE__, __LINE__); }
diff --git a/src/common/libalgo/btree.c b/src/common/libalgo/btree.c
index 45fde1e..d5b34bb 100644
--- a/src/common/libalgo/btree.c
+++ b/src/common/libalgo/btree.c
@@ -24,7 +24,7 @@ btree_t* create_btree(key_cmp_fun_t cf, kv_iter_fun_t relf) {
if (t == 0) return 0;
t->cf = cf;
- if (t->releasef) t->releasef = relf;
+ t->releasef = relf;
t->root = 0;
t->nitems = 0;
diff --git a/src/kernel/core/sys.c b/src/kernel/core/sys.c
index 02b66e5..e852274 100644
--- a/src/kernel/core/sys.c
+++ b/src/kernel/core/sys.c
@@ -32,10 +32,12 @@ static void panic_do(const char* type, const char *msg, const char* file, int li
void panic(const char* message, const char* file, int line) {
panic_do("PANIC", message, file, line);
+ while(true);
}
void panic_assert(const char* assertion, const char* file, int line) {
panic_do("ASSERT FAILED", assertion, file, line);
+ while(true);
}
// ---- kernel symbol map
diff --git a/src/kernel/dev/pciide.c b/src/kernel/dev/pciide.c
index d63abb4..f45bc44 100644
--- a/src/kernel/dev/pciide.c
+++ b/src/kernel/dev/pciide.c
@@ -311,7 +311,7 @@ uint8_t ide_ata_access(ide_controller_t *c, int direction,
// If (!DMA & LBA48) DO_PIO_EXT;
// If (!DMA & LBA28) DO_PIO_LBA;
// If (!DMA & !LBA#) DO_PIO_CHS;
- uint8_t cmd;
+ uint8_t cmd = 0;
if (lba_mode == 0 && !dma && direction == 0) cmd = ATA_CMD_READ_PIO;
if (lba_mode == 1 && !dma && direction == 0) cmd = ATA_CMD_READ_PIO;
if (lba_mode == 2 && !dma && direction == 0) cmd = ATA_CMD_READ_PIO_EXT;
@@ -324,6 +324,8 @@ uint8_t ide_ata_access(ide_controller_t *c, int direction,
if (lba_mode == 0 && dma && direction == 1) cmd = ATA_CMD_WRITE_DMA;
if (lba_mode == 1 && dma && direction == 1) cmd = ATA_CMD_WRITE_DMA;
if (lba_mode == 2 && dma && direction == 1) cmd = ATA_CMD_WRITE_DMA_EXT;
+ ASSERT(cmd != 0);
+
ide_write(c, channel, ATA_REG_COMMAND, cmd); // Send the Command.
if (dma) {
diff --git a/src/kernel/dev/vesa.c b/src/kernel/dev/vesa.c
index f77b230..03418b4 100644
--- a/src/kernel/dev/vesa.c
+++ b/src/kernel/dev/vesa.c
@@ -281,6 +281,8 @@ void vesa_detect(fs_t *iofs) {
uint16_t *last_mode = modes;
while (*last_mode != 0xFFFF) last_mode++;
+ if (last_mode == modes) goto end_detect;
+
mode_data = (vesa_mode_t*)malloc((last_mode - modes) * sizeof(vesa_mode_t));
if (mode_data == 0) goto end_detect;
diff --git a/src/lib/libkogata/mainloop.c b/src/lib/libkogata/mainloop.c
index ece7672..58966dd 100644
--- a/src/lib/libkogata/mainloop.c
+++ b/src/lib/libkogata/mainloop.c
@@ -65,6 +65,8 @@ void mainloop_run() {
for (mainloop_fd_t *fd = mainloop_fds; fd != 0; fd = fd->next)
nfds++;
+ if (nfds == 0) return;
+
if (sel_arg != 0) free(sel_arg);
sel_arg = (sel_fd_t*)malloc(nfds * sizeof(sel_fd_t));
if (sel_arg == 0) {