From f8c0b317aa734d57d1e0ffff594124a0b59b93ab Mon Sep 17 00:00:00 2001 From: mintsuki Date: Wed, 29 Apr 2020 16:53:05 +0200 Subject: [PATCH] Resolve most GCC warnings --- qloader2.bin | Bin 32768 -> 32768 bytes src/Makefile | 3 ++- src/fs/echfs.c | 4 ++-- src/lib/blib.c | 3 ++- src/lib/blib.h | 2 +- src/lib/part.c | 3 ++- src/lib/real.c | 6 ++---- src/lib/real.h | 2 +- src/main.c | 18 ++++++++++-------- src/protos/stivale.c | 6 ++++-- 10 files changed, 26 insertions(+), 21 deletions(-) diff --git a/qloader2.bin b/qloader2.bin index 3e2128aba686bd3efff2af1e0b634be7c9b2c250..28b58c0741bc9ac63d2a14ec823e4fdb53e72c07 100644 GIT binary patch delta 6183 zcmZu#4Oo;__J8j%1EUViAdCU>F?@+AprELPD5!%dDgz?}ilC;lub8cCGwM@IpabSK zjb&#uYt=-oHM1u-byG_NQAbM)%`HFDuxx#CtUrFNl2Y&goI7AXZSV8E_dWNV-#Pc3 zbI<*lsjXGi)+%=SD8q&}xv~sr1;ORt)Pb#@=)}{vcSz5IN;$9M&XLaoY1~-fWDW2<>EO;g((il;(^NSD_3zChj)S&CtKSqPIBUm*JBso^gYWoOFT8bS% z*l(z%jTkn8r}hd9BQZTEJRiDMq{Fb|c^7F|*(*2D70Z+CtnNBN+6_bDT(7jzq%^av zygdjFA=hGdG~2V1$da~B@WI;1ZXMlgd5lx9M1zYIy|srBB9FbBS8gr{UagMt1ZJ&fNdzQdM>g`qyL@D{{^e0a~ z+JdCxcF3>bN&ZH5R!PpL4ayo(9Fa0XZ-c-59eP{3VTdv!p#(A-~btqPSh12Q@ca1wo z{Mj$8I*EN;#8_*D_)Z(fTDKDEncy8qVat@Vx_XK+WTrF+JDy;-iq{g3y>Bcw(nwra z-m)M+yq+N+sh&8zr9!jgR#8jE;Z{-Uc&Q|a^dF=ptJH7*J2qI#CH{kIX!`bV!9Gsj zO;eR1%|aJ&ck&c_i>v;GHD4P20D0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i|dpj8Nlp!jxAo{o3jgI*PY25E~MS>Y3@ zz8YSkM(bqy9_FW~r`Bq0(ufXB4GOl}a1P<}zAUDGoaeHW3 z2Dd@exK+ZuHH68tx(&}*8xO$}c3tCPcwRNs6I(LI-3}`bQ5@2_7Mz-468?T%YI3hi zSWIJQ#*)~kSu=eI*-B?;r^Dyl1KE?q(9HFl?qrJ?GW_mteW7Vrwo0A5ejUSn((vc; zHsCM7nD;EhY=Ut+Pyf*Rji$@_8%Xfe@EZ0kj2B>RgR!G& zE({??`uW26Tr1EuGFg&&9^h)g;a4I4P-ZKP3cy9c6MuRbyJ1w(%teXhK5AMNPps4q zu$8{HXa>>J?nSc|Kef`)MQP+1%`Hk%TsuUqMFk{?zEhMwrKepKXTkx-3z&O`Q{fj3OC(SNSgkn?`&n7$R=Hhf>pht^m zka$WK&n8(ke{l$zK~0NOV6I!7qMCe66nE42i$duEpfuC&#pz@k{e5w|$^mtLN}}YK zgpg0EsU$vZKj7AaG5qOatbi?(LHUwIc=dj#B%PS(8GzmN_mWAVWda*brqBg!JbVG% z5A$5gv-4G!Zc*HcdPBGT5eWSC%oM`tp}(`~#FvgQjaSV-A&MVJ4%}OsPClfb(z#?N z?JiAJJ$+IXYbjwvsHQAJ^#Poj1=1=9R>wXU#bwg!!LkU&;1_gV*&O`(ElVLy^m17u zd6$M6Q^-M@3v(-7X-tHf2l!L^zA>JhqTR+6#g{$wx^X($Lo=7mCnxBWOVTs%hj+CH zAl#99%vtB-RQl8q3}UDjc|%cbhu6s8=;uq4M)xXOHH66@3Un@%jDEBrAzp+F`4*#Qu!Qek|qu_~fZ&Pr2Ps+am#xHoT diff --git a/src/Makefile b/src/Makefile index b80522d0..ed29b8e5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -12,7 +12,8 @@ INTERNAL_CFLAGS = \ -mno-80387 \ -ffreestanding \ -fno-stack-protector \ - -I. + -I. \ + -Wno-address-of-packed-member LDFLAGS = -O2 diff --git a/src/fs/echfs.c b/src/fs/echfs.c index 6f0654d9..ceddfe13 100644 --- a/src/fs/echfs.c +++ b/src/fs/echfs.c @@ -6,8 +6,8 @@ #include struct echfs_identity_table { - uint8_t jmp[4]; - uint8_t signature[8]; + uint8_t jmp[4]; + char signature[8]; uint64_t block_count; uint64_t dir_length; uint64_t block_size; diff --git a/src/lib/blib.c b/src/lib/blib.c index 90b381e5..0e25df2a 100644 --- a/src/lib/blib.c +++ b/src/lib/blib.c @@ -8,7 +8,7 @@ #include #include -void panic(const char *str) { +__attribute__((noreturn)) void panic(const char *str) { print("PANIC: %s", str); for (;;) { asm volatile ("cli; hlt"); @@ -153,6 +153,7 @@ __attribute__((naked)) int _pit_sleep_and_quit_on_keypress(uint32_t ticks) { // Exit "ret\n\t" ); + (void)ticks; } static bool int_08_hooked = false; diff --git a/src/lib/blib.h b/src/lib/blib.h index 2c1b9e2e..9cc1a4de 100644 --- a/src/lib/blib.h +++ b/src/lib/blib.h @@ -4,7 +4,7 @@ #include #include -void panic(const char *str); +__attribute__((noreturn)) void panic(const char *str); void pit_sleep(uint64_t pit_ticks); int pit_sleep_and_quit_on_keypress(uint32_t pit_ticks); diff --git a/src/lib/part.c b/src/lib/part.c index 799dbfcf..f9952712 100644 --- a/src/lib/part.c +++ b/src/lib/part.c @@ -66,7 +66,8 @@ static int gpt_get_part(struct part *ret, int drive, int partition) { if (header.revision != 0x00010000) return NO_PARTITION; // parse the entries if reached here - if (partition >= header.number_of_partition_entries) return NO_PARTITION; + if ((uint32_t)partition >= header.number_of_partition_entries) + return NO_PARTITION; struct gpt_entry entry = {0}; read(drive, &entry, diff --git a/src/lib/real.c b/src/lib/real.c index 71c243f5..8bfeb5f7 100644 --- a/src/lib/real.c +++ b/src/lib/real.c @@ -2,10 +2,7 @@ #include __attribute__((naked)) -void rm_int( - uint8_t int_no, - struct rm_regs *out_regs, - struct rm_regs *in_regs) { +void rm_int(uint8_t int_no, struct rm_regs *out_regs, struct rm_regs *in_regs) { asm ( // Self-modifying code: int $int_no "mov al, byte ptr ss:[esp+4]\n\t" @@ -110,4 +107,5 @@ void rm_int( // in_regs "7: .long 0\n\t" ); + (void)int_no; (void)out_regs; (void)in_regs; } diff --git a/src/lib/real.h b/src/lib/real.h index dfdd6b76..545cbded 100644 --- a/src/lib/real.h +++ b/src/lib/real.h @@ -22,6 +22,6 @@ struct rm_regs { uint32_t eax; }; -void rm_int(uint8_t, struct rm_regs *, struct rm_regs *); +void rm_int(uint8_t int_no, struct rm_regs *out_regs, struct rm_regs *in_regs); #endif diff --git a/src/main.c b/src/main.c index 373cc3c2..8f44f728 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,15 @@ asm ( ".section .entry\n\t" "xor dh, dh\n\t" "push edx\n\t" + + // Zero out .bss + "xor al, al\n\t" + "lea edi, bss_begin\n\t" + "lea ecx, bss_end\n\t" + "lea edx, bss_begin\n\t" + "sub ecx, edx\n\t" + "rep stosb\n\t" + "call main\n\t" ); @@ -31,7 +40,7 @@ refresh: print("Select an entry:\n\n"); - size_t max_entries; + int max_entries; for (max_entries = 0; ; max_entries++) { if (config_get_entry_name(config_entry_name, max_entries, 1024) == -1) break; @@ -79,16 +88,9 @@ refresh: } } -extern symbol bss_begin; -extern symbol bss_end; - void main(int boot_drive) { struct file_handle f; - // Zero out .bss section - for (uint8_t *p = bss_begin; p < bss_end; p++) - *p = 0; - // Initial prompt. init_vga_textmode(); diff --git a/src/protos/stivale.c b/src/protos/stivale.c index 0c5ea3ef..13a6800d 100644 --- a/src/protos/stivale.c +++ b/src/protos/stivale.c @@ -50,8 +50,6 @@ void stivale_load(struct file_handle *fd, char *cmdline) { int ret; - print("stivale: %u-bit ELF file detected\n", bits); - switch (bits) { case 64: ret = elf64_load_section(fd, &stivale_hdr, ".stivalehdr", sizeof(struct stivale_header)); @@ -59,8 +57,12 @@ void stivale_load(struct file_handle *fd, char *cmdline) { case 32: ret = elf32_load_section(fd, &stivale_hdr, ".stivalehdr", sizeof(struct stivale_header)); break; + default: + panic("Not 32 nor 64 bit x86 ELF file."); } + print("stivale: %u-bit ELF file detected\n", bits); + switch (ret) { case 1: panic("stivale: File is not a valid ELF.\n");