From df0ebbbbcd8266b0ee389db6c32061c64c40f19e Mon Sep 17 00:00:00 2001 From: Jozef Nagy Date: Fri, 31 Jan 2025 21:22:48 +0100 Subject: [PATCH] Added extra warning levels and fixed existing warnings --- boot/Makefile | 2 +- boot/common/config/config.c | 40 ++++++++++--------------------------- boot/common/fs/uefi_sfs.c | 4 ++++ boot/common/mm/mman.c | 1 - 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/boot/Makefile b/boot/Makefile index 6794b6a..ea5ec46 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -28,7 +28,7 @@ export BUILD_DIR ?= build export SYSROOT_DIR ?= sysroot export ASFLAGS := $(foreach d, $(DEFINES), -D$d) -export CFLAGS := $(foreach d, $(DEFINES), -D$d) -ffreestanding -fno-stack-protector -fno-stack-check -MMD -MP +export CFLAGS := $(foreach d, $(DEFINES), -D$d) -Wall -Wextra -ffreestanding -fno-stack-protector -fno-stack-check -MMD -MP export LDFLAGS := -nostdlib export BOOT_ROOT := $(ROOT_DIR)/boot diff --git a/boot/common/config/config.c b/boot/common/config/config.c index 31d756e..1fef728 100644 --- a/boot/common/config/config.c +++ b/boot/common/config/config.c @@ -18,6 +18,8 @@ /*********************************************************************************/ #include +#include +#include #include #include @@ -33,44 +35,24 @@ char *config_paths[] = { void config_init(void) { - void *config_file; - char *config_buffer; - int filesize; + char *config_buf; + uint8_t open = 0; for (size_t i = 0; i < ARRAY_LENGTH(config_paths); i++) { - //config_file = fw_file_open(NULL, config_paths[i]); - if (config_file != NULL) { + vfs_read("\\System\\axkrnl", &config_buf); + if (config_buf != NULL) { + open = 1; break; } } - if (config_file == NULL) { - //print("No configuration file found! Please refer to the AxBoot documentation.\n"); - //print("Entering console...\n\n"); + if (open == 0) { + debug("Couldn't open a configuration file! Entering console...\n"); //console(); + while (1); } - //filesize = fw_file_size(config_file); - //config_buffer = malloc(filesize); - if (config_buffer == NULL) { - log("Entering console...\r\n\r\n"); - //console(); - } - - //fw_file_read(config_file, filesize, config_buffer); - // TODO: parse configuration file - //free(config_buffer); - - /* - if (config_errors != 0 || config_get_menu_root() == NULL) { - //print("\nConfiguration invalid!\n"); - //print("Please correct your config file.\n"); - //print("Entering console...\n\n"); - //console(); - } - */ - - //fw_file_close(config_file); + mem_free(config_buf); } \ No newline at end of file diff --git a/boot/common/fs/uefi_sfs.c b/boot/common/fs/uefi_sfs.c index c3f1310..bd15e2e 100644 --- a/boot/common/fs/uefi_sfs.c +++ b/boot/common/fs/uefi_sfs.c @@ -34,6 +34,8 @@ struct sfs_fsdata { struct vfs_drive *sfs_init(char *mountpoint) { + (void)mountpoint; + EFI_LOADED_IMAGE_PROTOCOL *loaded_image = NULL; EFI_GUID lip_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID; EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *iovolume; @@ -97,6 +99,8 @@ struct vfs_drive *sfs_init(char *mountpoint) size_t sfs_read(char *filename, char **buffer, struct vfs_drive *dev, void *fsdata) { + (void)dev; + struct sfs_fsdata *data = (struct sfs_fsdata *)fsdata; EFI_FILE_PROTOCOL *volume = data->volume; EFI_FILE_PROTOCOL *file; diff --git a/boot/common/mm/mman.c b/boot/common/mm/mman.c index 47d952d..ea4490a 100644 --- a/boot/common/mm/mman.c +++ b/boot/common/mm/mman.c @@ -119,7 +119,6 @@ void *mem_alloc(size_t n) int mem_allocat(void *addr, size_t npages) { EFI_STATUS status; - void *alloc; status = gBootServices->AllocatePages(AllocateAddress, EfiLoaderData, (EFI_UINTN)npages, addr); if (EFI_ERROR(status)) {