From 626a1220d5ade8b08dc5d4ece00900dc0924f659 Mon Sep 17 00:00:00 2001 From: Jim Ramsay Date: Wed, 20 Jul 2011 09:06:47 -0400 Subject: fwparam_ibft: Fix warnings reported by gcc-4.5.2 A simple cast for the qsort comparison parameter, and an updated prom_lex.c generated by flex-2.5.35 Signed-off-by: Jim Ramsay --- utils/fwparam_ibft/fwparam_ppc.c | 2 +- utils/fwparam_ibft/prom_lex.c | 173 +++++++++++++++++++++------------------ utils/fwparam_ibft/prom_lex.l | 2 + 3 files changed, 96 insertions(+), 81 deletions(-) (limited to 'utils') diff --git a/utils/fwparam_ibft/fwparam_ppc.c b/utils/fwparam_ibft/fwparam_ppc.c index 391faa2..c298b8c 100644 --- a/utils/fwparam_ibft/fwparam_ppc.c +++ b/utils/fwparam_ibft/fwparam_ppc.c @@ -356,7 +356,7 @@ static int loop_devs(const char *devtree) * Sort the nics into "natural" order. The proc fs * device-tree has them in somewhat random, or reversed order. */ - qsort(niclist, nic_count, sizeof(char *), nic_cmp); + qsort(niclist, nic_count, sizeof(char *), (__compar_fn_t)nic_cmp); snprintf(prefix, sizeof(prefix), "%s/%s", devtree, "aliases"); dev_count = 0; diff --git a/utils/fwparam_ibft/prom_lex.c b/utils/fwparam_ibft/prom_lex.c index 704d8ca..c8ed9cb 100644 --- a/utils/fwparam_ibft/prom_lex.c +++ b/utils/fwparam_ibft/prom_lex.c @@ -8,7 +8,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 33 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -30,7 +30,7 @@ /* C99 systems have . Non-C99 systems may or may not. */ -#if __STDC_VERSION__ >= 199901L +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. @@ -53,7 +53,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -84,6 +83,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -93,11 +94,12 @@ typedef unsigned int flex_uint32_t; #else /* ! __cplusplus */ -#if __STDC__ +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) #define YY_USE_CONST -#endif /* __STDC__ */ +#endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST @@ -139,7 +141,15 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -177,14 +187,9 @@ extern FILE *yyin, *yyout; #define unput(c) yyunput( c, (yytext_ptr) ) -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ - #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T -typedef unsigned int yy_size_t; +typedef size_t yy_size_t; #endif #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -920,7 +925,7 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET #ifndef YYLMAX -#define YYLMAX 2048 +#define YYLMAX 8192 #endif char yytext[YYLMAX]; @@ -964,8 +969,9 @@ char *yytext_ptr; void dbgprint(const char *item) { fprintf(stderr, "%s: \"%s\" len=%d ", item, yytext, yyleng);} +#define YY_NO_INPUT 1 /* CHOSEN uses only boot related paths. */ -#line 969 "" +#line 975 "" #define INITIAL 0 @@ -983,6 +989,35 @@ void dbgprint(const char *item) { fprintf(stderr, "%s: \"%s\" len=%d ", item, yy static int yy_init_globals (void ); +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy (void ); + +int yyget_debug (void ); + +void yyset_debug (int debug_flag ); + +YY_EXTRA_TYPE yyget_extra (void ); + +void yyset_extra (YY_EXTRA_TYPE user_defined ); + +FILE *yyget_in (void ); + +void yyset_in (FILE * in_str ); + +FILE *yyget_out (void ); + +void yyset_out (FILE * out_str ); + +int yyget_leng (void ); + +char *yyget_text (void ); + +int yyget_lineno (void ); + +void yyset_lineno (int line_number ); + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -995,8 +1030,6 @@ extern int yywrap (void ); #endif #endif - static void yyunput (int c,char *buf_ptr ); - #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif @@ -1017,7 +1050,12 @@ static int input (void ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -1025,7 +1063,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1118,10 +1156,10 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 63 "prom_lex.l" +#line 65 "prom_lex.l" -#line 1125 "" +#line 1163 "" if ( !(yy_init) ) { @@ -1202,78 +1240,78 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 65 "prom_lex.l" +#line 67 "prom_lex.l" { upval(CHOSEN); } YY_BREAK case 2: YY_RULE_SETUP -#line 66 "prom_lex.l" +#line 68 "prom_lex.l" { upval(VDEVICE); } YY_BREAK case 3: YY_RULE_SETUP -#line 67 "prom_lex.l" +#line 69 "prom_lex.l" { upval(VDEVINST); } YY_BREAK case 4: YY_RULE_SETUP -#line 68 "prom_lex.l" +#line 70 "prom_lex.l" { upval(VDEVDEV); } YY_BREAK case 5: YY_RULE_SETUP -#line 69 "prom_lex.l" +#line 71 "prom_lex.l" { upval(VDEVRAW); } YY_BREAK case 6: YY_RULE_SETUP -#line 70 "prom_lex.l" +#line 72 "prom_lex.l" { upval(OBPQUAL); } YY_BREAK case 7: YY_RULE_SETUP -#line 71 "prom_lex.l" +#line 73 "prom_lex.l" { upval(BUSNAME); } YY_BREAK case 8: YY_RULE_SETUP -#line 72 "prom_lex.l" +#line 74 "prom_lex.l" { upval(IPV4); } YY_BREAK case 9: YY_RULE_SETUP -#line 73 "prom_lex.l" +#line 75 "prom_lex.l" { upval(IQN); } YY_BREAK case 10: YY_RULE_SETUP -#line 74 "prom_lex.l" +#line 76 "prom_lex.l" { upval(BOOTDEV); } YY_BREAK case 11: YY_RULE_SETUP -#line 75 "prom_lex.l" +#line 77 "prom_lex.l" { upval(OBPPARM); } YY_BREAK case 12: YY_RULE_SETUP -#line 76 "prom_lex.l" +#line 78 "prom_lex.l" { upval(HEX4); } YY_BREAK case 13: YY_RULE_SETUP -#line 77 "prom_lex.l" +#line 79 "prom_lex.l" { upval(HEX16); } YY_BREAK case 14: YY_RULE_SETUP -#line 78 "prom_lex.l" +#line 80 "prom_lex.l" { upval(FILENAME); } YY_BREAK case 15: /* rule 15 can match eol */ YY_RULE_SETUP -#line 79 "prom_lex.l" +#line 81 "prom_lex.l" { /* eat all whitespace. */ yylloc.first_column = yylloc.last_column; yylloc.last_column += yyleng; @@ -1281,7 +1319,7 @@ YY_RULE_SETUP YY_BREAK case 16: YY_RULE_SETUP -#line 83 "prom_lex.l" +#line 85 "prom_lex.l" { /* any other single char. */ dbg("??"); yylloc.first_column = yylloc.last_column; @@ -1290,15 +1328,15 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(INITIAL): -#line 90 "prom_lex.l" +#line 92 "prom_lex.l" yyterminate(); YY_BREAK case 17: YY_RULE_SETUP -#line 91 "prom_lex.l" +#line 93 "prom_lex.l" ECHO; YY_BREAK -#line 1302 "" +#line 1340 "" case YY_END_OF_BUFFER: { @@ -1528,7 +1566,7 @@ static int yy_get_next_buffer (void) /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); + (yy_n_chars), (size_t) num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } @@ -1552,6 +1590,14 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + (yy_n_chars) += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; @@ -1618,43 +1664,6 @@ static int yy_get_next_buffer (void) return yy_is_jam ? 0 : yy_current_state; } - static void yyunput (int c, register char * yy_bp ) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up yytext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void) @@ -1963,7 +1972,9 @@ static void yyensure_buffer_stack (void) (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); - + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; @@ -1981,6 +1992,8 @@ static void yyensure_buffer_stack (void) ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -2025,7 +2038,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) /** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. - * @param str a NUL-terminated string to scan + * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use @@ -2039,8 +2052,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ @@ -2279,7 +2292,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 91 "prom_lex.l" +#line 93 "prom_lex.l" diff --git a/utils/fwparam_ibft/prom_lex.l b/utils/fwparam_ibft/prom_lex.l index 208046b..e70c790 100644 --- a/utils/fwparam_ibft/prom_lex.l +++ b/utils/fwparam_ibft/prom_lex.l @@ -43,6 +43,8 @@ void dbgprint(const char *item) { fprintf(stderr, "%s: \"%s\" len=%d ", item, yy %option noyywrap %option never-interactive +%option nounput +%option noinput VDEVICE vdevice VDEVINST gscsi -- cgit v1.2.1