bug-gnustep
[Top][All Lists]
Advanced

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

Re: NSLog() / NSLogv() annoyance


From: Richard Frith-Macdonald
Subject: Re: NSLog() / NSLogv() annoyance
Date: Fri, 1 Aug 2003 07:10:52 +0100


On Friday, August 1, 2003, at 04:09 AM, Adam Fedor wrote:


On Thursday, July 31, 2003, at 10:54 AM, Chris B. Vetter wrote:

On 30 Jul 2003 21:47:29 -0600
Adam Fedor <fedor@doc.com> wrote:
[...]
Can't figure out where errno is set to 2, though I suspect it's
coming from _NSLog_standard_printf_handler() trying to write to
syslog(?).
I traced this down (and down, etc) - it actually happens when NSLog
gets a user default, and NSUserDefaults gets set up and looks for
.GNUsteprc, eventually getting to:
  +[GSAttrDictionary attributesAt: traverseLink:]
which does a 'stat' on the file which doesn't exist. Anyway, what
should GNUstep do in this case? Reset errno to 0? The documentation
says the value isn't significant unless a library function returns an
error, so it really is undefined in this case.

That's interesting, because .GNUsteprc does exist, though it's empty.

Well it's looking for the one in the System root.


Instead, it could/should "back up" the original value of errno, call
stat(2) and do some kind of evaluation if necessary, then restore the
original?



So NSLog should back-up the original? It's kind-of crazy, but probably the best solution, since there are a lot of places where gnustep-base uses c-library functions (we don't want to have to change all of them), and NSLog is probably the only place where the developer would expect errno to be the same before and after the call.

Sorry to come in so late to this ... I've been away from home on business ...

In unix, the value of errno is conventionally (and I think perhaps explicitly) undefined except for immediately after executing a system call which failed (or after a library
function which is explicitly documented to set errno).

So tracking down exactly why something within NSLog() sets errno a particular way seem of dubious benefit, since any code which relies on testing errno after the call to NSLog() is by definition buggy in that it is depending on undefined behavior.

Is there anything I've missed in this thread to give a reason why NSLog() should behave differently from all other functions and methods? Perhaps this is a documented Apple
behavior or something?





reply via email to

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