libc: Enable even more warnings
This commit is contained in:
parent
b7ee746da3
commit
028a1b1a3c
@ -4,7 +4,7 @@ MOON_OBJ := $(MOON_DIR)/lib
|
|||||||
MOON_BIN := $(MOON_DIR)/bin
|
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
|
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
|
ASMFLAGS := -felf64
|
||||||
LDFLAGS := -T$(MOON_DIR)/moon.ld -nostdlib -lgcc -Wl,--build-id=none -z max-page-size=0x1000
|
LDFLAGS := -T$(MOON_DIR)/moon.ld -nostdlib -lgcc -Wl,--build-id=none -z max-page-size=0x1000
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#pragma GCC push_options
|
#pragma GCC push_options
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
#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. */
|
/** Durand's Amazing Super Duper Memory functions. */
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ LIBC_BIN := $(LIBC_DIR)/bin
|
|||||||
|
|
||||||
DESTDIR ?= $(LUNA_BASE)/usr/lib
|
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
|
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
|
CXXFLAGS := -fno-rtti -fno-exceptions -Wsign-promo -Wstrict-null-sentinel -Wctor-dtor-privacy
|
||||||
ASMFLAGS := -felf64
|
ASMFLAGS := -felf64
|
||||||
|
|
||||||
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
|
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
|
||||||
|
@ -18,13 +18,13 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
long int __luna_syscall0(int sys_num);
|
long int __luna_syscall0(long int sys_num);
|
||||||
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 __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 __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 __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);
|
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);
|
unsigned long int arg3, unsigned long int arg4);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -20,7 +20,7 @@ void* liballoc_alloc(size_t size)
|
|||||||
|
|
||||||
int liballoc_free(void* address, 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;
|
if (result < 0) return 1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
#include <bits/liballoc.h>
|
#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 <stddef.h>
|
||||||
#include <stdint.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)
|
static void* liballoc_memcpy(void* s1, const void* s2, size_t n)
|
||||||
{
|
{
|
||||||
char* cdest;
|
char* cdest;
|
||||||
char* csrc;
|
const char* csrc;
|
||||||
unsigned int* ldest = (unsigned int*)s1;
|
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))
|
while (n >= sizeof(unsigned int))
|
||||||
{
|
{
|
||||||
@ -116,7 +120,7 @@ static void* liballoc_memcpy(void* s1, const void* s2, size_t n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cdest = (char*)ldest;
|
cdest = (char*)ldest;
|
||||||
csrc = (char*)lsrc;
|
csrc = (const char*)lsrc;
|
||||||
|
|
||||||
while (n > 0)
|
while (n > 0)
|
||||||
{
|
{
|
||||||
@ -740,3 +744,5 @@ void* PREFIX(realloc)(void* p, size_t size)
|
|||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC pop_options
|
||||||
|
@ -14,7 +14,7 @@ extern "C"
|
|||||||
|
|
||||||
unsigned int msleep(unsigned int ms)
|
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)
|
noreturn void __luna_abort(const char* message)
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
#include <luna/syscall.h>
|
#include <luna/syscall.h>
|
||||||
|
|
||||||
long int __luna_syscall0(int sys_num)
|
long int __luna_syscall0(long int sys_num)
|
||||||
{
|
{
|
||||||
long int result;
|
long int result;
|
||||||
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num));
|
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num));
|
||||||
return result;
|
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;
|
long int result;
|
||||||
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0));
|
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0));
|
||||||
return result;
|
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;
|
long int result;
|
||||||
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0), "S"(arg1));
|
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0), "S"(arg1));
|
||||||
return result;
|
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;
|
long int result;
|
||||||
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0), "S"(arg1), "d"(arg2));
|
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0), "S"(arg1), "d"(arg2));
|
||||||
return result;
|
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)
|
unsigned long int arg3)
|
||||||
{
|
{
|
||||||
long int result;
|
long int result;
|
||||||
@ -37,7 +37,7 @@ long int __luna_syscall4(int sys_num, unsigned long int arg0, unsigned long int
|
|||||||
return result;
|
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)
|
unsigned long int arg3, unsigned long int arg4)
|
||||||
{
|
{
|
||||||
long int result;
|
long int result;
|
||||||
|
@ -36,7 +36,7 @@ template <typename IntegerType> static char* __unsignedtoa(IntegerType number, c
|
|||||||
while (number != 0)
|
while (number != 0)
|
||||||
{
|
{
|
||||||
IntegerType r = number % (IntegerType)base;
|
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++;
|
i++;
|
||||||
number /= base;
|
number /= base;
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ template <typename IntegerType> static char* __signedtoa(IntegerType number, cha
|
|||||||
while (number != 0)
|
while (number != 0)
|
||||||
{
|
{
|
||||||
IntegerType r = number % base;
|
IntegerType r = number % base;
|
||||||
arr[i] = (r > 9) ? (r - 10) + 'a' : r + '0';
|
arr[i] = (char)((r > 9) ? (r - 10) + 'a' : r + '0');
|
||||||
i++;
|
i++;
|
||||||
number /= base;
|
number /= base;
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ static int internal_printf(const char* format, PutString put_string_callback, ss
|
|||||||
switch (current_char)
|
switch (current_char)
|
||||||
{
|
{
|
||||||
case 'c': {
|
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();
|
if (buffer_insert_index == 1024) flush_buffer();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ static int internal_printf(const char* format, PutString put_string_callback, ss
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (buffer_insert_index > 0) flush_buffer();
|
if (buffer_insert_index > 0) flush_buffer();
|
||||||
return written;
|
return (int)written;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma GCC pop_options
|
#pragma GCC pop_options
|
||||||
|
@ -51,7 +51,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
long nwritten = syscall(SYS_write, s, strlen(s));
|
long nwritten = syscall(SYS_write, s, strlen(s));
|
||||||
nwritten += syscall(SYS_write, "\n", 1);
|
nwritten += syscall(SYS_write, "\n", 1);
|
||||||
return nwritten;
|
return (int)nwritten;
|
||||||
}
|
}
|
||||||
int snprintf(char* str, size_t max, const char* format, ...)
|
int snprintf(char* str, size_t max, const char* format, ...)
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
void* memcpy(void* dest, const void* src, size_t n)
|
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;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ extern "C"
|
|||||||
size_t dest_len = strlen(dest);
|
size_t dest_len = strlen(dest);
|
||||||
size_t i;
|
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';
|
*(char*)(dest + dest_len + i) = '\0';
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ extern "C"
|
|||||||
size_t dest_len = strlen(dest);
|
size_t dest_len = strlen(dest);
|
||||||
size_t i;
|
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';
|
*(char*)(dest + dest_len + i) = '\0';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user