mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 18:45:07 +00:00
Kernel+LibC: Fix various build issues introduced by ssize_t
Now that ssize_t is derived from size_t, we have to
This commit is contained in:
parent
2fe6b3725a
commit
dd924b730a
14 changed files with 15 additions and 16 deletions
|
@ -33,7 +33,7 @@
|
||||||
# include <AK/Types.h>
|
# include <AK/Types.h>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
int dbgprintf(const char* fmt, ...);
|
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, ...);
|
int sprintf(char* buf, const char* fmt, ...);
|
||||||
}
|
}
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
|
|
|
@ -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 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);
|
memset(buffer, 0, (size_t)count);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
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?
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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);
|
memset(buffer, 0, (size_t)count);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t ZeroDevice::write(FileDescription&, size_t, const u8*, ssize_t size)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ ssize_t FileDescription::get_dir_entries(u8* buffer, ssize_t size)
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
return -EINVAL;
|
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);
|
auto temp_buffer = ByteBuffer::create_uninitialized(size_to_allocate);
|
||||||
BufferStream stream(temp_buffer);
|
BufferStream stream(temp_buffer);
|
||||||
|
|
|
@ -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
|
// 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
|
// random source like Linux, unlike the OpenBSD equivalent. However, if we
|
||||||
// do, we should be able of the caveats that Linux has dealt with.
|
// 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);
|
REQUIRE_PROMISE(stdio);
|
||||||
if (buffer_size <= 0)
|
if (buffer_size <= 0)
|
||||||
|
|
|
@ -103,7 +103,7 @@ static int allocate_dirp_buffer(DIR* dirp)
|
||||||
errno = old_errno;
|
errno = old_errno;
|
||||||
return new_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);
|
dirp->buffer = (char*)malloc(size_to_allocate);
|
||||||
ssize_t nread = syscall(SC_get_dir_entries, dirp->fd, dirp->buffer, size_to_allocate);
|
ssize_t nread = syscall(SC_get_dir_entries, dirp->fd, dirp->buffer, size_to_allocate);
|
||||||
if (nread < 0) {
|
if (nread < 0) {
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
# define NULL nullptr
|
# define NULL nullptr
|
||||||
|
|
|
@ -993,7 +993,7 @@ void dbgputch(char ch)
|
||||||
syscall(SC_dbgputch, 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);
|
int rc = syscall(SC_dbgputstr, characters, length);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
|
|
|
@ -93,7 +93,7 @@ int fprintf(FILE*, const char* fmt, ...);
|
||||||
int printf(const char* fmt, ...);
|
int printf(const char* fmt, ...);
|
||||||
int dbgprintf(const char* fmt, ...);
|
int dbgprintf(const char* fmt, ...);
|
||||||
void dbgputch(char);
|
void dbgputch(char);
|
||||||
int dbgputstr(const char*, ssize_t);
|
ssize_t dbgputstr(const char*, ssize_t);
|
||||||
int sprintf(char* buffer, const char* fmt, ...);
|
int sprintf(char* buffer, const char* fmt, ...);
|
||||||
int snprintf(char* buffer, size_t, const char* fmt, ...);
|
int snprintf(char* buffer, size_t, const char* fmt, ...);
|
||||||
int putchar(int ch);
|
int putchar(int ch);
|
||||||
|
|
|
@ -41,13 +41,13 @@ Value evaluate(const ByteBuffer& bytes, const PtraceRegisters& regs)
|
||||||
|
|
||||||
switch (static_cast<Operations>(opcode)) {
|
switch (static_cast<Operations>(opcode)) {
|
||||||
case Operations::RegEbp: {
|
case Operations::RegEbp: {
|
||||||
int offset = 0;
|
ssize_t offset = 0;
|
||||||
stream.read_LEB128_signed(offset);
|
stream.read_LEB128_signed(offset);
|
||||||
return Value { Type::UnsignedIntetger, regs.ebp + offset };
|
return Value { Type::UnsignedIntetger, regs.ebp + offset };
|
||||||
}
|
}
|
||||||
|
|
||||||
case Operations::FbReg: {
|
case Operations::FbReg: {
|
||||||
int offset = 0;
|
ssize_t offset = 0;
|
||||||
stream.read_LEB128_signed(offset);
|
stream.read_LEB128_signed(offset);
|
||||||
return Value { Type::UnsignedIntetger, regs.ebp + 2 * sizeof(size_t) + offset };
|
return Value { Type::UnsignedIntetger, regs.ebp + 2 * sizeof(size_t) + offset };
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,7 +303,7 @@ bool print_filesystem_object(const String& path, const String& name, const struc
|
||||||
ASSERT(st.st_size > 0);
|
ASSERT(st.st_size > 0);
|
||||||
printf(" %10s ", human_readable_size((size_t)st.st_size).characters());
|
printf(" %10s ", human_readable_size((size_t)st.st_size).characters());
|
||||||
} else {
|
} else {
|
||||||
printf(" %10u ", st.st_size);
|
printf(" %10zd ", st.st_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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))
|
if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))
|
||||||
printf(" Device: %u,%u\n", major(st.st_rdev), minor(st.st_rdev));
|
printf(" Device: %u,%u\n", major(st.st_rdev), minor(st.st_rdev));
|
||||||
else
|
else
|
||||||
printf(" Size: %u\n", st.st_size);
|
printf(" Size: %zd\n", st.st_size);
|
||||||
printf(" Links: %u\n", st.st_nlink);
|
printf(" Links: %u\n", st.st_nlink);
|
||||||
printf(" Blocks: %u\n", st.st_blocks);
|
printf(" Blocks: %u\n", st.st_blocks);
|
||||||
printf(" UID: %u", st.st_uid);
|
printf(" UID: %u", st.st_uid);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue