From 957e238614326198452b53498ae98e546fce7366 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 9 Jan 2010 21:58:50 +0100 Subject: ctime: do not use static struct tm buffer text data bss dec hex filename - 19 0 0 19 13 libc/misc/time/ctime.o + 25 0 0 25 19 libc/misc/time/ctime.o Signed-off-by: Denys Vlasenko --- libc/misc/time/time.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'libc/misc') diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c index 583c17aad..dfa8c0daf 100644 --- a/libc/misc/time/time.c +++ b/libc/misc/time/time.c @@ -274,7 +274,7 @@ libc_hidden_def(asctime) * If we take the implicit assumption as given, then the implementation below * is still incorrect for tm_year values < -900, as there will be either * 0-padding and/or a missing negative sign for the year conversion . But given - * the ususal use of asctime(), I think it isn't unreasonable to restrict correct + * the usual use of asctime(), I think it isn't unreasonable to restrict correct * operation to the domain of years between 1000 and 9999. */ @@ -465,8 +465,22 @@ clock_t clock(void) char *ctime(const time_t *t) { - /* ANSI/ISO/SUSv3 say that ctime is equivalent to the following. */ - return asctime(localtime(t)); + /* ANSI/ISO/SUSv3 say that ctime is equivalent to the following: + * return asctime(localtime(t)); + * I don't think "equivalent" means "it uses the same internal buffer", + * it means "gives the same resultant string". + * + * I doubt anyone ever uses weird code like: + * struct tm *ptm = localtime(t1); ...; ctime(t2); use(ptm); + * which relies on the assumption that ctime's and localtime's + * internal static struct tm is the same. + * + * Using localtime_r instead of localtime avoids linking in + * localtime's static buffer: + */ + struct tm xtm; + + return asctime(localtime_r(t, &xtm)); } libc_hidden_def(ctime) #endif -- cgit v1.2.3 From 831ea78623556cbfae002477afc6256cacaaf2c6 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Thu, 21 Jan 2010 10:42:02 +0100 Subject: wordexp: silence shadow warning Signed-off-by: Bernhard Reutner-Fischer --- libc/misc/wordexp/wordexp.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'libc/misc') diff --git a/libc/misc/wordexp/wordexp.c b/libc/misc/wordexp/wordexp.c index 1737ccc48..2f529158c 100644 --- a/libc/misc/wordexp/wordexp.c +++ b/libc/misc/wordexp/wordexp.c @@ -1444,28 +1444,28 @@ parse_param(char **word, size_t * word_length, size_t * max_length, size_t exp_len; size_t exp_maxl; char *p; - int quoted = 0; /* 1: single quotes; 2: double */ + int quotes = 0; /* 1: single quotes; 2: double */ expanded = w_newword(&exp_len, &exp_maxl); for (p = pattern; p && *p; p++) { - size_t offset; + size_t _offset; switch (*p) { case '"': - if (quoted == 2) - quoted = 0; - else if (quoted == 0) - quoted = 2; + if (quotes == 2) + quotes = 0; + else if (quotes == 0) + quotes = 2; else break; continue; case '\'': - if (quoted == 1) - quoted = 0; - else if (quoted == 0) - quoted = 1; + if (quotes == 1) + quotes = 0; + else if (quotes == 0) + quotes = 1; else break; @@ -1473,7 +1473,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, case '*': case '?': - if (quoted) { + if (quotes) { /* Convert quoted wildchar to escaped wildchar. */ expanded = w_addchar(expanded, &exp_len, &exp_maxl, '\\'); @@ -1484,9 +1484,9 @@ parse_param(char **word, size_t * word_length, size_t * max_length, break; case '$': - offset = 0; + _offset = 0; error = parse_dollars(&expanded, &exp_len, &exp_maxl, p, - &offset, flags, NULL, NULL, NULL, 1); + &_offset, flags, NULL, NULL, NULL, 1); if (error) { if (free_value) free(value); @@ -1496,16 +1496,16 @@ parse_param(char **word, size_t * word_length, size_t * max_length, goto do_error; } - p += offset; + p += _offset; continue; case '~': - if (quoted || exp_len) + if (quotes || exp_len) break; - offset = 0; + _offset = 0; error = parse_tilde(&expanded, &exp_len, &exp_maxl, p, - &offset, 0); + &_offset, 0); if (error) { if (free_value) free(value); @@ -1515,7 +1515,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length, goto do_error; } - p += offset; + p += _offset; continue; case '\\': -- cgit v1.2.3 From 95bb1ae902f590156048149c73da48fe851ed224 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Sat, 23 Jan 2010 22:37:01 +0100 Subject: silence some warnings about unused params Signed-off-by: Bernhard Reutner-Fischer --- libc/misc/glob/glob-susv3.c | 3 ++- libc/misc/internals/__uClibc_main.c | 5 +++-- libc/misc/regex/regex_old.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'libc/misc') diff --git a/libc/misc/glob/glob-susv3.c b/libc/misc/glob/glob-susv3.c index 1d64249c7..59b4d8e5f 100644 --- a/libc/misc/glob/glob-susv3.c +++ b/libc/misc/glob/glob-susv3.c @@ -183,7 +183,8 @@ int __glob_match_in_dir(const char *d, const char *p, int flags, int (*errfunc)( # ifndef BUILD_GLOB64 static # endif -int __glob_ignore_err(const char *path, int err) +int __glob_ignore_err(const char * path attribute_unused, + int err attribute_unused) { return 0; } diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c index b166aaaa7..19acbe0d6 100644 --- a/libc/misc/internals/__uClibc_main.c +++ b/libc/misc/internals/__uClibc_main.c @@ -257,10 +257,11 @@ libc_hidden_def(__uClibc_fini) */ void __uClibc_main(int (*main)(int, char **, char **), int argc, char **argv, void (*app_init)(void), void (*app_fini)(void), - void (*rtld_fini)(void), void *stack_end) attribute_noreturn; + void (*rtld_fini)(void), + void *stack_end attribute_unused) attribute_noreturn; void __uClibc_main(int (*main)(int, char **, char **), int argc, char **argv, void (*app_init)(void), void (*app_fini)(void), - void (*rtld_fini)(void), void *stack_end) + void (*rtld_fini)(void), void *stack_end attribute_unused) { #ifndef __ARCH_HAS_NO_LDSO__ unsigned long *aux_dat; diff --git a/libc/misc/regex/regex_old.c b/libc/misc/regex/regex_old.c index cbfb7ae7c..bc2ad6cb8 100644 --- a/libc/misc/regex/regex_old.c +++ b/libc/misc/regex/regex_old.c @@ -8140,7 +8140,7 @@ libc_hidden_def(regexec) size_t regerror ( int errcode, - const regex_t *preg, + const regex_t * preg attribute_unused, char *errbuf, size_t errbuf_size) { -- cgit v1.2.3 From a9df793a753f259b7e31cde3d1be39632b29f454 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 24 Jan 2010 02:26:26 +0100 Subject: wchar.c: fix indentation Signed-off-by: Denys Vlasenko --- libc/misc/wchar/wchar.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'libc/misc') diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c index 448baafa1..7380ac9ae 100644 --- a/libc/misc/wchar/wchar.c +++ b/libc/misc/wchar/wchar.c @@ -286,7 +286,7 @@ size_t mbrtowc(wchar_t *__restrict pwc, const char *__restrict s, s = empty_string; n = 1; } else if (*s == '\0') { - /* According to the ISO C 89 standard this is the expected behaviour. */ + /* According to the ISO C 89 standard this is the expected behaviour. */ return 0; } else if (!n) { /* TODO: change error code? */ @@ -600,7 +600,7 @@ size_t attribute_hidden _wchar_wcsntoutf8s(char *__restrict s, size_t n, if (!s) { n = SIZE_MAX; } - s = buf; + s = buf; store = 0; } @@ -1026,9 +1026,9 @@ static const signed char new_wtbl[] = { int wcswidth(const wchar_t *pwcs, size_t n) { - int h, l, m, count; - wchar_t wc; - unsigned char b; + int h, l, m, count; + wchar_t wc; + unsigned char b; if (ENCODING == __ctype_encoding_7_bit) { size_t i; @@ -1064,7 +1064,7 @@ int wcswidth(const wchar_t *pwcs, size_t n) } #endif /* __CTYPE_HAS_UTF_8_LOCALES */ - for (count = 0 ; n && (wc = *pwcs++) ; n--) { + for (count = 0 ; n && (wc = *pwcs++) ; n--) { if (wc <= 0xff) { /* If we're here, wc != 0. */ if ((wc < 32) || ((wc >= 0x7f) && (wc < 0xa0))) { @@ -1114,9 +1114,9 @@ int wcswidth(const wchar_t *pwcs, size_t n) } ++count; - } + } - return count; + return count; } #else /* __UCLIBC_HAS_LOCALE__ */ @@ -1133,7 +1133,7 @@ int wcswidth(const wchar_t *pwcs, size_t n) } } - for (count = 0 ; n && (wc = *pwcs++) ; n--) { + for (count = 0 ; n && (wc = *pwcs++) ; n--) { if (wc <= 0xff) { /* If we're here, wc != 0. */ if ((wc < 32) || ((wc >= 0x7f) && (wc < 0xa0))) { @@ -1160,7 +1160,7 @@ libc_hidden_def(wcswidth) int wcwidth(wchar_t wc) { - return wcswidth(&wc, 1); + return wcswidth(&wc, 1); } #endif -- cgit v1.2.3