Преглед изворни кода

Kernel+LibC: Fix various build issues introduced by ssize_t

Now that ssize_t is derived from size_t, we have to
Andreas Kling пре 5 година
родитељ
комит
dd924b730a

+ 1 - 1
AK/kstdio.h

@@ -33,7 +33,7 @@
 #        include <AK/Types.h>
 extern "C" {
 int dbgprintf(const char* fmt, ...);
-int dbgputstr(const char*, ssize_t);
+ssize_t dbgputstr(const char*, ssize_t);
 int sprintf(char* buf, const char* fmt, ...);
 }
 template<size_t N>

+ 1 - 1
Kernel/Devices/FullDevice.cpp

@@ -47,7 +47,7 @@ bool FullDevice::can_read(const FileDescription&, size_t) const
 
 ssize_t FullDevice::read(FileDescription&, size_t, u8* buffer, ssize_t size)
 {
-    ssize_t count = min(PAGE_SIZE, size);
+    ssize_t count = min(static_cast<ssize_t>(PAGE_SIZE), size);
     memset(buffer, 0, (size_t)count);
     return count;
 }

+ 1 - 1
Kernel/Devices/NullDevice.cpp

@@ -59,7 +59,7 @@ ssize_t NullDevice::read(FileDescription&, size_t, u8*, ssize_t)
 
 ssize_t NullDevice::write(FileDescription&, size_t, const u8*, ssize_t buffer_size)
 {
-    return min(PAGE_SIZE, buffer_size);
+    return min(static_cast<ssize_t>(PAGE_SIZE), buffer_size);
 }
 
 }

+ 1 - 1
Kernel/Devices/RandomDevice.cpp

@@ -52,7 +52,7 @@ ssize_t RandomDevice::read(FileDescription&, size_t, u8* buffer, ssize_t size)
 ssize_t RandomDevice::write(FileDescription&, size_t, const u8*, ssize_t size)
 {
     // FIXME: Use input for entropy? I guess that could be a neat feature?
-    return min(PAGE_SIZE, size);
+    return min(static_cast<ssize_t>(PAGE_SIZE), size);
 }
 
 }

+ 2 - 2
Kernel/Devices/ZeroDevice.cpp

@@ -46,14 +46,14 @@ bool ZeroDevice::can_read(const FileDescription&, size_t) const
 
 ssize_t ZeroDevice::read(FileDescription&, size_t, u8* buffer, ssize_t size)
 {
-    ssize_t count = min(PAGE_SIZE, size);
+    ssize_t count = min(static_cast<ssize_t>(PAGE_SIZE), size);
     memset(buffer, 0, (size_t)count);
     return count;
 }
 
 ssize_t ZeroDevice::write(FileDescription&, size_t, const u8*, ssize_t size)
 {
-    return min(PAGE_SIZE, size);
+    return min(static_cast<ssize_t>(PAGE_SIZE), size);
 }
 
 }

+ 1 - 1
Kernel/FileSystem/FileDescription.cpp

@@ -179,7 +179,7 @@ ssize_t FileDescription::get_dir_entries(u8* buffer, ssize_t size)
     if (size < 0)
         return -EINVAL;
 
-    size_t size_to_allocate = max(PAGE_SIZE, metadata.size);
+    size_t size_to_allocate = max(static_cast<size_t>(PAGE_SIZE), static_cast<size_t>(metadata.size));
 
     auto temp_buffer = ByteBuffer::create_uninitialized(size_to_allocate);
     BufferStream stream(temp_buffer);

+ 1 - 1
Kernel/Process.cpp

@@ -4259,7 +4259,7 @@ int Process::sys$get_process_name(char* buffer, int buffer_size)
 // We don't use the flag yet, but we could use it for distinguishing
 // random source like Linux, unlike the OpenBSD equivalent. However, if we
 // do, we should be able of the caveats that Linux has dealt with.
-int Process::sys$getrandom(void* buffer, size_t buffer_size, unsigned int flags __attribute__((unused)))
+ssize_t Process::sys$getrandom(void* buffer, size_t buffer_size, unsigned int flags __attribute__((unused)))
 {
     REQUIRE_PROMISE(stdio);
     if (buffer_size <= 0)

+ 1 - 1
Libraries/LibC/dirent.cpp

@@ -103,7 +103,7 @@ static int allocate_dirp_buffer(DIR* dirp)
         errno = old_errno;
         return new_errno;
     }
-    size_t size_to_allocate = max(st.st_size, 4096);
+    size_t size_to_allocate = max(st.st_size, static_cast<off_t>(4096));
     dirp->buffer = (char*)malloc(size_to_allocate);
     ssize_t nread = syscall(SC_get_dir_entries, dirp->fd, dirp->buffer, size_to_allocate);
     if (nread < 0) {

+ 0 - 1
Libraries/LibC/stddef.h

@@ -29,7 +29,6 @@
 #ifndef KERNEL
 
 #include <sys/cdefs.h>
-#include <sys/types.h>
 
 #ifdef __cplusplus
 #    define NULL nullptr

+ 1 - 1
Libraries/LibC/stdio.cpp

@@ -993,7 +993,7 @@ void dbgputch(char ch)
     syscall(SC_dbgputch, ch);
 }
 
-int dbgputstr(const char* characters, int length)
+ssize_t dbgputstr(const char* characters, ssize_t length)
 {
     int rc = syscall(SC_dbgputstr, characters, length);
     __RETURN_WITH_ERRNO(rc, rc, -1);

+ 1 - 1
Libraries/LibC/stdio.h

@@ -93,7 +93,7 @@ int fprintf(FILE*, const char* fmt, ...);
 int printf(const char* fmt, ...);
 int dbgprintf(const char* fmt, ...);
 void dbgputch(char);
-int dbgputstr(const char*, ssize_t);
+ssize_t dbgputstr(const char*, ssize_t);
 int sprintf(char* buffer, const char* fmt, ...);
 int snprintf(char* buffer, size_t, const char* fmt, ...);
 int putchar(int ch);

+ 2 - 2
Libraries/LibDebug/Dwarf/Expression.cpp

@@ -41,13 +41,13 @@ Value evaluate(const ByteBuffer& bytes, const PtraceRegisters& regs)
 
         switch (static_cast<Operations>(opcode)) {
         case Operations::RegEbp: {
-            int offset = 0;
+            ssize_t offset = 0;
             stream.read_LEB128_signed(offset);
             return Value { Type::UnsignedIntetger, regs.ebp + offset };
         }
 
         case Operations::FbReg: {
-            int offset = 0;
+            ssize_t offset = 0;
             stream.read_LEB128_signed(offset);
             return Value { Type::UnsignedIntetger, regs.ebp + 2 * sizeof(size_t) + offset };
         }

+ 1 - 1
Userland/ls.cpp

@@ -303,7 +303,7 @@ bool print_filesystem_object(const String& path, const String& name, const struc
             ASSERT(st.st_size > 0);
             printf(" %10s ", human_readable_size((size_t)st.st_size).characters());
         } else {
-            printf(" %10u ", st.st_size);
+            printf(" %10zd ", st.st_size);
         }
     }
 

+ 1 - 1
Userland/stat.cpp

@@ -48,7 +48,7 @@ static int stat(const char* file, bool should_follow_links)
     if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))
         printf("  Device: %u,%u\n", major(st.st_rdev), minor(st.st_rdev));
     else
-        printf("    Size: %u\n", st.st_size);
+        printf("    Size: %zd\n", st.st_size);
     printf("   Links: %u\n", st.st_nlink);
     printf("  Blocks: %u\n", st.st_blocks);
     printf("     UID: %u", st.st_uid);