From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16542 invoked by alias); 27 Jan 2012 12:02:15 -0000 Received: (qmail 16534 invoked by uid 22791); 27 Jan 2012 12:02:14 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_WEB,SPF_SOFTFAIL,TW_SM X-Spam-Check-By: sourceware.org Received: from mtaout23.012.net.il (HELO mtaout23.012.net.il) (80.179.55.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Jan 2012 12:01:58 +0000 Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0LYG00F00HEPGL00@a-mtaout23.012.net.il> for gdb-patches@sourceware.org; Fri, 27 Jan 2012 14:01:56 +0200 (IST) Received: from HOME-C4E4A596F7 ([84.228.102.195]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LYG00FH8HF7BIB0@a-mtaout23.012.net.il>; Fri, 27 Jan 2012 14:01:56 +0200 (IST) Date: Fri, 27 Jan 2012 12:22:00 -0000 From: Eli Zaretskii Subject: Re: fix build error on MinGW (HAVE_READLINK) undefined In-reply-to: <4F22760A.2020309@redhat.com> To: Pedro Alves Cc: asmwarrior@gmail.com, gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83ehulz77q.fsf@gnu.org> References: <4F2206DE.20907@gmail.com> <83k44dzejs.fsf@gnu.org> <4F22760A.2020309@redhat.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00944.txt.bz2 > Date: Fri, 27 Jan 2012 10:01:46 +0000 > From: Pedro Alves > CC: asmwarrior , gdb-patches@sourceware.org > > > I think you need to set errno to EINVAL in the #else branch, because > > the meaning of that error on systems that do have readlink is "the > > named file is not a symbolic link". > > > > On second thought, perhaps a better way would be to define a readlink > > for MinGW that always sets errno to EINVAL and returns -1. Then the > > ugly #ifdef can go away. > > The corresponding native side returns ENOSYS/FILEIO_ENOSYS, indicating > the function is not supported by the implementation. GDBserver should do > the same. But isn't ENOSYS sub-optimal in this case? Systems that don't have readlink don't have symlinks, either. So any file there is trivially, by definition, not a symlink. Why not tell that to the caller, and have the rest of the code work "normally"? By contrast, setting errno to ENOSYS will most likely be processed as an exceptional situation, like failing the command that invoked readlink. How is that TRT? > >> static char * > >> inf_child_fileio_readlink (const char *filename, int *target_errno) > >> { > >> /* We support readlink only on systems that also provide a compile-time > >> maximum path length (MAXPATHLEN), at least for now. */ > >> #if defined (HAVE_READLINK) && defined (MAXPATHLEN) > >> char buf[MAXPATHLEN]; > >> int len; > >> char *ret; > >> > >> len = readlink (filename, buf, sizeof buf); > > > > Here too. > > The #else branch just below reads: > > #else > *target_errno = FILEIO_ENOSYS; > return NULL; > #endif Which is wrong, don't you think?