david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[build] Enable warnings when building utilities

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2012-04-10 19:38:54 +01:00
parent 96a8c70a0c
commit 196751ce95
8 changed files with 39 additions and 40 deletions

View File

@ -7,6 +7,7 @@ CLEANUP :=
CFLAGS := CFLAGS :=
ASFLAGS := ASFLAGS :=
LDFLAGS := LDFLAGS :=
HOST_CFLAGS :=
MAKEDEPS := Makefile MAKEDEPS := Makefile
############################################################################### ###############################################################################

View File

@ -381,6 +381,7 @@ CFLAGS += -g
ifeq ($(CCTYPE),gcc) ifeq ($(CCTYPE),gcc)
CFLAGS += -ffreestanding CFLAGS += -ffreestanding
CFLAGS += -Wall -W -Wformat-nonliteral CFLAGS += -Wall -W -Wformat-nonliteral
HOST_CFLAGS += -Wall -W -Wformat-nonliteral
endif endif
ifeq ($(CCTYPE),icc) ifeq ($(CCTYPE),icc)
CFLAGS += -fno-builtin CFLAGS += -fno-builtin
@ -411,12 +412,14 @@ endif
CFLAGS += $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS) CFLAGS += $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS)
ASFLAGS += $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS) ASFLAGS += $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS)
LDFLAGS += $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS) LDFLAGS += $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS)
HOST_CFLAGS += -O2 -g
# Inhibit -Werror if NO_WERROR is specified on make command line # Inhibit -Werror if NO_WERROR is specified on make command line
# #
ifneq ($(NO_WERROR),1) ifneq ($(NO_WERROR),1)
CFLAGS += -Werror CFLAGS += -Werror
ASFLAGS += --fatal-warnings ASFLAGS += --fatal-warnings
HOST_CFLAGS += -Werror
endif endif
# Function trace recorder state in the last build. This is needed # Function trace recorder state in the last build. This is needed
@ -1057,13 +1060,13 @@ endif # defined(BIN)
# #
$(NRV2B) : util/nrv2b.c $(MAKEDEPS) $(NRV2B) : util/nrv2b.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@" $(QM)$(ECHO) " [HOSTCC] $@"
$(Q)$(HOST_CC) -O2 -DENCODE -DDECODE -DMAIN -DVERBOSE -DNDEBUG \ $(Q)$(HOST_CC) $(HOST_CFLAGS) -DENCODE -DDECODE -DMAIN -DVERBOSE \
-DBITSIZE=32 -DENDIAN=0 -o $@ $< -DNDEBUG -DBITSIZE=32 -DENDIAN=0 -o $@ $<
CLEANUP += $(NRV2B) CLEANUP += $(NRV2B)
$(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS) $(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@" $(QM)$(ECHO) " [HOSTCC] $@"
$(Q)$(HOST_CC) -O2 -o $@ $< $(Q)$(HOST_CC) $(HOST_CFLAGS) -o $@ $<
CLEANUP += $(ZBIN) CLEANUP += $(ZBIN)
############################################################################### ###############################################################################
@ -1071,23 +1074,25 @@ CLEANUP += $(ZBIN)
# The EFI image converter # The EFI image converter
# #
ELF2EFI_CFLAGS := -I$(BINUTILS_DIR)/include -I$(BFD_DIR)/include \ ELF2EFI_CFLAGS := -I$(BINUTILS_DIR)/include -I$(BFD_DIR)/include \
-I$(ZLIB_DIR)/include -idirafter include \ -I$(ZLIB_DIR)/include -idirafter include
-L$(BINUTILS_DIR)/lib -L$(BFD_DIR)/lib -L$(ZLIB_DIR)/lib \ ELF2EFI_LDFLAGS := -L$(BINUTILS_DIR)/lib -L$(BFD_DIR)/lib -L$(ZLIB_DIR)/lib \
-lbfd -ldl -liberty -lz -Wl,--no-warn-search-mismatch -lbfd -ldl -liberty -lz -Wl,--no-warn-search-mismatch
$(ELF2EFI32) : util/elf2efi.c $(MAKEDEPS) $(ELF2EFI32) : util/elf2efi.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@" $(QM)$(ECHO) " [HOSTCC] $@"
$(Q)$(HOST_CC) $< $(ELF2EFI_CFLAGS) -DEFI_TARGET_IA32 -O2 -o $@ $(Q)$(HOST_CC) $(HOST_CFLAGS) $(ELF2EFI_CFLAGS) -DEFI_TARGET_IA32 $< \
$(ELF2EFI_LDFLAGS) -o $@
CLEANUP += $(ELF2EFI32) CLEANUP += $(ELF2EFI32)
$(ELF2EFI64) : util/elf2efi.c $(MAKEDEPS) $(ELF2EFI64) : util/elf2efi.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@" $(QM)$(ECHO) " [HOSTCC] $@"
$(Q)$(HOST_CC) $< $(ELF2EFI_CFLAGS) -DEFI_TARGET_X64 -O2 -o $@ $(Q)$(HOST_CC) $(HOST_CFLAGS) $(ELF2EFI_CFLAGS) -DEFI_TARGET_X64 $< \
$(ELF2EFI_LDFLAGS) -o $@
CLEANUP += $(ELF2EFI64) CLEANUP += $(ELF2EFI64)
$(EFIROM) : util/efirom.c $(MAKEDEPS) $(EFIROM) : util/efirom.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@" $(QM)$(ECHO) " [HOSTCC] $@"
$(Q)$(HOST_CC) -idirafter include -O2 -o $@ $< $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
CLEANUP += $(EFIROM) CLEANUP += $(EFIROM)
############################################################################### ###############################################################################
@ -1096,7 +1101,7 @@ CLEANUP += $(EFIROM)
# #
$(ICCFIX) : util/iccfix.c $(MAKEDEPS) $(ICCFIX) : util/iccfix.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@" $(QM)$(ECHO) " [HOSTCC] $@"
$(Q)$(HOST_CC) -idirafter include -O2 -o $@ $< $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
CLEANUP += $(ICCFIX) CLEANUP += $(ICCFIX)
############################################################################### ###############################################################################
@ -1105,7 +1110,7 @@ CLEANUP += $(ICCFIX)
# #
$(EINFO) : util/einfo.c $(MAKEDEPS) $(EINFO) : util/einfo.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@" $(QM)$(ECHO) " [HOSTCC] $@"
$(Q)$(HOST_CC) -idirafter include -O2 -o $@ $< $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
CLEANUP += $(EINFO) CLEANUP += $(EINFO)
############################################################################### ###############################################################################

View File

@ -56,18 +56,6 @@ static void * xmalloc ( size_t len ) {
return ptr; return ptr;
} }
/**
* Get file size
*
* @v file File
* @v len File size
*/
static size_t file_size ( FILE *file ) {
ssize_t len;
return len;
}
/** /**
* Read information from PE headers * Read information from PE headers
* *
@ -239,15 +227,15 @@ static int parse_options ( const int argc, char **argv,
} }
int main ( int argc, char **argv ) { int main ( int argc, char **argv ) {
struct options opts = { struct options opts;
}; int infile_index;
unsigned int infile_index;
const char *infile_name; const char *infile_name;
const char *outfile_name; const char *outfile_name;
FILE *infile; FILE *infile;
FILE *outfile; FILE *outfile;
/* Parse command-line arguments */ /* Parse command-line arguments */
memset ( &opts, 0, sizeof ( opts ) );
infile_index = parse_options ( argc, argv, &opts ); infile_index = parse_options ( argc, argv, &opts );
if ( argc != ( infile_index + 2 ) ) { if ( argc != ( infile_index + 2 ) ) {
print_help ( argv[0] ); print_help ( argv[0] );

View File

@ -20,6 +20,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -49,7 +50,8 @@ struct einfo {
* @v infile Filename * @v infile Filename
* @v opts Command-line options * @v opts Command-line options
*/ */
static void einfo ( const char *infile, struct options *opts ) { static void einfo ( const char *infile,
struct options *opts __attribute__ (( unused )) ) {
int fd; int fd;
struct stat stat; struct stat stat;
size_t len; size_t len;
@ -85,9 +87,9 @@ static void einfo ( const char *infile, struct options *opts ) {
for ( einfo = start ; ( ( void * ) einfo ) < ( start + len ) ; for ( einfo = start ; ( ( void * ) einfo ) < ( start + len ) ;
einfo = ( ( ( void * ) einfo ) + einfo->size ) ) { einfo = ( ( ( void * ) einfo ) + einfo->size ) ) {
printf ( "%08x\t%s\t%d\t%s\n", einfo->error, printf ( "%08x\t%s\t%d\t%s\n", einfo->error,
( ( ( void * ) einfo ) + einfo->file ), ( ( ( char * ) einfo ) + einfo->file ),
einfo->line, einfo->line,
( ( ( void * ) einfo ) + einfo->desc ) ); ( ( ( char * ) einfo ) + einfo->desc ) );
} }
} }
@ -115,8 +117,7 @@ static void print_help ( const char *program_name ) {
* @v opts Options structure to populate * @v opts Options structure to populate
*/ */
static int parse_options ( const int argc, char **argv, static int parse_options ( const int argc, char **argv,
struct options *opts ) { struct options *opts __attribute__ (( unused )) ) {
char *end;
int c; int c;
while (1) { while (1) {
@ -147,7 +148,7 @@ static int parse_options ( const int argc, char **argv,
int main ( int argc, char **argv ) { int main ( int argc, char **argv ) {
struct options opts = { struct options opts = {
}; };
unsigned int infile_index; int infile_index;
const char *infile; const char *infile;
/* Parse command-line arguments */ /* Parse command-line arguments */

View File

@ -459,7 +459,8 @@ static struct pe_section * process_section ( bfd *bfd,
* @v rel Relocation entry * @v rel Relocation entry
* @v pe_reltab PE relocation table to fill in * @v pe_reltab PE relocation table to fill in
*/ */
static void process_reloc ( bfd *bfd, asection *section, arelent *rel, static void process_reloc ( bfd *bfd __attribute__ (( unused )),
asection *section, arelent *rel,
struct pe_relocs **pe_reltab ) { struct pe_relocs **pe_reltab ) {
reloc_howto_type *howto = rel->howto; reloc_howto_type *howto = rel->howto;
asymbol *sym = *(rel->sym_ptr_ptr); asymbol *sym = *(rel->sym_ptr_ptr);
@ -637,7 +638,7 @@ static void write_pe_file ( struct pe_header *pe_header,
for ( section = pe_sections ; section ; section = section->next ) { for ( section = pe_sections ; section ; section = section->next ) {
if ( fseek ( pe, section->hdr.PointerToRawData, if ( fseek ( pe, section->hdr.PointerToRawData,
SEEK_SET ) != 0 ) { SEEK_SET ) != 0 ) {
eprintf ( "Could not seek to %lx: %s\n", eprintf ( "Could not seek to %x: %s\n",
section->hdr.PointerToRawData, section->hdr.PointerToRawData,
strerror ( errno ) ); strerror ( errno ) );
exit ( 1 ); exit ( 1 );
@ -786,7 +787,7 @@ int main ( int argc, char **argv ) {
struct options opts = { struct options opts = {
.subsystem = EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION, .subsystem = EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,
}; };
unsigned int infile_index; int infile_index;
const char *infile; const char *infile;
const char *outfile; const char *outfile;

View File

@ -2,6 +2,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
@ -49,7 +50,7 @@ static int ICCFIX ( void *elf ) {
( align >= ICC_ALIGN_HACK_FACTOR ) ) { ( align >= ICC_ALIGN_HACK_FACTOR ) ) {
new_align = ( align / ICC_ALIGN_HACK_FACTOR ); new_align = ( align / ICC_ALIGN_HACK_FACTOR );
shdr->sh_addralign = new_align; shdr->sh_addralign = new_align;
dprintf ( "Section \"%s\": alignment %d->%d\n", dprintf ( "Section \"%s\": alignment %ld->%ld\n",
name, align, new_align ); name, align, new_align );
} }
} }

View File

@ -77,7 +77,7 @@ static __inline__ void Error(char *message)
/* These will be a complete waste of time on a lo-endian */ /* These will be a complete waste of time on a lo-endian */
/* system, but it only gets done once so WTF. */ /* system, but it only gets done once so WTF. */
static unsigned long i86ul_to_host(unsigned long ul) static unsigned long __attribute__ (( unused )) i86ul_to_host(unsigned long ul)
{ {
unsigned long res = 0; unsigned long res = 0;
int i; int i;
@ -375,7 +375,6 @@ static
int swd_init(struct ucl_swd *s, const uint8_t *dict, unsigned int dict_len) int swd_init(struct ucl_swd *s, const uint8_t *dict, unsigned int dict_len)
{ {
unsigned int i = 0; unsigned int i = 0;
int c = 0;
if (s->n == 0) if (s->n == 0)
s->n = N; s->n = N;
@ -439,7 +438,7 @@ static
void swd_exit(struct ucl_swd *s) void swd_exit(struct ucl_swd *s)
{ {
/* unused s */ /* unused s */
( void ) s;
} }
#define swd_pos2off(s,pos) \ #define swd_pos2off(s,pos) \

View File

@ -218,7 +218,8 @@ static int process_zinfo_pack ( struct input_file *input,
return 0; return 0;
} }
static int process_zinfo_payl ( struct input_file *input, static int process_zinfo_payl ( struct input_file *input
__attribute__ (( unused )),
struct output_file *output, struct output_file *output,
union zinfo_record *zinfo ) { union zinfo_record *zinfo ) {
struct zinfo_payload *payload = &zinfo->payload; struct zinfo_payload *payload = &zinfo->payload;
@ -229,9 +230,11 @@ static int process_zinfo_payl ( struct input_file *input,
if ( DEBUG ) { if ( DEBUG ) {
fprintf ( stderr, "PAYL at %#zx\n", output->hdr_len ); fprintf ( stderr, "PAYL at %#zx\n", output->hdr_len );
} }
return 0;
} }
static int process_zinfo_add ( struct input_file *input, static int process_zinfo_add ( struct input_file *input
__attribute__ (( unused )),
struct output_file *output, struct output_file *output,
size_t len, size_t len,
struct zinfo_add *add, struct zinfo_add *add,