From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Warning patrol - misc things
Date: Thu, 26 Jul 2007 22:01:00 -0000 [thread overview]
Message-ID: <20070726220544.GN4603@sunsite.mff.cuni.cz> (raw)
Hi!
In ld-monetary gcc complains about
signed_char_var < -128 || signed_char_var > 127
check which is always false due to signed char range. The patch below just
disables range checking for the two vars that want full signed char range
to be allowed. If we want to do any range checking even there, we'd need
to check much earlier (when the unsigned long val.num is assigned to the
signed char, see whether we lost any bits in the conversion).
The rest are aliasing violations. In the first two cases the patch
will give a few cycle hit in functions that take a lot of time to execute
though, copying two longs isn't IMHO too expensive over possibility of
incorrectly generated code.
The last one is also aliasing violation, solved by peeling off the first
iteration.
2007-07-26 Jakub Jelinek <jakub@redhat.com>
* locale/programs/ld-monetary.c (monetary_finish): Avoid range check
for int_frac_digits and frac_digits.
* login/logout.c (logout): Avoid aliasing violation.
* login/logwtmp.c (logwtmp): Likewise.
* libio/genops.c (_IO_un_link): Avoid aliasing violation.
--- libc/locale/programs/ld-monetary.c.jj 2007-07-16 09:58:46.000000000 +0200
+++ libc/locale/programs/ld-monetary.c 2007-07-26 18:57:19.000000000 +0200
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995-1999,2000,2001,2002,2005 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1999,2000,2001,2002,2005,2007
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
@@ -279,13 +280,14 @@ not correspond to a valid name in ISO 42
monetary->cat = initval; \
} \
else if ((monetary->cat < min || monetary->cat > max) \
+ && min < max \
&& !be_quiet && !nothing) \
WITH_CUR_LOCALE (error (0, 0, _("\
%s: value for field `%s' must be in range %d...%d"), \
"LC_MONETARY", #cat, min, max))
- TEST_ELEM (int_frac_digits, -128, 127, -1);
- TEST_ELEM (frac_digits, -128, 127, -1);
+ TEST_ELEM (int_frac_digits, 1, 0, -1);
+ TEST_ELEM (frac_digits, 1, 0, -1);
TEST_ELEM (p_cs_precedes, -1, 1, -1);
TEST_ELEM (p_sep_by_space, -1, 2, -1);
TEST_ELEM (n_cs_precedes, -1, 1, -1);
--- libc/login/logout.c.jj 2002-10-24 01:49:21.000000000 +0200
+++ libc/login/logout.c 2007-07-26 13:17:14.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2002, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -51,15 +51,10 @@ logout (const char *line)
bzero (ut->ut_host, sizeof ut->ut_host);
#endif
#if _HAVE_UT_TV - 0
- if (sizeof (ut->ut_tv) == sizeof (struct timeval))
- __gettimeofday ((struct timeval *) &ut->ut_tv, NULL);
- else
- {
struct timeval tv;
__gettimeofday (&tv, NULL);
ut->ut_tv.tv_sec = tv.tv_sec;
ut->ut_tv.tv_usec = tv.tv_usec;
- }
#else
ut->ut_time = time (NULL);
#endif
--- libc/login/logwtmp.c.jj 2002-10-24 01:49:21.000000000 +0200
+++ libc/login/logwtmp.c 2007-07-26 13:17:14.000000000 +0200
@@ -44,15 +44,10 @@ logwtmp (const char *line, const char *n
#endif
#if _HAVE_UT_TV - 0
- if (sizeof (ut.ut_tv) == sizeof (struct timeval))
- __gettimeofday ((struct timeval *) &ut.ut_tv, NULL);
- else
- {
- struct timeval tv;
- __gettimeofday (&tv, NULL);
- ut.ut_tv.tv_sec = tv.tv_sec;
- ut.ut_tv.tv_usec = tv.tv_usec;
- }
+ struct timeval tv;
+ __gettimeofday (&tv, NULL);
+ ut.ut_tv.tv_sec = tv.tv_sec;
+ ut.ut_tv.tv_usec = tv.tv_usec;
#else
ut.ut_time = time (NULL);
#endif
--- libc/libio/genops.c.jj 2007-04-23 10:54:00.000000000 +0200
+++ libc/libio/genops.c 2007-07-26 13:17:14.000000000 +0200
@@ -64,23 +64,29 @@ _IO_un_link (fp)
{
if (fp->file._flags & _IO_LINKED)
{
- struct _IO_FILE_plus **f;
+ struct _IO_FILE **f;
#ifdef _IO_MTSAFE_IO
_IO_cleanup_region_start_noarg (flush_cleanup);
_IO_lock_lock (list_all_lock);
run_fp = (_IO_FILE *) fp;
_IO_flockfile ((_IO_FILE *) fp);
#endif
- for (f = &INTUSE(_IO_list_all); *f;
- f = (struct _IO_FILE_plus **) &(*f)->file._chain)
+ if (INTUSE(_IO_list_all) == NULL)
+ ;
+ else if (fp == INTUSE(_IO_list_all))
{
- if (*f == fp)
+ INTUSE(_IO_list_all)
+ = (struct _IO_FILE_plus *) INTUSE(_IO_list_all)->file._chain;
+ ++_IO_list_all_stamp;
+ }
+ else
+ for (f = &INTUSE(_IO_list_all)->file._chain; *f; f = &(*f)->_chain)
+ if (*f == (_IO_FILE *) fp)
{
- *f = (struct _IO_FILE_plus *) fp->file._chain;
+ *f = fp->file._chain;
++_IO_list_all_stamp;
break;
}
- }
fp->file._flags &= ~_IO_LINKED;
#ifdef _IO_MTSAFE_IO
_IO_funlockfile ((_IO_FILE *) fp);
Jakub
reply other threads:[~2007-07-26 22:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070726220544.GN4603@sunsite.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).