summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kernel/drivers/ahci.c2
-rw-r--r--kernel/includes/math.h5
-rw-r--r--kernel/socket.c2
3 files changed, 5 insertions, 4 deletions
diff --git a/kernel/drivers/ahci.c b/kernel/drivers/ahci.c
index bbb0c22..1f3dcf4 100644
--- a/kernel/drivers/ahci.c
+++ b/kernel/drivers/ahci.c
@@ -430,7 +430,7 @@ int ahci_write(u8 *buffer, u64 offset, u64 len, vfs_fd_t *fd) {
ahci_raw_read(&hba->ports[port], lba, 0, 1, (u16 *)tmp_buffer);
int left = 512 - offset;
- int write = min(left, len);
+ int write = min((u64)left, len);
memcpy(tmp_buffer + offset, buffer, write);
ahci_raw_write(&hba->ports[port], lba, 0, 1, (u16 *)tmp_buffer);
diff --git a/kernel/includes/math.h b/kernel/includes/math.h
index 19fc595..87a9d37 100644
--- a/kernel/includes/math.h
+++ b/kernel/includes/math.h
@@ -1,2 +1,3 @@
-int min(int a, int b);
-int max(int a, int b);
+#define min(a,b) ((a) > (b) ? (b) : (a))
+#define max(a,b) ((a) < (b) ? (b) : (a))
+#define abs(a) ((a)>0?(a):(-1*(a)))
diff --git a/kernel/socket.c b/kernel/socket.c
index 37a8463..7ed6769 100644
--- a/kernel/socket.c
+++ b/kernel/socket.c
@@ -384,7 +384,7 @@ int udp_recvfrom(vfs_fd_t *fd, void *buffer, size_t len, int flags,
if (addrlen) {
if (src_addr) {
- memcpy(src_addr, &from, min(sizeof(from), *addrlen));
+ memcpy(src_addr, &from, min(sizeof(from), (long unsigned int)*addrlen));
}
*addrlen = sizeof(from);
}