From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: emacs & MAXPATHLEN Date: Fri, 29 Jul 2005 16:54:41 +0300 Message-ID: References: <87fytzj6a7.fsf@gmail.com> <87pst2h35e.fsf@gmail.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1122646424 24024 80.91.229.2 (29 Jul 2005 14:13:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 29 Jul 2005 14:13:44 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 29 16:13:36 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DyVc8-0008KT-6r for ged-emacs-devel@m.gmane.org; Fri, 29 Jul 2005 16:13:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DyVed-0001ZL-7y for ged-emacs-devel@m.gmane.org; Fri, 29 Jul 2005 10:16:03 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DyVTb-0005I5-BY for emacs-devel@gnu.org; Fri, 29 Jul 2005 10:04:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DyVTP-0005AI-Au for emacs-devel@gnu.org; Fri, 29 Jul 2005 10:04:29 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DyVTO-00055i-Ej for emacs-devel@gnu.org; Fri, 29 Jul 2005 10:04:26 -0400 Original-Received: from [192.114.186.24] (helo=legolas.inter.net.il) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DyVVR-0006v6-Bw for emacs-devel@gnu.org; Fri, 29 Jul 2005 10:06:33 -0400 Original-Received: from HOME-C4E4A596F7 (IGLD-83-130-250-73.inter.net.il [83.130.250.73]) by legolas.inter.net.il (MOS 3.5.8-GR) with ESMTP id FAB34103 (AUTH halo1); Fri, 29 Jul 2005 16:54:42 +0300 (IDT) Original-To: Giuseppe Scrivano In-reply-to: <87pst2h35e.fsf@gmail.com> (message from Giuseppe Scrivano on Fri, 29 Jul 2005 02:22:37 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:41310 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:41310 > From: Giuseppe Scrivano > Date: Fri, 29 Jul 2005 02:22:37 +0200 > Cc: emacs-devel@gnu.org > > This little patch should fix it. Thanks, but please see my comments below. > @@ -5146,14 +5146,47 @@ > && stat (".", &dotstat) == 0 > && dotstat.st_ino == pwdstat.st_ino > && dotstat.st_dev == pwdstat.st_dev > - && strlen (pwd) < MAXPATHLEN) > - strcpy (buf, pwd); > -#ifdef HAVE_GETCWD > - else if (getcwd (buf, MAXPATHLEN+1) == 0) > - fatal ("`getcwd' failed: %s\n", strerror (errno)); > +#ifdef MAXPATHLEN > + && strlen (pwd) < MAXPATHLEN > +#endif > + ) > + { > + buf = malloc(strlen(pwd)+1); > + if(!buf) > + fatal ("`malloc' failed in init_buffer\n"); This should have used xmalloc instead of calling malloc and checking for errors. > +#ifdef _GNU_SOURCE > + else > + { > + buf = get_current_dir_name(); > + if(!buf) > + fatal ("`get_current_dir_name' failed in init_buffer\n"); > + } I think this part is unnecessary. The old code didn't use get_current_dir_name, so I think we should not introduce it now. In any case, if we do introduce get_current_dir_name, we should add an Autoconf test for it, and then use HAVE_GET_CURRENT_DIR instead of _GNU_SOURCE (which I think is the wrong test anyway, btw: _GNU_SOURCE has nothing to do with availability of certain library functions). > + if(getcdwd (buf, MAXPATHLEN+1) == 0) ^^^^^^^ There's a typo in this line. Did you check that all the branches actually compile? > + else > + { > + buf = malloc(MAXPATHLEN+1); You are using MAXPATHLEN without testing for it being defined. If it is okay to assume that it is always defined, then why you introduced a test for that in the first hunk of your changes (see above)? > + if(!buf) > + fatal ("`malloc' failed in init_buffer\n"); Again, please use xmalloc. > + buf = malloc(MAXPATHLEN+1); > + if(!buf) > + fatal ("`malloc' failed in init_buffer\n"); > + if(buf) > + { > + if(getwd (buf) == 0) > + fatal ("`getwd' failed: %s\n", buf); > + } And here too: please use xmalloc, and please resolve the MAXPATHLEN issue. > + } > #endif > > #ifndef VMS > @@ -5189,6 +5222,7 @@ > > temp = get_minibuffer (0); > XBUFFER (temp)->directory = current_buffer->directory; > + free(buf); > } > > /* initialize the buffer routines */ > > > > I worked on the xsmfns.c file too. I am not sure if this is required for the hurd compatibility. The same comments apply there as well.