From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#8401: removing duplication and improving the readlink code Date: Fri, 01 Apr 2011 12:00:28 -0700 Organization: UCLA Computer Science Department Message-ID: <4D9620CC.4000806@cs.ucla.edu> References: <4D9574F2.20108@cs.ucla.edu> <83vcyypdzy.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1301684849 20427 80.91.229.12 (1 Apr 2011 19:07:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 1 Apr 2011 19:07:29 +0000 (UTC) Cc: 8401@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 01 21:07:25 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q5jgq-0001yd-WC for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Apr 2011 21:07:25 +0200 Original-Received: from localhost ([127.0.0.1]:55990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5jgp-0004cG-Af for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Apr 2011 15:07:23 -0400 Original-Received: from [140.186.70.92] (port=42291 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5jgf-0004bl-LF for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 15:07:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q5jge-0006sk-Jg for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 15:07:13 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q5jge-0006sf-I1 for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 15:07:12 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Q5jag-00083r-0g; Fri, 01 Apr 2011 15:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Apr 2011 19:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8401 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8401-submit@debbugs.gnu.org id=B8401.130168443830951 (code B ref 8401); Fri, 01 Apr 2011 19:01:01 +0000 Original-Received: (at 8401) by debbugs.gnu.org; 1 Apr 2011 19:00:38 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q5jaH-00083A-Tm for submit@debbugs.gnu.org; Fri, 01 Apr 2011 15:00:38 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q5jaE-00082s-NZ for 8401@debbugs.gnu.org; Fri, 01 Apr 2011 15:00:35 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 1C0B939E80F8; Fri, 1 Apr 2011 12:00:29 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8T0hIQ9opOjR; Fri, 1 Apr 2011 12:00:28 -0700 (PDT) Original-Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id A828D39E80B1; Fri, 1 Apr 2011 12:00:28 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9 In-Reply-To: <83vcyypdzy.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 01 Apr 2011 15:01:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:45564 Archived-At: On 04/01/2011 01:33 AM, Eli Zaretskii wrote: > Isn't much easier and much more elegant to use ssize_t instead of an > int for the buffer sizes in both cases? That doesn't suffice; the code should not only use ssize_t for readlink's returned value, but it should also use size_t for the buffer size, and it should check that neither type overflows. We could modify both copies of Emacs's readlink-using code to fix these problems, but when there's duplication like this, it's typically better to have just one copy of the code, and make any necessary fixes in that copy. On 04/01/2011 01:33 AM, Eli Zaretskii wrote: > If this patch is accepted, the new emacs_readlink function will be a > trivial "fail" stub on Windows. That would introduce an unnecessary "#ifdef DOS_NT" into the mainline code. We should strive to keep the mainline code free of porting #ifdefs when it is easy, as it is in this case. The proposed code should run just fine on Windows, using the already-existing stubs. We shouldn't need to clutter up up the mainline code with unnecessary Windows-specific microoptimizations.