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 C19543858D1E for ; Wed, 21 Dec 2022 22:29:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C19543858D1E 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 reform (deer0x15.wildebeest.org [172.31.17.151]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id A55D6300071A; Wed, 21 Dec 2022 23:29:36 +0100 (CET) Received: by reform (Postfix, from userid 1000) id 311EF2E808FB; Wed, 21 Dec 2022 23:29:36 +0100 (CET) Date: Wed, 21 Dec 2022 23:29:36 +0100 From: Mark Wielaard To: Yonggang Luo Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH v2 15/16] libelf: F_GETFD may not predefined with msvc/mingw, guard the usage of it Message-ID: References: <20221217165213.152-1-luoyonggang@gmail.com> <20221217165213.152-16-luoyonggang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221217165213.152-16-luoyonggang@gmail.com> X-Spam-Status: No, score=-3038.4 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 Sun, Dec 18, 2022 at 12:52:12AM +0800, Yonggang Luo via Elfutils-devel wrote: > Signed-off-by: Yonggang Luo > --- > libelf/elf_begin.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c > index 6d31882e..3d324694 100644 > --- a/libelf/elf_begin.c > +++ b/libelf/elf_begin.c > @@ -1163,12 +1163,19 @@ elf_begin (int fildes, Elf_Cmd cmd, Elf *ref) > if (ref != 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) == -1 && errno == EBADF)) > { > /* We cannot do anything productive without a file descriptor. */ > __libelf_seterrno (ELF_E_INVALID_FILE); > return NULL; > } > +#else > + else if (fildes < 0) > + { > + return NULL; > + } > +#endif That new return NULL is missing a __libelf_seterrno. Cheers, Mark