From: mquinson Date: Fri, 7 Nov 2008 15:52:54 +0000 (+0000) Subject: Work around newly reincreased paranoia of gcc and libc on ubuntu. It's geting hard... X-Git-Tag: v3.3~118 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/32e043cb47a2c23cd2b419c037d56f8139d51765 Work around newly reincreased paranoia of gcc and libc on ubuntu. It's geting hard to be -Werror friendly since they keep adding useless warnings git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6003 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/xbt/backtrace_linux.c b/src/xbt/backtrace_linux.c index c4ef0dceaa..d4aa200ee1 100644 --- a/src/xbt/backtrace_linux.c +++ b/src/xbt/backtrace_linux.c @@ -130,10 +130,15 @@ void xbt_ex_setup_backtrace(xbt_ex_t * e) } for (i = 0; i < e->used; i++) { + char *fgets_res; DEBUG2("Looking for symbol %d, addr = '%s'", i, addrs[i]); - fgets(line_func, 1024, pipe); + fgets_res = fgets(line_func, 1024, pipe); + if (fgets_res == NULL) + THROW2(system_error,0, "Cannot run fgets to look for symbol %d, addr %s",i, addrs[i]); line_func[strlen(line_func) - 1] = '\0'; - fgets(line_pos, 1024, pipe); + fgets_res = fgets(line_pos, 1024, pipe); + if (fgets_res == NULL) + THROW2(system_error,0, "Cannot run fgets to look for symbol %d, addr %s",i, addrs[i]); line_pos[strlen(line_pos) - 1] = '\0'; if (strcmp("??", line_func)) { @@ -230,9 +235,13 @@ void xbt_ex_setup_backtrace(xbt_ex_t * e) CRITICAL0("Cannot fork addr2line to display the backtrace"); abort(); } - fgets(line_func, 1024, subpipe); + fgets_res=fgets(line_func, 1024, subpipe); + if (fgets_res == NULL) + THROW1(system_error,0, "Cannot read result of subcommand %s",subcmd); line_func[strlen(line_func) - 1] = '\0'; - fgets(line_pos, 1024, subpipe); + fgets_res = fgets(line_pos, 1024, subpipe); + if (fgets_res == NULL) + THROW1(system_error,0, "Cannot read result of subcommand %s",subcmd); line_pos[strlen(line_pos) - 1] = '\0'; pclose(subpipe); free(subcmd); diff --git a/src/xbt/cunit.c b/src/xbt/cunit.c index 5cf79168ec..c22342e8e8 100644 --- a/src/xbt/cunit.c +++ b/src/xbt/cunit.c @@ -151,12 +151,13 @@ static void xbt_test_log_free(void *log) { xbt_test_suite_t xbt_test_suite_new(const char *name, const char *fmt, ...) { xbt_test_suite_t suite = xbt_new0(struct s_xbt_test_suite,1); va_list ap; + int vres; if (!_xbt_test_suites) _xbt_test_suites = xbt_dynar_new(sizeof(xbt_test_suite_t),xbt_test_suite_free); va_start(ap, fmt); - vasprintf(&suite->title,fmt, ap); + vres = vasprintf(&suite->title,fmt, ap); suite->units = xbt_dynar_new(sizeof(xbt_test_unit_t), &xbt_test_unit_free); va_end(ap); suite->name = name; @@ -174,6 +175,7 @@ xbt_test_suite_t xbt_test_suite_by_name(const char *name,const char *fmt, ...) { char *bufname; va_list ap; + int vres; if (_xbt_test_suites) xbt_dynar_foreach(_xbt_test_suites, it_suite, suite) @@ -181,7 +183,7 @@ xbt_test_suite_t xbt_test_suite_by_name(const char *name,const char *fmt, ...) { return suite; va_start(ap, fmt); - vasprintf(&bufname,fmt, ap); + vres = vasprintf(&bufname,fmt, ap); va_end(ap); suite = xbt_test_suite_new(name,bufname,NULL); free(bufname); @@ -208,6 +210,7 @@ void xbt_test_suite_dump(xbt_test_suite_t suite) { void xbt_test_suite_push(xbt_test_suite_t suite, const char *name, ts_test_cb_t func, const char *fmt, ...) { xbt_test_unit_t unit; va_list ap; + int vres; xbt_assert(suite); xbt_assert(func); @@ -215,7 +218,7 @@ void xbt_test_suite_push(xbt_test_suite_t suite, const char *name, ts_test_cb_t unit = xbt_new0(struct s_xbt_test_unit,1); va_start(ap, fmt); - vasprintf(&unit->title, fmt, ap); + vres = vasprintf(&unit->title, fmt, ap); va_end(ap); unit->name = (char*)name; unit->func = func; @@ -240,6 +243,7 @@ static int xbt_test_suite_run(xbt_test_suite_t suite) { unsigned int it_unit,it_test,it_log; int first=1; /* for result pretty printing */ + int vres; if (suite == NULL) return 0; @@ -276,7 +280,7 @@ static int xbt_test_suite_run(xbt_test_suite_t suite) { unit->test_expect = 0; /* display unit title */ - asprintf(&cp," Unit: %s ......................................" + vres=asprintf(&cp," Unit: %s ......................................" "......................................", unit->title); cp[70] = '\0'; fprintf(stderr, "%s", cp); @@ -644,13 +648,14 @@ void _xbt_test_add(const char*file,int line, const char *fmt, ...) { xbt_test_unit_t unit=_xbt_test_current_unit; xbt_test_test_t test; va_list ap; + int vres; xbt_assert(unit); xbt_assert(fmt); test = xbt_new0(struct s_xbt_test_test,1); va_start(ap, fmt); - vasprintf(&test->title, fmt, ap); + vres=vasprintf(&test->title, fmt, ap); va_end(ap); test->failed = 0; test->expected_failure = 0; @@ -668,6 +673,7 @@ void _xbt_test_fail(const char*file,int line,const char *fmt, ...) { xbt_test_test_t test; xbt_test_log_t log; va_list ap; + int vres; xbt_assert(unit); xbt_assert(fmt); @@ -678,7 +684,7 @@ void _xbt_test_fail(const char*file,int line,const char *fmt, ...) { log = xbt_new(struct s_xbt_test_log,1); va_start(ap, fmt); - vasprintf(&log->text,fmt, ap); + vres=vasprintf(&log->text,fmt, ap); va_end(ap); log->file = file; log->line = line; @@ -719,6 +725,7 @@ void _xbt_test_log(const char*file,int line,const char *fmt, ...) { xbt_test_test_t test; xbt_test_log_t log; va_list ap; + int vres; xbt_assert(unit); xbt_assert(fmt); @@ -728,7 +735,7 @@ void _xbt_test_log(const char*file,int line,const char *fmt, ...) { log = xbt_new(struct s_xbt_test_log,1); va_start(ap, fmt); - vasprintf(&log->text, fmt, ap); + vres=vasprintf(&log->text, fmt, ap); va_end(ap); log->file = file; log->line = line; diff --git a/src/xbt/graphxml.c b/src/xbt/graphxml.c index 4ad7a755da..0d4354c6c1 100644 --- a/src/xbt/graphxml.c +++ b/src/xbt/graphxml.c @@ -27,7 +27,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 34 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -72,7 +72,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 @@ -103,6 +102,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -210,13 +211,6 @@ extern FILE *xbt_graph_parse_in, *xbt_graph_parse_out; #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). - * Given that the standard has decreed that size_t exists since 1989, - * I guess we can afford to depend on it. Manoj. - */ - #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; @@ -370,11 +364,7 @@ void xbt_graph_parse_free (void * ); /* Begin user sect3 */ -#ifdef WIN32 -#define xbt_graph_parse_wrap() 1 -#else #define xbt_graph_parse_wrap(n) 1 -#endif #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; @@ -1350,6 +1340,35 @@ const char* *graphxml_statenames=NULL; static int yy_init_globals (void ); +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int xbt_graph_parse_lex_destroy (void ); + +int xbt_graph_parse_get_debug (void ); + +void xbt_graph_parse_set_debug (int debug_flag ); + +YY_EXTRA_TYPE xbt_graph_parse_get_extra (void ); + +void xbt_graph_parse_set_extra (YY_EXTRA_TYPE user_defined ); + +FILE *xbt_graph_parse_get_in (void ); + +void xbt_graph_parse_set_in (FILE * in_str ); + +FILE *xbt_graph_parse_get_out (void ); + +void xbt_graph_parse_set_out (FILE * out_str ); + +int xbt_graph_parse_get_leng (void ); + +char *xbt_graph_parse_get_text (void ); + +int xbt_graph_parse_get_lineno (void ); + +void xbt_graph_parse_set_lineno (int line_number ); + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -1398,7 +1417,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 fwrite( xbt_graph_parse_text, xbt_graph_parse_leng, 1, xbt_graph_parse_out ) +#define ECHO do { if (fwrite( xbt_graph_parse_text, xbt_graph_parse_leng, 1, xbt_graph_parse_out )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1409,7 +1428,7 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( xbt_graph_parse_in )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -2722,9 +2741,7 @@ static void xbt_graph_parse__load_buffer_state (void) } #ifndef __cplusplus -#ifndef WIN32 extern int isatty (int ); -#endif #endif /* __cplusplus */ /* Initializes or reinitializes a buffer. diff --git a/src/xbt/snprintf.c b/src/xbt/snprintf.c index b80f8d23c7..31cd4a0ef8 100644 --- a/src/xbt/snprintf.c +++ b/src/xbt/snprintf.c @@ -1050,11 +1050,11 @@ int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...) { char *bprintf(const char*fmt, ...) { va_list ap; char *res; + int len; va_start(ap, fmt); - - vasprintf(&res,fmt,ap); + len = vasprintf(&res,fmt,ap); va_end(ap); return res; diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index 4fc14b252d..b312bb8181 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -56,6 +56,7 @@ static void xbt_log_layout_format_dynamic(xbt_log_layout_t l, char *q = l->data; char *tmp; char *tmp2; + int vres; /* shut gcc up, but ignored */ while (*q != '\0') { if (*q == '%') { @@ -148,7 +149,7 @@ static void xbt_log_layout_format_dynamic(xbt_log_layout_t l, break; case 'm': /* user-provided message; LOG4J compliant */ - vasprintf(&tmp2, fmt, ev->ap_copy); + vres = vasprintf(&tmp2, fmt, ev->ap_copy); append1("%s","%.*s",tmp2); free(tmp2); break; diff --git a/src/xbt/xbt_strbuff.c b/src/xbt/xbt_strbuff.c index 8b1eec0672..50e475aee8 100644 --- a/src/xbt/xbt_strbuff.c +++ b/src/xbt/xbt_strbuff.c @@ -265,13 +265,12 @@ void xbt_strbuff_varsubst(xbt_strbuff_t b, xbt_dict_t patterns) { "9.........1.........2.........3.........4.........5.........6.........7.........8.........9........." \ "0.........1.........2.........3.........4.........5.........6.........7.........8.........9........." -static void mytest(const char *name, const char *input, const char *patterns, const char *expected) { +static void mytest(const char *input, const char *patterns, const char *expected) { xbt_dynar_t dyn_patterns; /* splited string */ xbt_dict_t p; /* patterns */ unsigned int cpt; char *str; /*foreach*/ xbt_strbuff_t sb; /* what we test */ - xbt_test_add0(name); p=xbt_dict_new(); dyn_patterns=xbt_str_split(patterns," "); xbt_dynar_foreach(dyn_patterns,cpt,str) { @@ -295,55 +294,54 @@ static void mytest(const char *name, const char *input, const char *patterns, co XBT_TEST_SUITE("xbt_strbuff","String Buffers"); XBT_TEST_UNIT("xbt_strbuff_substitute",test_strbuff_substitute, "test the function xbt_strbuff_substitute") { - mytest("Empty", "", "", ""); - - mytest("Value shorter, no braces, only variable", "$tutu", "tutu=t", "t"); - mytest("Value shorter, braces, only variable", "${tutu}", "tutu=t", "t"); - mytest("Value shorter, no braces, data after", "$tutu toto", "tutu=t", "t toto"); - mytest("Value shorter, braces, data after", "${tutu} toto", "tutu=t", "t toto"); - mytest("Value shorter, no braces, data before", "toto $tutu", "tutu=t", "toto t"); - mytest("Value shorter, braces, data before", "toto ${tutu}", "tutu=t", "toto t"); - mytest("Value shorter, no braces, data before and after", "toto $tutu tata", "tutu=t", "toto t tata"); - mytest("Value shorter, braces, data before and after", "toto ${tutu} tata", "tutu=t", "toto t tata"); - - mytest("Value as long, no braces, only variable", "$tutu", "tutu=12345", "12345"); - mytest("Value as long, braces, only variable", "${tutu}", "tutu=1234567", "1234567"); - mytest("Value as long, no braces, data after", "$tutu toto", "tutu=12345", "12345 toto"); - mytest("Value as long, braces, data after", "${tutu} toto", "tutu=1234567", "1234567 toto"); - mytest("Value as long, no braces, data before", "toto $tutu", "tutu=12345", "toto 12345"); - mytest("Value as long, braces, data before", "toto ${tutu}", "tutu=1234567", "toto 1234567"); - mytest("Value as long, no braces, data before and after", "toto $tutu tata", "tutu=12345", "toto 12345 tata"); - mytest("Value as long, braces, data before and after", "toto ${tutu} tata", "tutu=1234567", "toto 1234567 tata"); - - mytest("Value longer, no braces, only variable", "$t", "t=tututu", "tututu"); - mytest("Value longer, braces, only variable", "${t}", "t=tututu", "tututu"); - mytest("Value longer, no braces, data after", "$t toto", "t=tututu", "tututu toto"); - mytest("Value longer, braces, data after", "${t} toto", "t=tututu", "tututu toto"); - mytest("Value longer, no braces, data before", "toto $t", "t=tututu", "toto tututu"); - mytest("Value longer, braces, data before", "toto ${t}", "t=tututu", "toto tututu"); - mytest("Value longer, no braces, data before and after", "toto $t tata", "t=tututu", "toto tututu tata"); - mytest("Value longer, braces, data before and after", "toto ${t} tata", "t=tututu", "toto tututu tata"); - - mytest("Value much longer, no braces, only variable", "$t", "t=" force_resize, force_resize); - mytest("Value much longer, braces, only variable", "${t}", "t=" force_resize, force_resize); - mytest("Value much longer, no braces, data after", "$t toto", "t=" force_resize, force_resize " toto"); - mytest("Value much longer, braces, data after", "${t} toto", "t=" force_resize, force_resize " toto"); - mytest("Value much longer, no braces, data before", "toto $t", "t=" force_resize, "toto " force_resize); - mytest("Value much longer, braces, data before", "toto ${t}", "t=" force_resize, "toto " force_resize); - mytest("Value much longer, no braces, data before and after", "toto $t tata", "t=" force_resize, "toto " force_resize " tata"); - mytest("Value much longer, braces, data before and after", "toto ${t} tata", "t=" force_resize, "toto " force_resize " tata"); - - mytest("Escaped $", "\\$tutu", "tutu=t", "\\$tutu"); - mytest("Space in var name (with braces)", "${tu ti}", "tu_ti=t", "t"); - - mytest("Two variables", "$toto $tutu","toto=1 tutu=2", "1 2"); + xbt_test_add0("Empty");mytest("", "", ""); + + xbt_test_add0("Value shorter, no braces, only variable");mytest("$tutu", "tutu=t", "t"); + xbt_test_add0("Value shorter, braces, only variable");mytest("${tutu}", "tutu=t", "t"); + xbt_test_add0("Value shorter, no braces, data after");mytest("$tutu toto", "tutu=t", "t toto"); + xbt_test_add0("Value shorter, braces, data after");mytest("${tutu} toto", "tutu=t", "t toto"); + xbt_test_add0("Value shorter, no braces, data before");mytest("toto $tutu", "tutu=t", "toto t"); + xbt_test_add0("Value shorter, braces, data before");mytest("toto ${tutu}", "tutu=t", "toto t"); + xbt_test_add0("Value shorter, no braces, data before and after");mytest("toto $tutu tata", "tutu=t", "toto t tata"); + xbt_test_add0("Value shorter, braces, data before and after");mytest("toto ${tutu} tata", "tutu=t", "toto t tata"); + + xbt_test_add0("Value as long, no braces, only variable");mytest("$tutu", "tutu=12345", "12345"); + xbt_test_add0("Value as long, braces, only variable");mytest("${tutu}", "tutu=1234567", "1234567"); + xbt_test_add0("Value as long, no braces, data after");mytest("$tutu toto", "tutu=12345", "12345 toto"); + xbt_test_add0("Value as long, braces, data after");mytest("${tutu} toto", "tutu=1234567", "1234567 toto"); + xbt_test_add0("Value as long, no braces, data before");mytest("toto $tutu", "tutu=12345", "toto 12345"); + xbt_test_add0("Value as long, braces, data before");mytest("toto ${tutu}", "tutu=1234567", "toto 1234567"); + xbt_test_add0("Value as long, no braces, data before and after");mytest("toto $tutu tata", "tutu=12345", "toto 12345 tata"); + xbt_test_add0("Value as long, braces, data before and after");mytest("toto ${tutu} tata", "tutu=1234567", "toto 1234567 tata"); + + xbt_test_add0("Value longer, no braces, only variable");mytest("$t", "t=tututu", "tututu"); + xbt_test_add0("Value longer, braces, only variable");mytest("${t}", "t=tututu", "tututu"); + xbt_test_add0("Value longer, no braces, data after");mytest("$t toto", "t=tututu", "tututu toto"); + xbt_test_add0("Value longer, braces, data after");mytest("${t} toto", "t=tututu", "tututu toto"); + xbt_test_add0("Value longer, no braces, data before");mytest("toto $t", "t=tututu", "toto tututu"); + xbt_test_add0("Value longer, braces, data before");mytest("toto ${t}", "t=tututu", "toto tututu"); + xbt_test_add0("Value longer, no braces, data before and after");mytest("toto $t tata", "t=tututu", "toto tututu tata"); + xbt_test_add0("Value longer, braces, data before and after");mytest("toto ${t} tata", "t=tututu", "toto tututu tata"); + + xbt_test_add0("Value much longer, no braces, only variable");mytest("$t", "t=" force_resize, force_resize); + xbt_test_add0("Value much longer, no braces, data after");mytest("$t toto", "t=" force_resize, force_resize " toto"); + xbt_test_add0("Value much longer, braces, data after");mytest("${t} toto", "t=" force_resize, force_resize " toto"); + xbt_test_add0("Value much longer, no braces, data before");mytest("toto $t", "t=" force_resize, "toto " force_resize); + xbt_test_add0("Value much longer, braces, data before");mytest("toto ${t}", "t=" force_resize, "toto " force_resize); + xbt_test_add0("Value much longer, no braces, data before and after");mytest("toto $t tata", "t=" force_resize, "toto " force_resize " tata"); + xbt_test_add0("Value much longer, braces, data before and after");mytest("toto ${t} tata", "t=" force_resize, "toto " force_resize " tata"); + + xbt_test_add0("Escaped $");mytest("\\$tutu", "tutu=t", "\\$tutu"); + xbt_test_add0("Space in var name (with braces)");mytest("${tu ti}", "tu_ti=t", "t"); + + xbt_test_add0("Two variables");mytest("$toto $tutu","toto=1 tutu=2", "1 2"); // Commented: I'm too lazy to do a memmove in var name to remove the backslash after use. // Users should use braces. - // mytest("Escaped space in var name", "$tu\\ ti", "tu_ti=t", "t"); + // xbt_test_add0("Escaped space in var name", "$tu\\ ti", "tu_ti=t", "t"); - mytest("Default value", "${t:-toto}", "", "toto"); - mytest("Useless default value (variable already defined)", "${t:-toto}", "t=TRUC", "TRUC"); + xbt_test_add0("Default value");mytest("${t:-toto}", "", "toto"); + xbt_test_add0("Useless default value (variable already defined)");mytest("${t:-toto}", "t=TRUC", "TRUC"); }