From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id C11273852C78 for ; Mon, 12 Dec 2022 15:55:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C11273852C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from tarox.wildebeest.org (83-87-18-245.cable.dynamic.v4.ziggo.nl [83.87.18.245]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id CA7CB3045FA6; Mon, 12 Dec 2022 16:54:59 +0100 (CET) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 8D5D2400142A; Mon, 12 Dec 2022 16:54:59 +0100 (CET) Message-ID: Subject: Re: [PATCH 19/25] libelf: F_GETFD may not predefined with msvc/mingw, guard the usage of it From: Mark Wielaard To: Yonggang Luo , elfutils-devel@sourceware.org Date: Mon, 12 Dec 2022 16:54:59 +0100 In-Reply-To: <20221020182603.815-20-luoyonggang@gmail.com> References: <20221020182603.815-1-luoyonggang@gmail.com> <20221020182603.815-20-luoyonggang@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution 3.28.5 (3.28.5-10.el7) Mime-Version: 1.0 X-Spam-Status: No, score=-3038.7 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, On Fri, 2022-10-21 at 02:25 +0800, Yonggang Luo via Elfutils-devel wrote: > Signed-off-by: Yonggang Luo > --- > libelf/elf_begin.c | 2 ++ > 1 file changed, 2 insertions(+) >=20 > diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c > index 6d31882e..d867cd6f 100644 > --- a/libelf/elf_begin.c > +++ b/libelf/elf_begin.c > @@ -1163,12 +1163,14 @@ elf_begin (int fildes, Elf_Cmd cmd, Elf *ref) > if (ref !=3D NULL) > /* Make sure the descriptor is not suddenly going away. */ > rwlock_rdlock (ref->lock); > +#if defined(F_GETFD) > else if (unlikely (fcntl (fildes, F_GETFD) =3D=3D -1 && errno =3D=3D > EBADF)) > { > /* We cannot do anything productive without a file > descriptor. */ > __libelf_seterrno (ELF_E_INVALID_FILE); > return NULL; > } > +#endif If you cannot check validity of fildes using fcntl, then shouldn't you at least check for fildes >=3D 0 ? Cheers, Mark