From 477911553e0443fcafad5bd96c97314aa2f8d9ea Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 14 Jul 2016 10:47:53 +0200 Subject: Integration of scan-build and splint --- src/common/include/debug.h | 8 ++++++-- src/common/libalgo/btree.c | 2 +- src/kernel/core/sys.c | 2 ++ src/kernel/dev/pciide.c | 4 +++- src/kernel/dev/vesa.c | 2 ++ src/lib/libkogata/mainloop.c | 2 ++ 6 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src') 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 #include -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) { -- cgit v1.2.3