From: Tulio A M Mendes Date: Thu, 4 Jun 2026 07:17:07 +0000 (-0300) Subject: build: fix sparse warning and host utility test builds X-Git-Url: https://projects.tadryanom.me/?a=commitdiff_plain;ds=sidebyside;p=AdrOS.git build: fix sparse warning and host utility test builds --- diff --git a/src/drivers/e1000.c b/src/drivers/e1000.c index 504c3213..d359b094 100644 --- a/src/drivers/e1000.c +++ b/src/drivers/e1000.c @@ -100,13 +100,13 @@ static void e1000_read_mac(void) { /* DMA memory allocation */ /* ------------------------------------------------------------------ */ -static uint32_t alloc_dma_page(uintptr_t va) { +static void* alloc_dma_page(uintptr_t va) { void* phys = pmm_alloc_page(); - if (!phys) return 0; + if (!phys) return NULL; vmm_map_page((uint64_t)(uintptr_t)phys, (uint64_t)va, VMM_FLAG_PRESENT | VMM_FLAG_RW | VMM_FLAG_NOCACHE); memset((void*)va, 0, 4096); - return (uint32_t)(uintptr_t)phys; + return phys; } /* ------------------------------------------------------------------ */ @@ -114,7 +114,7 @@ static uint32_t alloc_dma_page(uintptr_t va) { /* ------------------------------------------------------------------ */ static int e1000_init_tx(void) { - tx_desc_phys = alloc_dma_page(E1000_TX_DESC_VA); + tx_desc_phys = (uint32_t)(uintptr_t)alloc_dma_page(E1000_TX_DESC_VA); if (!tx_desc_phys) return -1; struct e1000_tx_desc* txd = (struct e1000_tx_desc*)E1000_TX_DESC_VA; @@ -127,7 +127,7 @@ static int e1000_init_tx(void) { if (buf_off == 0) { /* First buffer on this page — allocate it */ - uint32_t phys = alloc_dma_page(va); + uint32_t phys = (uint32_t)(uintptr_t)alloc_dma_page(va); if (!phys) return -1; tx_buf_phys[i] = phys; } else { @@ -162,7 +162,7 @@ static int e1000_init_tx(void) { /* ------------------------------------------------------------------ */ static int e1000_init_rx(void) { - rx_desc_phys = alloc_dma_page(E1000_RX_DESC_VA); + rx_desc_phys = (uint32_t)(uintptr_t)alloc_dma_page(E1000_RX_DESC_VA); if (!rx_desc_phys) return -1; struct e1000_rx_desc* rxd = (struct e1000_rx_desc*)E1000_RX_DESC_VA; @@ -173,7 +173,7 @@ static int e1000_init_rx(void) { uintptr_t va = E1000_RX_BUF_VA + (uintptr_t)page_idx * 4096; if (buf_off == 0) { - uint32_t phys = alloc_dma_page(va); + uint32_t phys = (uint32_t)(uintptr_t)alloc_dma_page(va); if (!phys) return -1; rx_buf_phys[i] = phys; } else { @@ -197,7 +197,7 @@ static int e1000_init_rx(void) { e1000_write(E1000_MTA + (uint32_t)i * 4, 0); } - e1000_write(E1000_RDBAL, rx_desc_phys); + e1000_write(E1000_RDBAL, (uint32_t)rx_desc_phys); e1000_write(E1000_RDBAH, 0); e1000_write(E1000_RDLEN, E1000_NUM_RX_DESC * (uint32_t)sizeof(struct e1000_rx_desc)); e1000_write(E1000_RDH, 0); diff --git a/src/kernel/main.c b/src/kernel/main.c index 2cfd19ed..806070d5 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -36,7 +36,7 @@ /* Check if the compiler thinks we are targeting the wrong operating system. */ -#if defined(__linux__) +#if defined(__linux__) && !defined(__CHECKER__) #warning "You are not using a cross-compiler, you may run into trouble" #endif diff --git a/user/cmds/du/du.c b/user/cmds/du/du.c index ac80ec35..5523dcd7 100644 --- a/user/cmds/du/du.c +++ b/user/cmds/du/du.c @@ -15,6 +15,8 @@ #include #include +int getdents(int fd, void* buf, size_t count); + static int sflag = 0; /* -s: summary only */ static long du_path(const char* path, int print) { diff --git a/user/cmds/find/find.c b/user/cmds/find/find.c index 6b2bbc90..42c7463a 100644 --- a/user/cmds/find/find.c +++ b/user/cmds/find/find.c @@ -17,6 +17,9 @@ #include #include #include +#include + +int getdents(int fd, void* buf, size_t count); #define MAX_PRED 32 diff --git a/user/cmds/grep/grep.c b/user/cmds/grep/grep.c index 5caf1d8e..a26cf512 100644 --- a/user/cmds/grep/grep.c +++ b/user/cmds/grep/grep.c @@ -17,6 +17,8 @@ #include #include +int getdents(int fd, void* buf, size_t count); + static int use_regex = 1; /* 1=BRE, 2=ERE, 0=fixed string */ static int icase = 0; static int show_name = 0; diff --git a/user/cmds/kill/kill.c b/user/cmds/kill/kill.c index 22749490..1c3af5f3 100644 --- a/user/cmds/kill/kill.c +++ b/user/cmds/kill/kill.c @@ -12,6 +12,7 @@ #include #include #include +#include int main(int argc, char** argv) { if (argc <= 1) { diff --git a/user/cmds/ls/ls.c b/user/cmds/ls/ls.c index 6f261e26..c62716c0 100644 --- a/user/cmds/ls/ls.c +++ b/user/cmds/ls/ls.c @@ -19,6 +19,8 @@ #include #include +int getdents(int fd, void* buf, size_t count); + static int aflag = 0; /* -a: show hidden files */ static int lflag = 0; /* -l: long format */ static int nflag = 0; /* -n: numeric UID/GID */ diff --git a/user/cmds/rm/rm.c b/user/cmds/rm/rm.c index 135ce5d5..4df8687e 100644 --- a/user/cmds/rm/rm.c +++ b/user/cmds/rm/rm.c @@ -15,6 +15,8 @@ #include #include +int getdents(int fd, void* buf, size_t count); + static int rflag = 0; /* -r: recursive */ static int fflag = 0; /* -f: force (no errors) */ static int dflag = 0; /* -d: remove empty directories */