Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1133409imu; Wed, 23 Jan 2019 11:18:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Md8t4mc3peHDwMD6AlVBRCUe+r/xTVReCcNucyFEiK8HM2x3Ehm602GGLz6dlH6LpWJn2 X-Received: by 2002:a17:902:7b91:: with SMTP id w17mr3493966pll.111.1548271114536; Wed, 23 Jan 2019 11:18:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548271114; cv=none; d=google.com; s=arc-20160816; b=Rqo7cQ2qVez2RznSpCoXidXFy39hmO5ULBtAE3x60ia/w0He3BSt2P1E6kEUOE9pdD aHfUUYYnwX6Q0P77TXvHk7OjrdMLFvgcvf07vskjjjPvxkxOaDzK/FpkTPS8vqd04u6H MjeMheUv17UFOF4UTPqAQZEJ4k1KcadxhqhAycj+lDOznCynQN2XK8bflXQH3C0BaaL5 9FJsrTkwyb1ktjb5wZj8hDAxXFYGs4fXHbZ13XQDNBBzaA+0ekRPFcXb9tbRALn2PGWT 3j3PsP+fekhmkoL+obg/lkSjY7g9/6Ac1rqk3J2fb0Xao2yjKU8kmebaD3c5pXfECKSu k7VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9TxsPBM3jjXfVOkRBw/Td/M3gJ46TOrrJlMH4ZHJ0Lc=; b=ZndUgtkIIQiW68YjZH72oNSXOV+XlbRK5qN7jbZ54LZdrM5FTXSL5sguZcfTgi18kB P5gYF0Qr2SUAGXZjxOqYEoUJhSWXpYVlvZNwqiP21o53ctG+zPV2PNeWf5vsUOCgPsbc SSfcsdoBjKDlPvfwzja4q3eaRXdnx7jZYMl8yJ9e3Kwy+NumiejQC3hslMgeGLgCaz2x nT+E0x2dIfMNOo6WcrIDmzMqhoKPtJ9PcXS3/QUBjV/vmjEqOiBCpkWdC9T8LEYWi17D lBLOXLZheNlZJpxua8bein9nrKQfwWm4stnkYaUdihwfNQ7HIrFHyKLcGNbTi0zW99XF wOAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=P1Evooh0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z123si14506191pfb.104.2019.01.23.11.18.18; Wed, 23 Jan 2019 11:18:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=P1Evooh0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726523AbfAWTSF (ORCPT + 99 others); Wed, 23 Jan 2019 14:18:05 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:42446 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725896AbfAWTSF (ORCPT ); Wed, 23 Jan 2019 14:18:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9TxsPBM3jjXfVOkRBw/Td/M3gJ46TOrrJlMH4ZHJ0Lc=; b=P1Evooh0cZ31Vg3yJPMvCI5MF CC4YBr/I1nCsU/rqUkDI1fV8Fvg4YGT43qI7wCHMpuOgMf5qtqld9gwF6JfYnCnFyVXQIJBqZqxKf +bXh52Xuy8K9WkZlAHjLkFnoR0xSu90bX6HTDIw0irhqObr4H6eqbtd9kXiAye23pHVJO/RKrVfJm wNphHaylDyKMeEoKt11LT9KvYUcIlkJ+556RxfH9Qpm4xmKK7vzyStJCyhZGt5UbGBf76tLO7MXgw ofEKY62IMmhGnvY/zNmeOv+oxFFrJlpF+/pDa+gmT7EiT+uBtsSwuxI3eWvobtIa9Y2+jQCIFGt9g vqukkVMFw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gmO2E-0001t7-R4; Wed, 23 Jan 2019 19:18:02 +0000 Date: Wed, 23 Jan 2019 11:18:02 -0800 From: Matthew Wilcox To: Jani Nikula Cc: Greg KH , Kees Cook , dev@openvswitch.org, Ard Biesheuvel , netdev@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, kernel-hardening@lists.openwall.com, intel-wired-lan@lists.osuosl.org, linux-fsdevel@vger.kernel.org, xen-devel@lists.xenproject.org, Laura Abbott , linux-kbuild@vger.kernel.org, Alexander Popov Subject: Re: [Intel-gfx] [PATCH 1/3] treewide: Lift switch variables out of switches Message-ID: <20190123191802.GB15311@bombadil.infradead.org> References: <20190123110349.35882-1-keescook@chromium.org> <20190123110349.35882-2-keescook@chromium.org> <20190123115829.GA31385@kroah.com> <874l9z31c5.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <874l9z31c5.fsf@intel.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 23, 2019 at 04:17:30PM +0200, Jani Nikula wrote: > Can't have: > > switch (i) { > int j; > case 0: > /* ... */ > } > > because it can't be turned into: > > switch (i) { > int j = 0; /* not valid C */ > case 0: > /* ... */ > } > > but can have e.g.: > > switch (i) { > case 0: > { > int j = 0; > /* ... */ > } > } > > I think Kees' approach of moving such variable declarations to the > enclosing block scope is better than adding another nesting block. Another nesting level would be bad, but I think this is OK: switch (i) { case 0: { int j = 0; /* ... */ } case 1: { void *p = q; /* ... */ } } I can imagine Kees' patch might have a bad effect on stack consumption, unless GCC can be relied on to be smart enough to notice the non-overlapping liveness of the vriables and use the same stack slots for both.