Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1197963ybp; Fri, 4 Oct 2019 10:55:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqynoIaCUQtfZlfhEFziVy7cQBiAb9Gs9UOBtuaDncQ24SME3+IMIgkGEuNA496J4ZxGgbuU X-Received: by 2002:a50:f60d:: with SMTP id c13mr16801537edn.279.1570211732453; Fri, 04 Oct 2019 10:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570211732; cv=none; d=google.com; s=arc-20160816; b=mVNrsBLZO/Pfw8QAZYQWkK+MW/UN+kVjve85G/1dJ7MK6nlD30Xv1hf8c0hFiJoiPG Y6xS+7UdJiWCnM+22eKuA9VM+cJWCAwKxEI1HEUtWzCWqKD+W05J8zvM/WpmL83F5PnT 7xKhgPCVlDSe3CImNNMbENs4htzvYu4oActKgvp7yDoUgNlFzV8IscU3fXRGaQSTGwua OEbTMvy/svufI3HZ0EE40mk/mkgAsLfwP1OjZaEz8Y1mL1oROjgOE0dXTdmXJZmRZ2Uo Xe3UV5ILAREeSTzdrwz9jbuyhqMFkCTddITDgew9veR8fW9WvwGIsfj+hq7Z3DrxdH4w dKFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=v+ot6MecpahXBy/XsNEnO0h9gE1GQDq0Bf9rTX+VY1c=; b=ysTeVly17kR65VFaXEGPhVeJJ+/DfUldKZ89Zg9Emi5gFX7cNt7lvARTR01b16M2BH ve/Pu3Ax3HxOgd2fL+URSWuwKXvJ3HX6B2A0EYQWFDrgvZS3Eeqpl98T8RQGDWRu9Omk pYs2ZUPuk5D7mnz/Wx4FaPrN3Np8ey40y/xvxqc5meCq3QWN6csNuM3VQF5ZmEJZNriF Vvgp/vjuJhb65FuD7qC7S4AZ2E5V9PiuxjyWf9vcVGSP0B4iMpNiAmL4ZJGSHfAhQAuR T1vKKjqE+fevjZSP5HScAteixfJG3J5wddeGjf1h/Uwsaa3QhJzjL1rGXA4npTLSRBT/ g6KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=RxD7rcL8; 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 g1si3308829ejo.82.2019.10.04.10.55.08; Fri, 04 Oct 2019 10:55:32 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=RxD7rcL8; 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 S2388272AbfJDRyB (ORCPT + 99 others); Fri, 4 Oct 2019 13:54:01 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:40456 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387900AbfJDRyB (ORCPT ); Fri, 4 Oct 2019 13:54:01 -0400 Received: by mail-lj1-f195.google.com with SMTP id 7so7372533ljw.7 for ; Fri, 04 Oct 2019 10:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v+ot6MecpahXBy/XsNEnO0h9gE1GQDq0Bf9rTX+VY1c=; b=RxD7rcL8Fr8GWZMypzp09r370bJefuZJwTltueP/8mQyT6b7pUuSEySIjw8cyI6MfK FAvUII414LI0hPJIa3T5wjJnf1JRW8oNT4ty5NpJmJlT5F4P4bqFNzjTGWWxb9O1t2Ts SF9Seg9ScG9kR+oW6CJlLSGxvzt7lFYAr4rdk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=v+ot6MecpahXBy/XsNEnO0h9gE1GQDq0Bf9rTX+VY1c=; b=RWhepwoqkKF+NA3lFFfQaB/8jv8U6aq8uhbPDQBA8bMWbDz2G2St1JuwQYoGplW0d2 t5c294HdMN1lfFEjJH5y2OfdA5RM15HEVLrkcdV1pBEptPAE5QdZl+RoJevDwf6L9Xl8 XoFKx0UpeMcYlRINvGIbUwaEtUk/HARk/gsa1hkTTdMMUVXdhuidLEHSBAm9lsOfuFjQ MP4PC55xfiDR02Zh5EEJDk64Dy+Pg/pyrUAkN/x/oHkkbJxQ1A1PnrCCfaghWWpAIeGQ 2kc8xFLCQR5j/YZvxKAasf+eniTNbuEzxjbcJiBLdfcE6aXK6WjNCeJ7Vfn0RH1gxEMz Bh8w== X-Gm-Message-State: APjAAAWWUxPAPGrQ34dUzGG0ebAxmLd2fni3NPfMG4vrk1rryj+vOKve Thq/UQ1T/ZJGwO62jkpt1H9A1Jpdryg= X-Received: by 2002:a2e:9a89:: with SMTP id p9mr10655023lji.131.1570211638780; Fri, 04 Oct 2019 10:53:58 -0700 (PDT) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com. [209.85.167.47]) by smtp.gmail.com with ESMTPSA id c6sm1253467lfh.65.2019.10.04.10.53.57 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Oct 2019 10:53:57 -0700 (PDT) Received: by mail-lf1-f47.google.com with SMTP id w67so5085327lff.4 for ; Fri, 04 Oct 2019 10:53:57 -0700 (PDT) X-Received: by 2002:a19:f204:: with SMTP id q4mr9574170lfh.29.1570211637449; Fri, 04 Oct 2019 10:53:57 -0700 (PDT) MIME-Version: 1.0 References: <20191004104116.20418-1-christian.brauner@ubuntu.com> In-Reply-To: <20191004104116.20418-1-christian.brauner@ubuntu.com> From: Linus Torvalds Date: Fri, 4 Oct 2019 10:53:41 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] usercopy structs for v5.4-rc2 To: Christian Brauner Cc: Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 4, 2019 at 3:42 AM Christian Brauner wrote: > > The only separate fix we we had to apply > was for a warning by clang when building the tests for using the result of > an assignment as a condition without parantheses. 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 if ((x = y)) is *wrong*. I know the compiler suggests that, but the compiler is just being stupid, and the suggestion comes from people who don't have any taste. If you want to test an assignment, you should just use if ((x = y) != 0) instead, at which point it's not syntactic noise mind-games any more, but the parenthesis actually make sense. However, you had no reason to use an assignment in the conditional in the first place. IOW, the code should have just been ret = test(umem_src == NULL, "kmalloc failed"); if (ret) ... instead. Which is a whole lot more legible. The alternative, of course, is to just ignore the return value of "test()" which is useless anyway (it's a boolean, not an error) and just write it as if (test(umem_src == NULL, "kmalloc failed")) goto out_free; and set ret to the error value ahead of time. Regardless, the double parentheses are _never_ the right answer. Ugly, broken, senseless syntax that is hard for humans to read, and doesn't make any sense even for computers when there's a perfectly regular alternative that isn't a random special case. I've pulled this, since it's not in core kernel code anyway, but I wish I had never had to see that ugly construct. Linus