[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FYI: [branch-2-0] fix warnings on cygwin
From: |
Christoph Egger |
Subject: |
Re: FYI: [branch-2-0] fix warnings on cygwin |
Date: |
Thu, 4 Aug 2005 15:45:12 +0200 (MEST) |
> Hi Christoph,
>
> Sorry for the late response.
>
> * Christoph Egger wrote on Sat, Jul 16, 2005 at 09:35:40AM CEST:
> >
> > I got some warnings when I build a program on cygwin with latest
> > gcc and -Wcast-qual flag:
>
> > libtool: link: creating evtimestamp.exe
> > ./.libs/lt-evtimestamp.c: In function `main':
> > ./.libs/lt-evtimestamp.c:95: warning: assignment discards qualifiers
> from
> > pointer target type
> > ./.libs/lt-evtimestamp.c: In function `basename':
> > ./.libs/lt-evtimestamp.c:148: warning: cast discards qualifiers from
> pointer
> > target type
>
> Thanks for the bug report. I have applied the following, slightly
> different patch to branch-2-0 and HEAD. It changes basename to
> base_name on the grounds that eventual clashes with system prototypes
> are avoided and our base_name is but a crippled version of the standard
> interface anyway.
Thank you for applying the patch.
But why did you drop one line?
base_name() should return const char * and not char *
The cast in the return makes the compiler still believe
to have to do two castings:
1. Cast from const char * to char * => causes warning
2. Cast from char * back to const char * to fit return type
in the definition/declaration
Please replace
return (char *) base;
with
return base;
and the compiler (and I :) is (are) happy.
> Cheers,
> Ralf
>
> 2005-08-04 Christoph Egger <address@hidden>
>
> * config/ltmain.m4sh (func_mode_link) <cwrappersource>: Change
> basename() to base_name() and have it return a pointer to const,
> fix compilation warnings.
>
> Index: config/ltmain.m4sh
> ===================================================================
> RCS file: /cvsroot/libtool/libtool/config/ltmain.m4sh,v
> retrieving revision 1.76
> diff -u -r1.76 ltmain.m4sh
> --- config/ltmain.m4sh 28 Jul 2005 10:23:18 -0000 1.76
> +++ config/ltmain.m4sh 4 Aug 2005 12:03:16 -0000
> @@ -5807,7 +5807,7 @@
>
> void * xmalloc (size_t num);
> char * xstrdup (const char *string);
> -char * basename (const char *name);
> +const char * base_name (const char *name);
> char * find_executable(const char *wrapper);
> int check_executable(const char *path);
> char * strendzap(char *str, const char *pat);
> @@ -5819,14 +5819,14 @@
> char **newargz;
> int i;
>
> - program_name = (char *) xstrdup ((char *) basename (argv[[0]]));
> + program_name = (char *) xstrdup (base_name (argv[[0]]));
> DEBUG("(main) argv[[0]] : %s\n",argv[[0]]);
> DEBUG("(main) program_name : %s\n",program_name);
> newargz = XMALLOC(char *, argc+2);
> EOF
>
> cat >> $cwrappersource <<EOF
> - newargz[[0]] = "$SHELL";
> + newargz[[0]] = (char *) xstrdup("$SHELL");
> EOF
>
> cat >> $cwrappersource <<"EOF"
> @@ -5883,8 +5883,8 @@
> ;
> }
>
> -char *
> -basename (const char *name)
> +const char *
> +base_name (const char *name)
> {
> const char *base;
>
>
--
Greetings,
Christoph
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++