diff options
author | Alex Auvolat <alex@adnab.me> | 2016-07-14 10:47:53 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2016-07-14 10:47:53 +0200 |
commit | 477911553e0443fcafad5bd96c97314aa2f8d9ea (patch) | |
tree | 3825cba2552c0c4fe9cf64aecf065402db90f39e | |
parent | d09f8a08bdd9477bd463a2de03397ff56b5ce75d (diff) | |
download | kogata-477911553e0443fcafad5bd96c97314aa2f8d9ea.tar.gz kogata-477911553e0443fcafad5bd96c97314aa2f8d9ea.zip |
Integration of scan-build and splint
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | bam.lua | 25 | ||||
-rw-r--r-- | src/common/include/debug.h | 8 | ||||
-rw-r--r-- | src/common/libalgo/btree.c | 2 | ||||
-rw-r--r-- | src/kernel/core/sys.c | 2 | ||||
-rw-r--r-- | src/kernel/dev/pciide.c | 4 | ||||
-rw-r--r-- | src/kernel/dev/vesa.c | 2 | ||||
-rw-r--r-- | src/lib/libkogata/mainloop.c | 2 |
9 files changed, 48 insertions, 8 deletions
@@ -3,6 +3,7 @@ tags +debuglog/* build/* .bam/* @@ -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 @@ -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) { |