disable -Wold-style-definition for gcc 3.x

This commit is contained in:
Denis Vlasenko 2007-01-29 17:08:51 +00:00
parent fe7a9f1277
commit c562bb7487
3 changed files with 28 additions and 7 deletions

View File

@ -20,16 +20,22 @@ CFLAGS += $(call cc-option,-Wall -Wshadow,)
ifeq ($(CONFIG_WERROR),y) ifeq ($(CONFIG_WERROR),y)
CFLAGS += $(call cc-option,-Werror,) CFLAGS += $(call cc-option,-Werror,)
endif endif
CFLAGS += $(call cc-option,-Wundef -Wold-style-definition -Wstrict-prototypes,) CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
# If you want to add "-Wmissing-prototypes -Wmissing-declarations" above # If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
# (or anything else for that matter) make sure that it is still possible # (or anything else for that matter) make sure that it is still possible
# to build bbox without warnings. Current offender: find.c:alloc_action(). # to build bbox without warnings. Current offender: find.c:alloc_action().
# Looks more like gcc bug: gcc will warn on it with or without prototype. # Looks more like gcc bug: gcc will warn on it with or without prototype.
# But still, warning-free compile is a must, or else we will drown # But still, warning-free compile is a must, or else we will drown
# in warnings pretty soon. # in warnings pretty soon.
# gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
# gcc emits bogus "no prev proto" warning on find.c:alloc_action()
ifneq ($(CONFIG_WERROR),y) ifneq ($(CONFIG_WERROR),y)
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,) CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
endif endif
CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,) CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
# -fno-guess-branch-probability: prohibit pseudo-random guessing # -fno-guess-branch-probability: prohibit pseudo-random guessing
# of branch probabilities (hopefully makes bloatcheck more stable): # of branch probabilities (hopefully makes bloatcheck more stable):

View File

@ -422,8 +422,10 @@ static char *parse_cmd_args(sed_cmd_t *sed_cmd, char *cmdstr)
if (sed_cmd->end_line || sed_cmd->end_match) if (sed_cmd->end_line || sed_cmd->end_match)
bb_error_msg_and_die("command only uses one address"); bb_error_msg_and_die("command only uses one address");
cmdstr += parse_file_cmd(sed_cmd, cmdstr, &sed_cmd->string); cmdstr += parse_file_cmd(sed_cmd, cmdstr, &sed_cmd->string);
if (sed_cmd->cmd == 'w') if (sed_cmd->cmd == 'w') {
sed_cmd->sw_file = xfopen(sed_cmd->string, "w"); sed_cmd->sw_file = xfopen(sed_cmd->string, "w");
sed_cmd->sw_last_char = '\n';
}
/* handle branch commands */ /* handle branch commands */
} else if (strchr(":btT", sed_cmd->cmd)) { } else if (strchr(":btT", sed_cmd->cmd)) {
int length; int length;
@ -726,7 +728,8 @@ enum {
static char *get_next_line(char *gets_char) static char *get_next_line(char *gets_char)
{ {
char *temp = NULL; char *temp = NULL;
int len, gc; int len;
char gc;
flush_append(); flush_append();
@ -744,9 +747,11 @@ static char *get_next_line(char *gets_char)
char c = temp[len-1]; char c = temp[len-1];
if (c == '\n' || c == '\0') { if (c == '\n' || c == '\0') {
temp[len-1] = '\0'; temp[len-1] = '\0';
gc = (unsigned char)c; gc = c;
break;
} }
/* else we put NO_EOL_CHAR into *gets_char */
break;
/* NB: I had the idea of peeking next file(s) and returning /* NB: I had the idea of peeking next file(s) and returning
* NO_EOL_CHAR only if it is the *last* non-empty * NO_EOL_CHAR only if it is the *last* non-empty
* input file. But there is a case where this won't work: * input file. But there is a case where this won't work:
@ -754,8 +759,6 @@ static char *get_next_line(char *gets_char)
* file2: "c no\nd no" * file2: "c no\nd no"
* sed -ne 's/woo/bang/p' input1 input2 => "a bang\nb bang" * sed -ne 's/woo/bang/p' input1 input2 => "a bang\nb bang"
* (note: *no* newline after "b bang"!) */ * (note: *no* newline after "b bang"!) */
break;
} }
/* Close this file and advance to next one */ /* Close this file and advance to next one */
fclose(bbg.input_file_list[bbg.current_input_file++]); fclose(bbg.input_file_list[bbg.current_input_file++]);

12
scripts/gcc-version.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
#
# gcc-version gcc-command
#
# Prints the gcc version of `gcc-command' in a canonical 4-digit form
# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc.
#
compiler="$*"
MAJ_MIN=$(echo __GNUC__ __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
printf '%02d%02d\n' $MAJ_MIN