Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2965459ybp; Sun, 6 Oct 2019 01:41:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZ+m8e8jUK5H2E0sXQoMS8V8aApZbr/NgqmGKrlLIbuY+GcbQi2ovm1lwF33OZ17d1c4qo X-Received: by 2002:a05:6402:3d2:: with SMTP id t18mr23097717edw.136.1570351302421; Sun, 06 Oct 2019 01:41:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570351302; cv=none; d=google.com; s=arc-20160816; b=LyoFFthcc8qJKZxRspWcVOOwFgkEBEyasgXoE1vxc7Q5bdywP3mscKnR0J4jJrjYAu RpxGCghZGCtP2ekY+N7W3afmGjM6FMvL395Q3mMc7IkD+1RdsCthV2J312b6/KUWYrq2 yDYsFsYr7t3zOeGEl1Ui27HZFu2fS1bQPtaBR7RQGEruwFpyEA3h1d+wdu8n3QypXKuK Jh7HPU7UKJQ8NQwzBp+Oeoo9uKK3RB4cf3xWFcuLZtEfj1oPeiGC0bvWPZOQ6GSKNUbn jNbXB83JVccwyPIteJDolPJHQNBm0N+dJf1iBidOTOku/upGDoIk02OVXKCGkuZKtv+D pGEg== 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; bh=F6MH4OUT0AWqLGfMhMUsapELpYnSN5Czm2cQyRh72zM=; b=dkEf9oM8e4xxD1k5yP+HN/GDSEyEraHgUfbucQNjpPnX03smkQdgD66v/vsFze5Zu5 xmr5SW0YSk+To9P6APtiBo/optfOYG/zAxWS9uQ74G63jXSbsYpZRRzTAAsP14AVOhx/ +czw3ffweO3ggNgHCSF5/6l1zL5bTC2Hyw6s6cXaFT4kCrpqydOFshWQGyIy6amEADA5 vvQyXFJxtrRFYTJ1HbH+C8/uKCb946UnblaPNhF4J6jJKWYIuC+v1BaZw4HXk084v5Ev VJo4hKkX/hqs2IeCidwgfWkni4i9M1/JzmfQC51x5Y+I6pWoOyheBMrwa4U83/+Ji7FR ciCg== ARC-Authentication-Results: i=1; mx.google.com; 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 k53si6979602edb.303.2019.10.06.01.41.18; Sun, 06 Oct 2019 01:41:42 -0700 (PDT) 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; 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 S1726291AbfJFIlH (ORCPT + 99 others); Sun, 6 Oct 2019 04:41:07 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:52221 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726207AbfJFIlH (ORCPT ); Sun, 6 Oct 2019 04:41:07 -0400 Received: from [213.220.153.21] (helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iH26C-0007lp-6Z; Sun, 06 Oct 2019 08:41:04 +0000 Date: Sun, 6 Oct 2019 10:41:03 +0200 From: Christian Brauner To: Aleksa Sarai Cc: Kees Cook , Nathan Chancellor , linux-kernel@vger.kernel.org Subject: Re: [PATCH] lib: test_user_copy: style cleanup Message-ID: <20191006084102.mhqrsyg5slbfwejd@wittgenstein> References: <20191005233028.18566-1-cyphar@cyphar.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191005233028.18566-1-cyphar@cyphar.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 06, 2019 at 10:30:28AM +1100, Aleksa Sarai wrote: > While writing the tests for copy_struct_from_user(), I used a construct > that Linus doesn't appear to be too fond of: > > On 2019-10-04, Linus Torvalds wrote: > > Hmm. That code is ugly, both before and after the fix. > > > > This just doesn't make sense for so many reasons: > > > > if ((ret |= test(umem_src == NULL, "kmalloc failed"))) > > > > where the insanity comes from > > > > - why "|=" when you know that "ret" was zero before (and it had to > > be, for the test to make sense) > > > > - why do this as a single line anyway? > > > > - don't do the stupid "double parenthesis" to hide a warning. Make it > > use an actual comparison if you add a layer of parentheses. > > So instead, use a bog-standard check that isn't nearly as ugly. > > Fixes: 341115822f88 ("usercopy: Add parentheses around assignment in test_copy_struct_from_user") > Fixes: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper") > Signed-off-by: Aleksa Sarai Fwiw, I think the commit message doesn't necessarily need to mention stylistic preferences nor a specific mail. It's sufficient enough to say that the new way makes things way more obvious. But ok. :) I'll pick this up now. Reviewed-by: Christian Brauner