]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
build: fix sparse warning and host utility test builds master
authorTulio A M Mendes <[email protected]>
Thu, 4 Jun 2026 07:17:07 +0000 (04:17 -0300)
committerTulio A M Mendes <[email protected]>
Thu, 4 Jun 2026 07:17:07 +0000 (04:17 -0300)
src/drivers/e1000.c
src/kernel/main.c
user/cmds/du/du.c
user/cmds/find/find.c
user/cmds/grep/grep.c
user/cmds/kill/kill.c
user/cmds/ls/ls.c
user/cmds/rm/rm.c

index 504c3213f884a3ea4587a0a0d66ba694e8f7d0df..d359b0945e7f2dd21eeefd99eaca914675f0ef0b 100644 (file)
@@ -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);
index 2cfd19ed053ac6fd0c77ae777c692145f2b3e473..806070d529b2e189a231244f6cf731af31a1c0ac 100644 (file)
@@ -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
 
index ac80ec3513dd678a00b5033df3d602ec36adce37..5523dcd761cf6c13b0e501fa7616da4ca54e5942 100644 (file)
@@ -15,6 +15,8 @@
 #include <dirent.h>
 #include <sys/stat.h>
 
+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) {
index 6b2bbc905702c7af88dda8af7f1e8b4d190a3662..42c7463a321e8c4ae5fdeac3e8213f9c4660ad41 100644 (file)
@@ -17,6 +17,9 @@
 #include <pwd.h>
 #include <time.h>
 #include <stdlib.h>
+#include <sys/wait.h>
+
+int getdents(int fd, void* buf, size_t count);
 
 #define MAX_PRED 32
 
index 5caf1d8e22bf29562393263c4dba6f377319495c..a26cf512e494fbacd2f3e6e75600cc8d730e7aac 100644 (file)
@@ -17,6 +17,8 @@
 #include <regex.h>
 #include <ctype.h>
 
+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;
index 2274949057e56386d5c13606473331235db62f90..1c3af5f3bf184860d886a93816365b13ce19cf4b 100644 (file)
@@ -12,6 +12,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <signal.h>
 
 int main(int argc, char** argv) {
     if (argc <= 1) {
index 6f261e26f2bd13544adc3fa5f909b579fd4eb906..c62716c0ef6a48f61284dfeabbc742a5ccb56106 100644 (file)
@@ -19,6 +19,8 @@
 #include <grp.h>
 #include <time.h>
 
+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 */
index 135ce5d5c4d7bf2465e21ea0ba8f8ffc8f87d0e5..4df8687e9a4e16a2201042c19e8e9968914c70d6 100644 (file)
@@ -15,6 +15,8 @@
 #include <dirent.h>
 #include <sys/stat.h>
 
+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 */