diff options
author | smh <smh@FreeBSD.org> | 2016-01-12 02:17:39 +0000 |
---|---|---|
committer | smh <smh@FreeBSD.org> | 2016-01-12 02:17:39 +0000 |
commit | 5bfbb8e2e501c2ed4209fb168e9878e598acc192 (patch) | |
tree | 4520281a4158d809c8e552821a3d2ed21e225359 /sys/boot/efi/loader | |
parent | 0517d6cfae2a854c90ccf67ec23cfa18945a67ac (diff) | |
download | FreeBSD-src-5bfbb8e2e501c2ed4209fb168e9878e598acc192.zip FreeBSD-src-5bfbb8e2e501c2ed4209fb168e9878e598acc192.tar.gz |
Enable warnings in EFI boot code
Set WARNS if not set for EFI boot code and fix the issues highlighted by
setting it.
Most components are set to WARNS level 6 with few being left at lower
levels due to the amount of changes needed to fix at higher levels.
Error types fixed:
* Missing / invalid casts
* Missing inner structs
* Unused vars
* Missing static for internal only funcs
* Missing prototypes
* Alignment changes
* Use of uninitialised vars
* Unknown pragma (intrinsic)
* Missing types etc due to missing includes
* printf formatting types
Reviewed by: emaste (in part)
MFC after: 2 weeks
X-MFC-With: r293268
Sponsored by: Multiplay
Differential Revision: https://reviews.freebsd.org/D4839
Diffstat (limited to 'sys/boot/efi/loader')
-rw-r--r-- | sys/boot/efi/loader/Makefile | 1 | ||||
-rw-r--r-- | sys/boot/efi/loader/arch/amd64/elf64_freebsd.c | 1 | ||||
-rw-r--r-- | sys/boot/efi/loader/arch/amd64/framebuffer.c | 4 | ||||
-rw-r--r-- | sys/boot/efi/loader/arch/arm/exec.c | 6 | ||||
-rw-r--r-- | sys/boot/efi/loader/arch/arm64/exec.c | 7 | ||||
-rw-r--r-- | sys/boot/efi/loader/autoload.c | 2 | ||||
-rw-r--r-- | sys/boot/efi/loader/bootinfo.c | 8 | ||||
-rw-r--r-- | sys/boot/efi/loader/copy.c | 2 | ||||
-rw-r--r-- | sys/boot/efi/loader/devicename.c | 4 | ||||
-rw-r--r-- | sys/boot/efi/loader/loader_efi.h | 2 | ||||
-rw-r--r-- | sys/boot/efi/loader/main.c | 20 |
11 files changed, 35 insertions, 22 deletions
diff --git a/sys/boot/efi/loader/Makefile b/sys/boot/efi/loader/Makefile index d6bd9c7..56f3cab 100644 --- a/sys/boot/efi/loader/Makefile +++ b/sys/boot/efi/loader/Makefile @@ -11,6 +11,7 @@ MK_SSP= no PROG= loader.sym INTERNALPROG= +WARNS?= 3 # architecture-specific loader code SRCS= autoload.c \ diff --git a/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c b/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c index c1dbec2..1b95cde 100644 --- a/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c +++ b/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c @@ -100,7 +100,6 @@ elf64_exec(struct preloaded_file *fp) ACPI_TABLE_RSDP *rsdp; char buf[24]; int revision; - EFI_STATUS status; rsdp = efi_get_table(&acpi20_guid); if (rsdp == NULL) { diff --git a/sys/boot/efi/loader/arch/amd64/framebuffer.c b/sys/boot/efi/loader/arch/amd64/framebuffer.c index 04b8804..d861ee4 100644 --- a/sys/boot/efi/loader/arch/amd64/framebuffer.c +++ b/sys/boot/efi/loader/arch/amd64/framebuffer.c @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); #include <efipciio.h> #include <machine/metadata.h> +#include "framebuffer.h" + static EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; static EFI_GUID pciio_guid = EFI_PCI_IO_PROTOCOL_GUID; static EFI_GUID uga_guid = EFI_UGA_DRAW_PROTOCOL_GUID; @@ -270,7 +272,7 @@ efifb_from_uga(struct efi_fb *efifb, EFI_UGA_DRAW_PROTOCOL *uga) char *ev, *p; EFI_STATUS status; ssize_t offset; - uint64_t fbaddr, fbsize; + uint64_t fbaddr; uint32_t horiz, vert, stride; uint32_t np, depth, refresh; diff --git a/sys/boot/efi/loader/arch/arm/exec.c b/sys/boot/efi/loader/arch/arm/exec.c index 7c51e6e..716c7d3 100644 --- a/sys/boot/efi/loader/arch/arm/exec.c +++ b/sys/boot/efi/loader/arch/arm/exec.c @@ -44,8 +44,9 @@ __FBSDID("$FreeBSD$"); #include "loader_efi.h" extern vm_offset_t md_load(char *, vm_offset_t *); +extern int bi_load(char *, vm_offset_t *, vm_offset_t *); -int +static int __elfN(arm_load)(char *filename, u_int64_t dest, struct preloaded_file **result) { @@ -58,7 +59,7 @@ __elfN(arm_load)(char *filename, u_int64_t dest, return (0); } -int +static int __elfN(arm_exec)(struct preloaded_file *fp) { struct file_metadata *fmp; @@ -66,7 +67,6 @@ __elfN(arm_exec)(struct preloaded_file *fp) Elf_Ehdr *e; int error; void (*entry)(void *); - EFI_STATUS status; if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) return (EFTYPE); diff --git a/sys/boot/efi/loader/arch/arm64/exec.c b/sys/boot/efi/loader/arch/arm64/exec.c index 0746c05..a0f8b83 100644 --- a/sys/boot/efi/loader/arch/arm64/exec.c +++ b/sys/boot/efi/loader/arch/arm64/exec.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include "platform/acfreebsd.h" #include "acconfig.h" #define ACPI_SYSTEM_XFACE +#define ACPI_USE_SYSTEM_INTTYPES #include "actypes.h" #include "actbl.h" @@ -74,8 +75,6 @@ elf64_exec(struct preloaded_file *fp) size_t clean_size; struct file_metadata *md; ACPI_TABLE_RSDP *rsdp; - EFI_STATUS status; - EFI_PHYSICAL_ADDRESS addr; Elf_Ehdr *ehdr; char buf[24]; int err, revision; @@ -119,8 +118,8 @@ elf64_exec(struct preloaded_file *fp) return (err); /* Clean D-cache under kernel area and invalidate whole I-cache */ - clean_addr = efi_translate(fp->f_addr); - clean_size = efi_translate(kernendp) - clean_addr; + clean_addr = (vm_offset_t)efi_translate(fp->f_addr); + clean_size = (vm_offset_t)efi_translate(kernendp) - clean_addr; cpu_flush_dcache((void *)clean_addr, clean_size); cpu_inval_icache(NULL, 0); diff --git a/sys/boot/efi/loader/autoload.c b/sys/boot/efi/loader/autoload.c index 694a6da..c1eb849 100644 --- a/sys/boot/efi/loader/autoload.c +++ b/sys/boot/efi/loader/autoload.c @@ -27,6 +27,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "loader_efi.h" + int efi_autoload(void) { diff --git a/sys/boot/efi/loader/bootinfo.c b/sys/boot/efi/loader/bootinfo.c index ac665b2..c6a76ab 100644 --- a/sys/boot/efi/loader/bootinfo.c +++ b/sys/boot/efi/loader/bootinfo.c @@ -55,6 +55,8 @@ __FBSDID("$FreeBSD$"); #include <fdt_platform.h> #endif +int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp); + extern EFI_SYSTEM_TABLE *ST; static const char howto_switches[] = "aCdrgDmphsv"; @@ -122,7 +124,7 @@ bi_copyenv(vm_offset_t start) /* Traverse the environment. */ for (ep = environ; ep != NULL; ep = ep->ev_next) { len = strlen(ep->ev_name); - if (archsw.arch_copyin(ep->ev_name, addr, len) != len) + if ((size_t)archsw.arch_copyin(ep->ev_name, addr, len) != len) break; addr += len; if (archsw.arch_copyin("=", addr, 1) != 1) @@ -130,7 +132,7 @@ bi_copyenv(vm_offset_t start) addr++; if (ep->ev_value != NULL) { len = strlen(ep->ev_value); - if (archsw.arch_copyin(ep->ev_value, addr, len) != len) + if ((size_t)archsw.arch_copyin(ep->ev_value, addr, len) != len) break; addr += len; } @@ -351,7 +353,7 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp) #endif #if defined(__arm__) vm_offset_t vaddr; - int i; + size_t i; /* * These metadata addreses must be converted for kernel after * relocation. diff --git a/sys/boot/efi/loader/copy.c b/sys/boot/efi/loader/copy.c index 8714786..128196e 100644 --- a/sys/boot/efi/loader/copy.c +++ b/sys/boot/efi/loader/copy.c @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); #include <efi.h> #include <efilib.h> +#include "loader_efi.h" + #ifndef EFI_STAGING_SIZE #define EFI_STAGING_SIZE 48 #endif diff --git a/sys/boot/efi/loader/devicename.c b/sys/boot/efi/loader/devicename.c index 1ba33e8..45f9871 100644 --- a/sys/boot/efi/loader/devicename.c +++ b/sys/boot/efi/loader/devicename.c @@ -31,11 +31,13 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #include <string.h> #include <sys/disklabel.h> -#include "bootstrap.h" +#include <bootstrap.h> #include <efi.h> #include <efilib.h> +#include "loader_efi.h" + static int efi_parsedev(struct devdesc **, const char *, const char **); /* diff --git a/sys/boot/efi/loader/loader_efi.h b/sys/boot/efi/loader/loader_efi.h index 5819d78..ee7c4bb 100644 --- a/sys/boot/efi/loader/loader_efi.h +++ b/sys/boot/efi/loader/loader_efi.h @@ -31,6 +31,8 @@ #ifndef _LOADER_EFI_COPY_H_ #define _LOADER_EFI_COPY_H_ +#include <stand.h> + int efi_autoload(void); int efi_getdev(void **vdev, const char *devspec, const char **path); diff --git a/sys/boot/efi/loader/main.c b/sys/boot/efi/loader/main.c index 1fa031f..ddd96b4 100644 --- a/sys/boot/efi/loader/main.c +++ b/sys/boot/efi/loader/main.c @@ -68,6 +68,7 @@ main(int argc, CHAR16 *argv[]) EFI_LOADED_IMAGE *img; EFI_GUID *guid; int i, j, vargood; + UINTN k; /* * XXX Chicken-and-egg problem; we want to have console output @@ -155,10 +156,10 @@ main(int argc, CHAR16 *argv[]) archsw.arch_copyout = efi_copyout; archsw.arch_readin = efi_readin; - for (i = 0; i < ST->NumberOfTableEntries; i++) { - guid = &ST->ConfigurationTable[i].VendorGuid; + for (k = 0; k < ST->NumberOfTableEntries; k++) { + guid = &ST->ConfigurationTable[k].VendorGuid; if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) { - smbios_detect(ST->ConfigurationTable[i].VendorTable); + smbios_detect(ST->ConfigurationTable[k].VendorTable); break; } } @@ -242,8 +243,9 @@ command_memmap(int argc, char *argv[]) for (i = 0, p = map; i < ndesc; i++, p = NextMemoryDescriptor(p, dsz)) { - printf("%23s %012lx %012lx %08lx ", types[p->Type], - p->PhysicalStart, p->VirtualStart, p->NumberOfPages); + printf("%23s %012jx %012jx %08jx ", types[p->Type], + (uintmax_t)p->PhysicalStart, (uintmax_t)p->VirtualStart, + (uintmax_t)p->NumberOfPages); if (p->Attribute & EFI_MEMORY_UC) printf("UC "); if (p->Attribute & EFI_MEMORY_WC) @@ -284,9 +286,10 @@ guid_to_string(EFI_GUID *guid) static int command_configuration(int argc, char *argv[]) { - int i; + UINTN i; - printf("NumberOfTableEntries=%ld\n", ST->NumberOfTableEntries); + printf("NumberOfTableEntries=%lu\n", + (unsigned long)ST->NumberOfTableEntries); for (i = 0; i < ST->NumberOfTableEntries; i++) { EFI_GUID *guid; @@ -382,9 +385,8 @@ command_nvram(int argc, char *argv[]) CHAR16 *data; EFI_STATUS status; EFI_GUID varguid = { 0,0,0,{0,0,0,0,0,0,0,0} }; - UINTN varsz, datasz; + UINTN varsz, datasz, i; SIMPLE_TEXT_OUTPUT_INTERFACE *conout; - int i; conout = ST->ConOut; |