From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7913 Path: news.gmane.org!not-for-mail From: Alex Newsgroups: gmane.linux.lib.musl.general Subject: Re: getgrgid and errno Date: Tue, 9 Jun 2015 21:17:47 +0200 Message-ID: References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c30f9e1dfd2605181a9d47 X-Trace: ger.gmane.org 1433877485 11389 80.91.229.3 (9 Jun 2015 19:18:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Jun 2015 19:18:05 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7926-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jun 09 21:18:04 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Z2P2B-0008CK-ED for gllmg-musl@m.gmane.org; Tue, 09 Jun 2015 21:18:03 +0200 Original-Received: (qmail 6079 invoked by uid 550); 9 Jun 2015 19:18:00 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 6058 invoked from network); 9 Jun 2015 19:17:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=aRpiwg840XZRVTNmDAPKBRYvaArFDPoW/1UJbibvUUE=; b=whX74LLq9kfG94tWFAoTkQ54cXab7tpVMcMmma7oUcx3CyLSUWEjTguYlCPL07mjdW dvm6BgYN9JK9AbHO1m3qtr9Zxwjlm7DWsZJNNb8wG1Yaxusf6piiy+jN8avTzZsOYDDl jQGqk0NiLQQ3EyhUmSbLwq+AAUlcGrPlU7KJW+uc1bvWTdL9CXJFy1cFBHkuzvpuDOLa Yzl9Mswm66N7a6pe+Q1tEVRFCpcc56jJNom5rYaPy1EShU6NCDmZdIHdHxq3/H44lkcM /A9I2obRrZ4XZyuWAW/YMx2KXmewC5hTCCyXikBUPlTUrt8JeRmM3o7c0C4GCwnjLEee ks5g== X-Received: by 10.42.226.8 with SMTP id iu8mr392837icb.17.1433877467756; Tue, 09 Jun 2015 12:17:47 -0700 (PDT) In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:7913 Archived-At: --001a11c30f9e1dfd2605181a9d47 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable The code which you show says "if (rv) errno =3D rv". The debugger shows tha= t rv is 0. So the condition is false and errno is not set. It must have been set to ENOENT somewhere above that -- as you single-step through the code, keep printing errno on each line to find out where. On Tue, Jun 9, 2015 at 2:59 PM, Julien Ramseier wrote: > Hello, > > I=E2=80=99m encountering a strange problem with getgrgid. > > Calling this function with a non-existent group sets errno to ENOENT > instead of 0. > This small test program below prints getgrgid: No such file or directory. > > #include > #include > #include > #include > > int main(void) { > errno =3D 0; > struct group *g =3D getgrgid(1234); > perror("getgrgid"); > } > > However, when stepping through __getgr_a with gdb, errno seems to be > correctly set to 0: > > 167 if (rv) errno =3D rv; > (gdb) > 168 return rv; > (gdb) p rv > $6 =3D 0 > > So I really don=E2=80=99t know what=E2=80=99s going on=E2=80=A6Am I missi= ng something? > > - > Julien > --001a11c30f9e1dfd2605181a9d47 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
The code which you show says "if (rv) errno =3D rv&qu= ot;. The debugger shows that rv is 0. So the condition is false and errno i= s not set.

It must have been set to ENOENT somewhere abo= ve that -- as you single-step through the code, keep printing errno on each= line to find out where.

On Tue, Jun 9, 2015 at 2:59 PM, Julien Ramseier <j.r= amseier@gmail.com> wrote:
<= div style=3D"word-wrap:break-word">Hello,

I=E2=80=99m en= countering a strange problem with getgrgid.

Callin= g this function with a non-existent group sets errno to ENOENT instead of 0= .
This small test program below prints getgrgid: No such file or = directory.

#include &l= t;sys/types.h>
#include <grp.= h>
#include <stddef.h>
#include <errno.h>
<= div>
int= main(void) {
errno =3D 0;
struct group *g =3D getgrgid= (1234);
perror("getgrgid");
}

However, when stepping= through=C2=A0__getgr_a with gdb, errno seems to be correctly set to 0:

167 if (rv) errno =3D rv;
(gdb)
168 return rv;
(gdb) p rv
$6 =3D 0

So I really don=E2=80=99t know wha= t=E2=80=99s going on=E2=80=A6Am I missing something?

-
Julien

--001a11c30f9e1dfd2605181a9d47--