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 18:57:24 -0700 Organization: UCLA Computer Science Department Message-ID: <4D968284.1000009@cs.ucla.edu> References: <4D9574F2.20108@cs.ucla.edu> <83vcyypdzy.fsf@gnu.org> <4D9620CC.4000806@cs.ucla.edu> <83hbahyd64.fsf@gnu.org> <4D9630F2.1010806@cs.ucla.edu> <838vvty9il.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1301710044 8756 80.91.229.12 (2 Apr 2011 02:07:24 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 2 Apr 2011 02:07:24 +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 Sat Apr 02 04:07:20 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 1Q5qFD-0002pv-3W for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Apr 2011 04:07:19 +0200 Original-Received: from localhost ([127.0.0.1]:56762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5qFC-0006dV-5p for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Apr 2011 22:07:18 -0400 Original-Received: from [140.186.70.92] (port=54024 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5qF7-0006dQ-T8 for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 22:07:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q5qF6-000740-Rs for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 22:07:13 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q5qF6-00073w-PD for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 22:07:12 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Q5q6E-0000QK-FI; Fri, 01 Apr 2011 21:58: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: Sat, 02 Apr 2011 01:58:02 +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.13017094611600 (code B ref 8401); Sat, 02 Apr 2011 01:58:02 +0000 Original-Received: (at 8401) by debbugs.gnu.org; 2 Apr 2011 01:57:41 +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 1Q5q5t-0000Pk-1I for submit@debbugs.gnu.org; Fri, 01 Apr 2011 21:57:41 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q5q5q-0000PZ-Q2 for 8401@debbugs.gnu.org; Fri, 01 Apr 2011 21:57:39 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 1DD6C39E80FA; Fri, 1 Apr 2011 18:57:33 -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 pji42Phw5BjV; Fri, 1 Apr 2011 18:57:32 -0700 (PDT) Original-Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 7A64F39E80F0; Fri, 1 Apr 2011 18:57:32 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: <838vvty9il.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 01 Apr 2011 21:58: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:45571 Archived-At: On 04/01/2011 01:57 PM, Eli Zaretskii wrote: > this just underlines the difficulty of reading the convoluted > arrangement that this patch introduces. Actually, the patch reduces the complexity of Emacs proper; it removes 58 lines and adds 39 lines. The patch's core is simple: a function emacs_readlink, whose body is two lines long, replaces duplicated code elsewhere in Emacs. There's nothing that hard about this. There is some indirection (which you're calling a "convoluted arrangement"), but that is normal when replacing inline code with a call to a parameterizable library. It's not rocket science. > this just underlines the difficulty of reading the convoluted > arrangement that this patch introduces I would think that only a quick and careless read of the code would lead one to believe that it calls malloc from Emacs without blocking interrupts. However, I wrote the code and perhaps am not the best to judge its clarity. A specific suggestion to make the code clearer (without introducing bugs or reducing flexibility) would be welcome. > Sorry, that doesn't answer the question. OK, then the answer is yes, I'm going to seriously consider the case of Emacs going bad when int or size_t or ssize_t overflows. This can occur when the underlying file system is corrupted and reports an incorrect file size. I've had this happen personally. In such cases Emacs should not crash. > There should be a good reason for introducing this There are at least four good reasons. The change simplifies Emacs's source code. It makes Emacs smaller and faster; for example, it typically reduces the number of system calls (on my RHEL 5.6 host a patched Emacs typically uses four fewer system calls to lock a file). The change improves the reliability of Emacs slightly, in unusual overflow cases. And the code is written and works.