libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Don't export lt__error_strings


From: Ralf Wildenhues
Subject: Re: Don't export lt__error_strings
Date: Sat, 24 Sep 2005 17:49:02 +0200
User-agent: Mutt/1.5.9i

Hi Peter,

I noted that some of your mails are missing References: and In-Reply-To:
headers, which break threading (at least for the web archives).  If it's
easy to fix this, it would be nice if you could change it.  Don't bother
wasting much time on this, though, it's not worth it.

* Peter Ekberg wrote on Fri, Sep 23, 2005 at 09:31:39PM CEST:
> * Ralf Wildenhues wrote on Friday, September 23, 2005 15:37 CEST:
> > * Peter Ekberg wrote on Fri, Sep 23, 2005 at 02:02:18PM CEST:

> > You wanted to set it to errormsg, not last_error.
> 
> Right. Sorry for wasting your time. I tested, then made one
> last round of minor changes without retesting. I should know
> better...

No problem at all.  The fix was really obvious.

> > If yes, please read dsohowto.pdf chapter 2.4.3 (or around 
> > there) titled
> 
> Oh, that old worthless document. Who needs that crap? :-)

Hehe.  The only thing that bugs me is that it's not current wrt.
libtool.  Oh well.

> Ok, going with the first method. I could not think up a good
> way to get the preprocessor to find out the longest error string
> so I counted it and defined LT_ERROR_LEN_MAX to 35. I then did
> some tests to see if gcc warned about too long strings in case
> someone carelessly adds a longer error string without changing
> the define. To my discomfort gcc does not seem to count the
> nul terminator when it decides whether to warn or not (-Wall).
> But I might be mistaken and might have made a mistake counting
> or something, but I don't think so. I checked a couple of times
> because I was so baffled.

Well, the trick is easy: add the nul to the initialization strings
explicitly:
  const char s[4] = "abc\0";

This way GCC will notify you.  The point is, when you say
  const char t[3] = "abc";
only 3 characters will be initialized, no trailing nul.  There are a few
cases where this is beneficial: it saves you a byte, when you know what
you are doing.  (Side note: with the static storage, all characters you
do not specify explicitly will be initialized to nul.)

Feel free to change the error strings, or leave them as-is.

>       * libltdl/libltdl/lt__private.h, libltdl/lt_error.c:
>       Don't export the lt__last_error and lt__error_strings
>       variables. Define lt__error_strings so that no relocations
>       are needed.
>       * libltdl/libltdl/lt__private.h (LT__STRERROR, LT__GETERROR)
>       (LT__SETERRORSTR): Adjust to not use the above variables,
>       instead use the following functions...
>       * libltdl/lt_error.c: (lt__error_string, lt__get_last_error)
>       (lt__set_last_error): Reimplement the functionality in
>       these functions instead.

The patch is fine with one missing piece: please add assert()s for
bounds-checked argument in lt__error_string().  A failure here is a
clear sign of a programming error on our part (and not some invalid but
external-to-ltdl condition), so we may just fail here.  Go ahead and
commit with this change.

Thanks!
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]