delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2012/03/07/13:36:13

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
Date: Wed, 07 Mar 2012 20:20:00 +0200
From: Eli Zaretskii <eliz AT gnu DOT org>
Subject: Re: errno returned by open()
In-reply-to: <201203071845.09240.juan.guerrero@gmx.de>
X-012-Sender: halo1 AT inter DOT net DOT il
To: djgpp-workers AT delorie DOT com
Message-id: <83obs81df3.fsf@gnu.org>
References: <201203071845 DOT 09240 DOT juan DOT guerrero AT gmx DOT de>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
> Date: Wed, 7 Mar 2012 18:45:09 +0100
> 
>    if (fd == -1)
>      return fd;	/* errno already set by _open or _creat */
> +  else
> +    errno = 0;  /* at this stage reset errno set by
> +                   previous calls to _open or _creat */

This isn't right.  If a function succeeds, it should leave errno at
the same value as it was when the function was called.  Forcing it to
zero is not TRT when some previous code set errno to something
non-zero.

What you need is to save the value of errno upon entry to `open', and
then restore it on successful exit.

Thanks.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019