Re: DBI Driver.xst and DBD::cego

Jonathan Leffler <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Message-ID <CAH+RLGHGA-1MRj6zRVjBp8Uc=9bK17ceeVhCjoPqf3D0anPKDw@mail.gmail.com>
Since the only place 'plural' is used is the statement immediately after
the assignment, it is much simpler and perfectly safe to use

const char *plural = ...

than to futz around with the myp array as in the second patch (or to cast
away constness as in the first patch).



On Mon, May 27, 2013 at 8:16 AM, Kurt Jaeger <[email protected]> wrote:

> Hi!
>
> Tim wrote:
> > On Sun, May 26, 2013 at 08:13:58PM +0200, Kurt Jaeger wrote:
> > > https://rt.cpan.org/Ticket/Display.html?id=84285
> >
> >     error: invalid conversion from 'const char*' to 'char*'
> >
> > I'm surprised the compiler treats this as an error, it's normally a
> warning.
>
> > -        char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s";
> > +        char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? (char*)"" :
> (char*)"s";
>
> clang++ is more strict 8-}
>
> > > Can someone have a look at it ? Is that patch the right way to do it ?
> >
> > It would be better to put the const on the declaration in this case.
>  I.e.:
> >
> > -        char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s";
> > +        const char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s";
> >
> > but that may trigger other errors/warnings in later code which will need
> > attending to. (Same goes for the other hunk in the patch.)
> >
> > Could you give that a go?
>
> Have you seen my second attempt ? It's going along the clang line
> and seems much cleaner.
>
> --
> [email protected]            +49 171 3101372                         7 years to
> go !
>



-- 
Jonathan Leffler <[email protected]>  #include <disclaimer.h>
Guardian of DBD::Informix - v2013.0521 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.