This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/4] getaddrinfo: Avoid negating error values


----- Original Message -----
> From: "Pavel Simerda" <psimerda@redhat.com>
> To: "Joseph S. Myers" <joseph@codesourcery.com>
> Cc: "libc-alpha" <libc-alpha@sourceware.org>, "Siddhesh Poyarekar" <siddhesh@redhat.com>
> Sent: Monday, December 9, 2013 7:15:11 PM
> Subject: Re: [PATCH 2/4] getaddrinfo: Avoid negating error values
> 
> ----- Original Message -----
> > From: "Joseph S. Myers" <joseph@codesourcery.com>
> > To: "Pavel Simerda" <psimerda@redhat.com>
> > Cc: "libc-alpha" <libc-alpha@sourceware.org>, "Siddhesh Poyarekar"
> > <siddhesh@redhat.com>
> > Sent: Monday, December 9, 2013 7:00:24 PM
> > Subject: Re: [PATCH 2/4] getaddrinfo: Avoid negating error values
> > 
> > On Mon, 9 Dec 2013, Pavel Simerda wrote:
> > 
> > > There's no reason for negating the error values in the current code.
> > 
> > Could you clarify the underlying analysis more?
> 
> Sure.
> 
> > Is it always the case in
> > the present code that the error numbers get negated an even number of
> > times on their way to the user, and this patch changes that number to be
> > 0?
> 
> Yes.
> 
> It's easier than that. The getaddrinfo() function must only return an
> unmodified error value. After applying the patch, the error value goes
> unmodified from the constant expression to the user.
> 
> > What's the before-and-after interface for which functions return an
> > error number, or a negated error number, and what are the users for
> > functions whose return value semantics you've changed?
> 
> gaih_inet_serv():
> 
> before: 0, -ERROR [always non-positive]
> after: 0, ERROR [always non-negative]
> 
> gaih_inet():
> 
> before: 0, -ERROR, gaih_inet_serv() [always non-positive]
> after: 0, ERROR, gaih_inet_serv() [always non-negative]
> 
> getaddrinfo():
> 
> before: 0, ERROR, -gaih_inet() [always non-negative]
> after: 0, ERROR, gaih_inet() [always non-negative]
> 
> Overall behavior:
> 
> before: In the code, -ERROR is always used, getaddrinfo() would negate it
> back to ERROR or return ERROR on its own.
> after: In the code, ERROR is always used, getaddrinfo() returns it directly
> or returns ERROR on its own.
> 
> > Do none of those
> > functions have a comment above them describing the return value semantics,
> > which would need updating?
> 
> Nope, there are no comments about returned values.
> 
> Cheers,
> 
> Pavel

Ping.

> > --
> > Joseph S. Myers
> > joseph@codesourcery.com
> > 
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]