From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] emacs-26 9bf66c6: Don't run FOR_EACH_FRAME when there's no frame left (Bug#29961) Date: Fri, 15 Dec 2017 09:13:19 -0800 Organization: UCLA Computer Science Department Message-ID: References: <20171215073120.7671.79446@vcs0.savannah.gnu.org> <20171215073122.52703204D3@vcs0.savannah.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------95B498E5385D2D03FD6A98ED" X-Trace: blaine.gmane.org 1513358212 1234 195.159.176.226 (15 Dec 2017 17:16:52 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 15 Dec 2017 17:16:52 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 Cc: Martin Rudalics To: Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 15 18:16:48 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ePtbL-0008Tb-Ky for ged-emacs-devel@m.gmane.org; Fri, 15 Dec 2017 18:16:47 +0100 Original-Received: from localhost ([::1]:47832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePtbS-0000Qj-Qh for ged-emacs-devel@m.gmane.org; Fri, 15 Dec 2017 12:16:54 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePtY6-0006FQ-K3 for emacs-devel@gnu.org; Fri, 15 Dec 2017 12:13:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePtY3-0002nV-CR for emacs-devel@gnu.org; Fri, 15 Dec 2017 12:13:26 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:49460) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePtY3-0002l1-2U for emacs-devel@gnu.org; Fri, 15 Dec 2017 12:13:23 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 55D8A16148E; Fri, 15 Dec 2017 09:13:21 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 6BvYUTlsDO71; Fri, 15 Dec 2017 09:13:20 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1AEFB161490; Fri, 15 Dec 2017 09:13:20 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Ll8qL1txT1KZ; Fri, 15 Dec 2017 09:13:20 -0800 (PST) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id F2F54160D0E; Fri, 15 Dec 2017 09:13:19 -0800 (PST) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221106 Archived-At: This is a multi-part message in MIME format. --------------95B498E5385D2D03FD6A98ED Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 12/15/2017 08:23 AM, Stefan Monnier wrote: > Is the problem caused by eassume (CONSP (Vframe_list))? > If so, maybe we should simply remove it. That's a good idea. However, some calls to FOR_EACH_FRAME do assume that frame-list is non-nil, while others don't. So when we remove the eassume from FOR_EACH_FRAME, we should add it to callers that have the assumption (otherwise --enable-gcc-warnings would sometimes rightly complain). I installed the attached. --------------95B498E5385D2D03FD6A98ED Content-Type: text/x-patch; name="0001-FOR_EACH_FRAME-no-longer-assumes-frame-list.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-FOR_EACH_FRAME-no-longer-assumes-frame-list.patch" >From 3716d4c5f02abbcc5bad5f0c884302687bcbbb7e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 15 Dec 2017 09:07:52 -0800 Subject: [PATCH] FOR_EACH_FRAME no longer assumes frame-list This cleans up a recent fix related to Bug#29661. Suggested by Stefan Monnier in: https://lists.gnu.org/r/emacs-devel/2017-12/msg00544.html * src/frame.c (next_frame, prev_frame, delete_frame): Restore debugging checks that Vframe_list is non-nil, as FOR_EACH_FRAME no longer has these checks. (delete_frame): Remove no-longer-needed checks that Vframe_list is non-nil, as FOR_EACH_FRAME no longer assumes that. * src/frame.h (FOR_EACH_FRAME): Do not assume Vframe_list is non-nil. --- src/frame.c | 13 ++++++++----- src/frame.h | 5 ++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/frame.c b/src/frame.c index 66d1b5c759..63fa8abb7d 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1607,6 +1607,8 @@ next_frame (Lisp_Object frame, Lisp_Object minibuf) Lisp_Object f, tail; int passed = 0; + eassume (CONSP (Vframe_list)); + while (passed < 2) FOR_EACH_FRAME (tail, f) { @@ -1629,6 +1631,8 @@ prev_frame (Lisp_Object frame, Lisp_Object minibuf) { Lisp_Object f, tail, prev = Qnil; + eassume (CONSP (Vframe_list)); + FOR_EACH_FRAME (tail, f) { if (EQ (frame, f) && !NILP (prev)) @@ -1914,6 +1918,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) if (f == sf) { Lisp_Object tail; + eassume (CONSP (Vframe_list)); /* Look for another visible frame on the same terminal. Do not call next_frame here because it may loop forever. @@ -2058,7 +2063,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) /* If we've deleted the last_nonminibuf_frame, then try to find another one. */ - if (f == last_nonminibuf_frame && !NILP (Vframe_list)) + if (f == last_nonminibuf_frame) { last_nonminibuf_frame = 0; @@ -2076,7 +2081,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) /* If there's no other frame on the same kboard, get out of single-kboard state if we're in it for this kboard. */ - if (kb != NULL && !NILP (Vframe_list)) + if (kb != NULL) { /* Some frame we found on the same kboard, or nil if there are none. */ Lisp_Object frame_on_same_kboard = Qnil; @@ -2093,9 +2098,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) /* If we've deleted this keyboard's default_minibuffer_frame, try to find another one. Prefer minibuffer-only frames, but also notice frames with other windows. */ - if (kb != NULL - && EQ (frame, KVAR (kb, Vdefault_minibuffer_frame)) - && !NILP (Vframe_list)) + if (kb != NULL && EQ (frame, KVAR (kb, Vdefault_minibuffer_frame))) { /* The last frame we saw with a minibuffer, minibuffer-only or not. */ Lisp_Object frame_with_minibuf = Qnil; diff --git a/src/frame.h b/src/frame.h index a3b7763643..a5d4e4fc88 100644 --- a/src/frame.h +++ b/src/frame.h @@ -1149,8 +1149,7 @@ default_pixels_per_inch_y (void) /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a `for' loop which iterates over the elements of Vframe_list. The loop will set FRAME_VAR, a Lisp_Object, to each frame in - Vframe_list in succession and execute the statement. Vframe_list - should be nonempty, so the body is executed at least once. LIST_VAR + Vframe_list in succession and execute the statement. LIST_VAR should be a Lisp_Object too; it is used to iterate through the Vframe_list. Note that this macro walks over child frames and the tooltip frame as well. @@ -1160,7 +1159,7 @@ default_pixels_per_inch_y (void) something which executes the statement once. */ #define FOR_EACH_FRAME(list_var, frame_var) \ - for ((list_var) = (eassume (CONSP (Vframe_list)), Vframe_list); \ + for ((list_var) = Vframe_list; \ (CONSP (list_var) \ && (frame_var = XCAR (list_var), true)); \ list_var = XCDR (list_var)) -- 2.14.3 --------------95B498E5385D2D03FD6A98ED--