Bläddra i källkod

[build] Enable warnings when building utilities

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 år sedan
förälder
incheckning
196751ce95
8 ändrade filer med 39 tillägg och 40 borttagningar
  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 Visa fil

@@ -7,6 +7,7 @@ CLEANUP		:=
7 7
 CFLAGS		:=
8 8
 ASFLAGS		:=
9 9
 LDFLAGS		:=
10
+HOST_CFLAGS	:=
10 11
 MAKEDEPS	:= Makefile
11 12
 
12 13
 ###############################################################################

+ 15
- 10
src/Makefile.housekeeping Visa fil

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

+ 3
- 15
src/util/efirom.c Visa fil

@@ -56,18 +56,6 @@ static void * xmalloc ( size_t len ) {
56 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 60
  * Read information from PE headers
73 61
  *
@@ -239,15 +227,15 @@ static int parse_options ( const int argc, char **argv,
239 227
 }
240 228
 
241 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 232
 	const char *infile_name;
246 233
 	const char *outfile_name;
247 234
 	FILE *infile;
248 235
 	FILE *outfile;
249 236
 
250 237
 	/* Parse command-line arguments */
238
+	memset ( &opts, 0, sizeof ( opts ) );
251 239
 	infile_index = parse_options ( argc, argv, &opts );
252 240
 	if ( argc != ( infile_index + 2 ) ) {
253 241
 		print_help ( argv[0] );

+ 7
- 6
src/util/einfo.c Visa fil

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

+ 4
- 3
src/util/elf2efi.c Visa fil

@@ -459,7 +459,8 @@ static struct pe_section * process_section ( bfd *bfd,
459 459
  * @v rel		Relocation entry
460 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 464
 			    struct pe_relocs **pe_reltab ) {
464 465
 	reloc_howto_type *howto = rel->howto;
465 466
 	asymbol *sym = *(rel->sym_ptr_ptr);
@@ -637,7 +638,7 @@ static void write_pe_file ( struct pe_header *pe_header,
637 638
 	for ( section = pe_sections ; section ; section = section->next ) {
638 639
 		if ( fseek ( pe, section->hdr.PointerToRawData,
639 640
 			     SEEK_SET ) != 0 ) {
640
-			eprintf ( "Could not seek to %lx: %s\n",
641
+			eprintf ( "Could not seek to %x: %s\n",
641 642
 				  section->hdr.PointerToRawData,
642 643
 				  strerror ( errno ) );
643 644
 			exit ( 1 );
@@ -786,7 +787,7 @@ int main ( int argc, char **argv ) {
786 787
 	struct options opts = {
787 788
 		.subsystem = EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION,
788 789
 	};
789
-	unsigned int infile_index;
790
+	int infile_index;
790 791
 	const char *infile;
791 792
 	const char *outfile;
792 793
 

+ 2
- 1
src/util/iccfix.c Visa fil

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

+ 2
- 3
src/util/nrv2b.c Visa fil

@@ -77,7 +77,7 @@ static __inline__ void Error(char *message)
77 77
 
78 78
 /* These will be a complete waste of time on a lo-endian */
79 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 82
 	unsigned long res = 0;
83 83
 	int i;
@@ -375,7 +375,6 @@ static
375 375
 int swd_init(struct ucl_swd *s, const uint8_t *dict, unsigned int dict_len)
376 376
 {
377 377
 	unsigned int i = 0;
378
-	int c = 0;
379 378
 
380 379
 	if (s->n == 0)
381 380
 		s->n = N;
@@ -439,7 +438,7 @@ static
439 438
 void swd_exit(struct ucl_swd *s)
440 439
 {
441 440
 	/* unused s */
442
-
441
+	( void ) s;
443 442
 }
444 443
 
445 444
 #define swd_pos2off(s,pos) \

+ 5
- 2
src/util/zbin.c Visa fil

@@ -218,7 +218,8 @@ static int process_zinfo_pack ( struct input_file *input,
218 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 223
 				struct output_file *output,
223 224
 				union zinfo_record *zinfo ) {
224 225
 	struct zinfo_payload *payload = &zinfo->payload;
@@ -229,9 +230,11 @@ static int process_zinfo_payl ( struct input_file *input,
229 230
 	if ( DEBUG ) {
230 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 238
 			       struct output_file *output,
236 239
 			       size_t len,
237 240
 			       struct zinfo_add *add,

Laddar…
Avbryt
Spara