瀏覽代碼

[build] Enable warnings when building utilities

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 年之前
父節點
當前提交
196751ce95
共有 8 個檔案被更改,包括 39 行新增40 行删除
  1. 1
    0
      src/Makefile
  2. 15
    10
      src/Makefile.housekeeping
  3. 3
    15
      src/util/efirom.c
  4. 7
    6
      src/util/einfo.c
  5. 4
    3
      src/util/elf2efi.c
  6. 2
    1
      src/util/iccfix.c
  7. 2
    3
      src/util/nrv2b.c
  8. 5
    2
      src/util/zbin.c

+ 1
- 0
src/Makefile 查看文件

7
 CFLAGS		:=
7
 CFLAGS		:=
8
 ASFLAGS		:=
8
 ASFLAGS		:=
9
 LDFLAGS		:=
9
 LDFLAGS		:=
10
+HOST_CFLAGS	:=
10
 MAKEDEPS	:= Makefile
11
 MAKEDEPS	:= Makefile
11
 
12
 
12
 ###############################################################################
13
 ###############################################################################

+ 15
- 10
src/Makefile.housekeeping 查看文件

381
 ifeq ($(CCTYPE),gcc)
381
 ifeq ($(CCTYPE),gcc)
382
 CFLAGS		+= -ffreestanding
382
 CFLAGS		+= -ffreestanding
383
 CFLAGS		+= -Wall -W -Wformat-nonliteral
383
 CFLAGS		+= -Wall -W -Wformat-nonliteral
384
+HOST_CFLAGS	+= -Wall -W -Wformat-nonliteral
384
 endif
385
 endif
385
 ifeq ($(CCTYPE),icc)
386
 ifeq ($(CCTYPE),icc)
386
 CFLAGS		+= -fno-builtin
387
 CFLAGS		+= -fno-builtin
411
 CFLAGS		+= $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS)
412
 CFLAGS		+= $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS)
412
 ASFLAGS		+= $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS)
413
 ASFLAGS		+= $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS)
413
 LDFLAGS		+= $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS)
414
 LDFLAGS		+= $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS)
415
+HOST_CFLAGS	+= -O2 -g
414
 
416
 
415
 # Inhibit -Werror if NO_WERROR is specified on make command line
417
 # Inhibit -Werror if NO_WERROR is specified on make command line
416
 #
418
 #
417
 ifneq ($(NO_WERROR),1)
419
 ifneq ($(NO_WERROR),1)
418
 CFLAGS		+= -Werror
420
 CFLAGS		+= -Werror
419
 ASFLAGS		+= --fatal-warnings
421
 ASFLAGS		+= --fatal-warnings
422
+HOST_CFLAGS	+= -Werror
420
 endif
423
 endif
421
 
424
 
422
 # Function trace recorder state in the last build.  This is needed
425
 # Function trace recorder state in the last build.  This is needed
1057
 #
1060
 #
1058
 $(NRV2B) : util/nrv2b.c $(MAKEDEPS)
1061
 $(NRV2B) : util/nrv2b.c $(MAKEDEPS)
1059
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1062
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1060
-	$(Q)$(HOST_CC) -O2 -DENCODE -DDECODE -DMAIN -DVERBOSE -DNDEBUG \
1061
-		       -DBITSIZE=32 -DENDIAN=0 -o $@ $<
1063
+	$(Q)$(HOST_CC) $(HOST_CFLAGS) -DENCODE -DDECODE -DMAIN -DVERBOSE \
1064
+		       -DNDEBUG -DBITSIZE=32 -DENDIAN=0 -o $@ $<
1062
 CLEANUP	+= $(NRV2B)
1065
 CLEANUP	+= $(NRV2B)
1063
 
1066
 
1064
 $(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS)
1067
 $(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS)
1065
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1068
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1066
-	$(Q)$(HOST_CC) -O2 -o $@ $<
1069
+	$(Q)$(HOST_CC) $(HOST_CFLAGS) -o $@ $<
1067
 CLEANUP += $(ZBIN)
1070
 CLEANUP += $(ZBIN)
1068
 
1071
 
1069
 ###############################################################################
1072
 ###############################################################################
1071
 # The EFI image converter
1074
 # The EFI image converter
1072
 #
1075
 #
1073
 ELF2EFI_CFLAGS	:= -I$(BINUTILS_DIR)/include -I$(BFD_DIR)/include \
1076
 ELF2EFI_CFLAGS	:= -I$(BINUTILS_DIR)/include -I$(BFD_DIR)/include \
1074
-		   -I$(ZLIB_DIR)/include -idirafter include \
1075
-		   -L$(BINUTILS_DIR)/lib -L$(BFD_DIR)/lib -L$(ZLIB_DIR)/lib \
1077
+		   -I$(ZLIB_DIR)/include -idirafter include
1078
+ELF2EFI_LDFLAGS	:= -L$(BINUTILS_DIR)/lib -L$(BFD_DIR)/lib -L$(ZLIB_DIR)/lib \
1076
 		   -lbfd -ldl -liberty -lz -Wl,--no-warn-search-mismatch
1079
 		   -lbfd -ldl -liberty -lz -Wl,--no-warn-search-mismatch
1077
 
1080
 
1078
 $(ELF2EFI32) : util/elf2efi.c $(MAKEDEPS)
1081
 $(ELF2EFI32) : util/elf2efi.c $(MAKEDEPS)
1079
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1082
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1080
-	$(Q)$(HOST_CC) $< $(ELF2EFI_CFLAGS) -DEFI_TARGET_IA32 -O2 -o $@
1083
+	$(Q)$(HOST_CC) $(HOST_CFLAGS) $(ELF2EFI_CFLAGS) -DEFI_TARGET_IA32 $< \
1084
+		$(ELF2EFI_LDFLAGS) -o $@
1081
 CLEANUP += $(ELF2EFI32)
1085
 CLEANUP += $(ELF2EFI32)
1082
 
1086
 
1083
 $(ELF2EFI64) : util/elf2efi.c $(MAKEDEPS)
1087
 $(ELF2EFI64) : util/elf2efi.c $(MAKEDEPS)
1084
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1088
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1085
-	$(Q)$(HOST_CC) $< $(ELF2EFI_CFLAGS) -DEFI_TARGET_X64 -O2 -o $@
1089
+	$(Q)$(HOST_CC) $(HOST_CFLAGS) $(ELF2EFI_CFLAGS) -DEFI_TARGET_X64 $< \
1090
+		$(ELF2EFI_LDFLAGS) -o $@
1086
 CLEANUP += $(ELF2EFI64)
1091
 CLEANUP += $(ELF2EFI64)
1087
 
1092
 
1088
 $(EFIROM) : util/efirom.c $(MAKEDEPS)
1093
 $(EFIROM) : util/efirom.c $(MAKEDEPS)
1089
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1094
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1090
-	$(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
1095
+	$(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
1091
 CLEANUP += $(EFIROM)
1096
 CLEANUP += $(EFIROM)
1092
 
1097
 
1093
 ###############################################################################
1098
 ###############################################################################
1096
 #
1101
 #
1097
 $(ICCFIX) : util/iccfix.c $(MAKEDEPS)
1102
 $(ICCFIX) : util/iccfix.c $(MAKEDEPS)
1098
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1103
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1099
-	$(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
1104
+	$(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
1100
 CLEANUP += $(ICCFIX)
1105
 CLEANUP += $(ICCFIX)
1101
 
1106
 
1102
 ###############################################################################
1107
 ###############################################################################
1105
 #
1110
 #
1106
 $(EINFO) : util/einfo.c $(MAKEDEPS)
1111
 $(EINFO) : util/einfo.c $(MAKEDEPS)
1107
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1112
 	$(QM)$(ECHO) "  [HOSTCC] $@"
1108
-	$(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
1113
+	$(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
1109
 CLEANUP += $(EINFO)
1114
 CLEANUP += $(EINFO)
1110
 
1115
 
1111
 ###############################################################################
1116
 ###############################################################################

+ 3
- 15
src/util/efirom.c 查看文件

56
 	return ptr;
56
 	return ptr;
57
 }
57
 }
58
 
58
 
59
-/**
60
- * Get file size
61
- *
62
- * @v file		File
63
- * @v len		File size
64
- */
65
-static size_t file_size ( FILE *file ) {
66
-	ssize_t len;
67
-
68
-	return len;
69
-}
70
-
71
 /**
59
 /**
72
  * Read information from PE headers
60
  * Read information from PE headers
73
  *
61
  *
239
 }
227
 }
240
 
228
 
241
 int main ( int argc, char **argv ) {
229
 int main ( int argc, char **argv ) {
242
-	struct options opts = {
243
-	};
244
-	unsigned int infile_index;
230
+	struct options opts;
231
+	int infile_index;
245
 	const char *infile_name;
232
 	const char *infile_name;
246
 	const char *outfile_name;
233
 	const char *outfile_name;
247
 	FILE *infile;
234
 	FILE *infile;
248
 	FILE *outfile;
235
 	FILE *outfile;
249
 
236
 
250
 	/* Parse command-line arguments */
237
 	/* Parse command-line arguments */
238
+	memset ( &opts, 0, sizeof ( opts ) );
251
 	infile_index = parse_options ( argc, argv, &opts );
239
 	infile_index = parse_options ( argc, argv, &opts );
252
 	if ( argc != ( infile_index + 2 ) ) {
240
 	if ( argc != ( infile_index + 2 ) ) {
253
 		print_help ( argv[0] );
241
 		print_help ( argv[0] );

+ 7
- 6
src/util/einfo.c 查看文件

20
 #include <stdint.h>
20
 #include <stdint.h>
21
 #include <stdlib.h>
21
 #include <stdlib.h>
22
 #include <stdio.h>
22
 #include <stdio.h>
23
+#include <string.h>
23
 #include <errno.h>
24
 #include <errno.h>
24
 #include <sys/types.h>
25
 #include <sys/types.h>
25
 #include <sys/stat.h>
26
 #include <sys/stat.h>
49
  * @v infile		Filename
50
  * @v infile		Filename
50
  * @v opts		Command-line options
51
  * @v opts		Command-line options
51
  */
52
  */
52
-static void einfo ( const char *infile, struct options *opts ) {
53
+static void einfo ( const char *infile,
54
+		    struct options *opts __attribute__ (( unused )) ) {
53
 	int fd;
55
 	int fd;
54
 	struct stat stat;
56
 	struct stat stat;
55
 	size_t len;
57
 	size_t len;
85
 		for ( einfo = start ; ( ( void * ) einfo ) < ( start + len ) ;
87
 		for ( einfo = start ; ( ( void * ) einfo ) < ( start + len ) ;
86
 		      einfo = ( ( ( void * ) einfo ) + einfo->size ) ) {
88
 		      einfo = ( ( ( void * ) einfo ) + einfo->size ) ) {
87
 			printf ( "%08x\t%s\t%d\t%s\n", einfo->error,
89
 			printf ( "%08x\t%s\t%d\t%s\n", einfo->error,
88
-				 ( ( ( void * ) einfo ) + einfo->file ),
90
+				 ( ( ( char * ) einfo ) + einfo->file ),
89
 				 einfo->line,
91
 				 einfo->line,
90
-				 ( ( ( void * ) einfo ) + einfo->desc ) );
92
+				 ( ( ( char * ) einfo ) + einfo->desc ) );
91
 		}
93
 		}
92
 
94
 
93
 	}
95
 	}
115
  * @v opts		Options structure to populate
117
  * @v opts		Options structure to populate
116
  */
118
  */
117
 static int parse_options ( const int argc, char **argv,
119
 static int parse_options ( const int argc, char **argv,
118
-			   struct options *opts ) {
119
-	char *end;
120
+			   struct options *opts __attribute__ (( unused )) ) {
120
 	int c;
121
 	int c;
121
 
122
 
122
 	while (1) {
123
 	while (1) {
147
 int main ( int argc, char **argv ) {
148
 int main ( int argc, char **argv ) {
148
 	struct options opts = {
149
 	struct options opts = {
149
 	};
150
 	};
150
-	unsigned int infile_index;
151
+	int infile_index;
151
 	const char *infile;
152
 	const char *infile;
152
 
153
 
153
 	/* Parse command-line arguments */
154
 	/* Parse command-line arguments */

+ 4
- 3
src/util/elf2efi.c 查看文件

459
  * @v rel		Relocation entry
459
  * @v rel		Relocation entry
460
  * @v pe_reltab		PE relocation table to fill in
460
  * @v pe_reltab		PE relocation table to fill in
461
  */
461
  */
462
-static void process_reloc ( bfd *bfd, asection *section, arelent *rel,
462
+static void process_reloc ( bfd *bfd __attribute__ (( unused )),
463
+			    asection *section, arelent *rel,
463
 			    struct pe_relocs **pe_reltab ) {
464
 			    struct pe_relocs **pe_reltab ) {
464
 	reloc_howto_type *howto = rel->howto;
465
 	reloc_howto_type *howto = rel->howto;
465
 	asymbol *sym = *(rel->sym_ptr_ptr);
466
 	asymbol *sym = *(rel->sym_ptr_ptr);
637
 	for ( section = pe_sections ; section ; section = section->next ) {
638
 	for ( section = pe_sections ; section ; section = section->next ) {
638
 		if ( fseek ( pe, section->hdr.PointerToRawData,
639
 		if ( fseek ( pe, section->hdr.PointerToRawData,
639
 			     SEEK_SET ) != 0 ) {
640
 			     SEEK_SET ) != 0 ) {
640
-			eprintf ( "Could not seek to %lx: %s\n",
641
+			eprintf ( "Could not seek to %x: %s\n",
641
 				  section->hdr.PointerToRawData,
642
 				  section->hdr.PointerToRawData,
642
 				  strerror ( errno ) );
643
 				  strerror ( errno ) );
643
 			exit ( 1 );
644
 			exit ( 1 );
786
 	struct options opts = {
787
 	struct options opts = {
787
 		.subsystem = EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,
788
 		.subsystem = EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,
788
 	};
789
 	};
789
-	unsigned int infile_index;
790
+	int infile_index;
790
 	const char *infile;
791
 	const char *infile;
791
 	const char *outfile;
792
 	const char *outfile;
792
 
793
 

+ 2
- 1
src/util/iccfix.c 查看文件

2
 #include <stddef.h>
2
 #include <stddef.h>
3
 #include <stdio.h>
3
 #include <stdio.h>
4
 #include <stdlib.h>
4
 #include <stdlib.h>
5
+#include <string.h>
5
 #include <unistd.h>
6
 #include <unistd.h>
6
 #include <fcntl.h>
7
 #include <fcntl.h>
7
 #include <errno.h>
8
 #include <errno.h>
49
 		     ( align >= ICC_ALIGN_HACK_FACTOR ) ) {
50
 		     ( align >= ICC_ALIGN_HACK_FACTOR ) ) {
50
 			new_align = ( align / ICC_ALIGN_HACK_FACTOR );
51
 			new_align = ( align / ICC_ALIGN_HACK_FACTOR );
51
 			shdr->sh_addralign = new_align;
52
 			shdr->sh_addralign = new_align;
52
-			dprintf ( "Section \"%s\": alignment %d->%d\n",
53
+			dprintf ( "Section \"%s\": alignment %ld->%ld\n",
53
 				  name, align, new_align );
54
 				  name, align, new_align );
54
 		}
55
 		}
55
 	}
56
 	}

+ 2
- 3
src/util/nrv2b.c 查看文件

77
 
77
 
78
 /* These will be a complete waste of time on a lo-endian */
78
 /* These will be a complete waste of time on a lo-endian */
79
 /* system, but it only gets done once so WTF. */
79
 /* system, but it only gets done once so WTF. */
80
-static unsigned long i86ul_to_host(unsigned long ul)
80
+static unsigned long __attribute__ (( unused )) i86ul_to_host(unsigned long ul)
81
 {
81
 {
82
 	unsigned long res = 0;
82
 	unsigned long res = 0;
83
 	int i;
83
 	int i;
375
 int swd_init(struct ucl_swd *s, const uint8_t *dict, unsigned int dict_len)
375
 int swd_init(struct ucl_swd *s, const uint8_t *dict, unsigned int dict_len)
376
 {
376
 {
377
 	unsigned int i = 0;
377
 	unsigned int i = 0;
378
-	int c = 0;
379
 
378
 
380
 	if (s->n == 0)
379
 	if (s->n == 0)
381
 		s->n = N;
380
 		s->n = N;
439
 void swd_exit(struct ucl_swd *s)
438
 void swd_exit(struct ucl_swd *s)
440
 {
439
 {
441
 	/* unused s */
440
 	/* unused s */
442
-
441
+	( void ) s;
443
 }
442
 }
444
 
443
 
445
 #define swd_pos2off(s,pos) \
444
 #define swd_pos2off(s,pos) \

+ 5
- 2
src/util/zbin.c 查看文件

218
 	return 0;
218
 	return 0;
219
 }
219
 }
220
 
220
 
221
-static int process_zinfo_payl ( struct input_file *input,
221
+static int process_zinfo_payl ( struct input_file *input
222
+					__attribute__ (( unused )),
222
 				struct output_file *output,
223
 				struct output_file *output,
223
 				union zinfo_record *zinfo ) {
224
 				union zinfo_record *zinfo ) {
224
 	struct zinfo_payload *payload = &zinfo->payload;
225
 	struct zinfo_payload *payload = &zinfo->payload;
229
 	if ( DEBUG ) {
230
 	if ( DEBUG ) {
230
 		fprintf ( stderr, "PAYL at %#zx\n", output->hdr_len );
231
 		fprintf ( stderr, "PAYL at %#zx\n", output->hdr_len );
231
 	}
232
 	}
233
+	return 0;
232
 }
234
 }
233
 
235
 
234
-static int process_zinfo_add ( struct input_file *input,
236
+static int process_zinfo_add ( struct input_file *input
237
+					__attribute__ (( unused )),
235
 			       struct output_file *output,
238
 			       struct output_file *output,
236
 			       size_t len,
239
 			       size_t len,
237
 			       struct zinfo_add *add,
240
 			       struct zinfo_add *add,

Loading…
取消
儲存