libc: Enable even more warnings

This commit is contained in:
apio 2022-10-07 18:19:06 +02:00
parent b7ee746da3
commit 028a1b1a3c
11 changed files with 35 additions and 29 deletions

View File

@ -4,7 +4,7 @@ MOON_OBJ := $(MOON_DIR)/lib
MOON_BIN := $(MOON_DIR)/bin
CFLAGS := -pedantic -Wall -Wextra -Werror -Wfloat-equal -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion -Os -ffreestanding -fstack-protector-all -fno-omit-frame-pointer -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -fshort-wchar -mcmodel=kernel -I$(MOON_DIR)/include -isystem $(MOON_DIR)/include/std
CXXFLAGS := -fno-rtti -fno-exceptions -Wsign-promo -Wstrict-null-sentinel -Wctor-dtor-privacy
CXXFLAGS := -fno-rtti -fno-exceptions -Wsign-promo -Wstrict-null-sentinel -Wctor-dtor-privacy
ASMFLAGS := -felf64
LDFLAGS := -T$(MOON_DIR)/moon.ld -nostdlib -lgcc -Wl,--build-id=none -z max-page-size=0x1000

View File

@ -4,7 +4,7 @@
#pragma GCC push_options
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wsign-conversion" // FIXME: Actually solve these warnings.
/** Durand's Amazing Super Duper Memory functions. */

View File

@ -5,8 +5,8 @@ LIBC_BIN := $(LIBC_DIR)/bin
DESTDIR ?= $(LUNA_BASE)/usr/lib
CFLAGS := -Wall -Wextra -Werror -Os -nostdlib -fno-omit-frame-pointer -pedantic -Wfloat-equal -Wundef -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow
CXXFLAGS := -fno-rtti -fno-exceptions
CFLAGS := -Os -nostdlib -fno-omit-frame-pointer -pedantic -Wall -Wextra -Werror -Wfloat-equal -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion
CXXFLAGS := -fno-rtti -fno-exceptions -Wsign-promo -Wstrict-null-sentinel -Wctor-dtor-privacy
ASMFLAGS := -felf64
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))

View File

@ -18,13 +18,13 @@ extern "C"
{
#endif
long int __luna_syscall0(int sys_num);
long int __luna_syscall1(int sys_num, unsigned long int arg0);
long int __luna_syscall2(int sys_num, unsigned long int arg0, unsigned long int arg1);
long int __luna_syscall3(int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2);
long int __luna_syscall4(int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
long int __luna_syscall0(long int sys_num);
long int __luna_syscall1(long int sys_num, unsigned long int arg0);
long int __luna_syscall2(long int sys_num, unsigned long int arg0, unsigned long int arg1);
long int __luna_syscall3(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2);
long int __luna_syscall4(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
unsigned long int arg3);
long int __luna_syscall5(int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
long int __luna_syscall5(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
unsigned long int arg3, unsigned long int arg4);
#ifdef __cplusplus

View File

@ -20,7 +20,7 @@ void* liballoc_alloc(size_t size)
int liballoc_free(void* address, size_t size)
{
int result = syscall(SYS_munmap, address, size * 4096);
int result = (int)syscall(SYS_munmap, address, size * 4096);
if (result < 0) return 1;
else
return 0;

View File

@ -1,5 +1,9 @@
#include <bits/liballoc.h>
#pragma GCC push_options
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion" // FIXME: Actually solve these warnings.
#include <stddef.h>
#include <stdint.h>
@ -105,9 +109,9 @@ static void* liballoc_memset(void* s, int c, size_t n)
static void* liballoc_memcpy(void* s1, const void* s2, size_t n)
{
char* cdest;
char* csrc;
const char* csrc;
unsigned int* ldest = (unsigned int*)s1;
unsigned int* lsrc = (unsigned int*)s2;
const unsigned int* lsrc = (const unsigned int*)s2;
while (n >= sizeof(unsigned int))
{
@ -116,7 +120,7 @@ static void* liballoc_memcpy(void* s1, const void* s2, size_t n)
}
cdest = (char*)ldest;
csrc = (char*)lsrc;
csrc = (const char*)lsrc;
while (n > 0)
{
@ -740,3 +744,5 @@ void* PREFIX(realloc)(void* p, size_t size)
return ptr;
}
#pragma GCC pop_options

View File

@ -14,7 +14,7 @@ extern "C"
unsigned int msleep(unsigned int ms)
{
return syscall(SYS_sleep, ms);
return (unsigned int)syscall(SYS_sleep, ms);
}
noreturn void __luna_abort(const char* message)

View File

@ -1,34 +1,34 @@
#include <luna/syscall.h>
long int __luna_syscall0(int sys_num)
long int __luna_syscall0(long int sys_num)
{
long int result;
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num));
return result;
}
long int __luna_syscall1(int sys_num, unsigned long int arg0)
long int __luna_syscall1(long int sys_num, unsigned long int arg0)
{
long int result;
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0));
return result;
}
long int __luna_syscall2(int sys_num, unsigned long int arg0, unsigned long int arg1)
long int __luna_syscall2(long int sys_num, unsigned long int arg0, unsigned long int arg1)
{
long int result;
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0), "S"(arg1));
return result;
}
long int __luna_syscall3(int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2)
long int __luna_syscall3(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2)
{
long int result;
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0), "S"(arg1), "d"(arg2));
return result;
}
long int __luna_syscall4(int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
long int __luna_syscall4(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
unsigned long int arg3)
{
long int result;
@ -37,7 +37,7 @@ long int __luna_syscall4(int sys_num, unsigned long int arg0, unsigned long int
return result;
}
long int __luna_syscall5(int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
long int __luna_syscall5(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
unsigned long int arg3, unsigned long int arg4)
{
long int result;

View File

@ -36,7 +36,7 @@ template <typename IntegerType> static char* __unsignedtoa(IntegerType number, c
while (number != 0)
{
IntegerType r = number % (IntegerType)base;
arr[i] = (r > 9) ? (r - 10) + 'a' : r + '0';
arr[i] = (char)((r > 9) ? (r - 10) + 'a' : r + '0');
i++;
number /= base;
}
@ -68,7 +68,7 @@ template <typename IntegerType> static char* __signedtoa(IntegerType number, cha
while (number != 0)
{
IntegerType r = number % base;
arr[i] = (r > 9) ? (r - 10) + 'a' : r + '0';
arr[i] = (char)((r > 9) ? (r - 10) + 'a' : r + '0');
i++;
number /= base;
}
@ -147,7 +147,7 @@ static int internal_printf(const char* format, PutString put_string_callback, ss
switch (current_char)
{
case 'c': {
buffer[buffer_insert_index++] = va_arg(ap, int);
buffer[buffer_insert_index++] = (char)va_arg(ap, int);
if (buffer_insert_index == 1024) flush_buffer();
break;
}
@ -272,7 +272,7 @@ static int internal_printf(const char* format, PutString put_string_callback, ss
}
if (buffer_insert_index > 0) flush_buffer();
return written;
return (int)written;
}
#pragma GCC pop_options

View File

@ -51,7 +51,7 @@ extern "C"
{
long nwritten = syscall(SYS_write, s, strlen(s));
nwritten += syscall(SYS_write, "\n", 1);
return nwritten;
return (int)nwritten;
}
int snprintf(char* str, size_t max, const char* format, ...)
{

View File

@ -5,7 +5,7 @@ extern "C"
{
void* memcpy(void* dest, const void* src, size_t n)
{
for (size_t i = 0; i < n; ++i) { *((char*)dest + i) = *((char*)src + i); }
for (size_t i = 0; i < n; ++i) { *((char*)dest + i) = *((const char*)src + i); }
return dest;
}
@ -41,7 +41,7 @@ extern "C"
size_t dest_len = strlen(dest);
size_t i;
for (i = 0; *(src + i); i++) *(char*)(dest + dest_len + i) = *(char*)(src + i);
for (i = 0; *(src + i); i++) *(char*)(dest + dest_len + i) = *(const char*)(src + i);
*(char*)(dest + dest_len + i) = '\0';
@ -53,7 +53,7 @@ extern "C"
size_t dest_len = strlen(dest);
size_t i;
for (i = 0; i < n && *(src + i); i++) *(char*)(dest + dest_len + i) = *(char*)(src + i);
for (i = 0; i < n && *(src + i); i++) *(char*)(dest + dest_len + i) = *(const char*)(src + i);
*(char*)(dest + dest_len + i) = '\0';