Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp64514ybp; Thu, 3 Oct 2019 10:13:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4w7MtI5uRf7LHjzLTCjWeaLfR+qhwR4TmsTbAc7E+jWpdWX+EeYuaNBx2xvFKKwTlTOJT X-Received: by 2002:a17:907:205b:: with SMTP id pg27mr8645517ejb.135.1570122814919; Thu, 03 Oct 2019 10:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570122814; cv=none; d=google.com; s=arc-20160816; b=dTLiaZvH+EXeYFdJeJHczeNVo2OstGcbKttDsjg/LQ8Wq/NalIWDsVvvRePNZfDFzF JA8VOUUV6e/uM78ch797hgDspG90HVDXJyjZ3K4wVpBtssxaeVRjyNJyzf0EE3XVnUI/ uSkUigDWe4m3mU2Rk43EqbXNVHLqcz6/PIDdCKuiDq9cGokQ9HZYI0hVdL1vBPZqHwOh 0Sn5rZd45MccVYL41afk9vqH+Pznc98+e7Xl2TWP8FPD6zCBT/3RMtU5nrfpCyBPGoWu ohOKkAmXIpFKZspuA3R/JrLt1I1fdFkHCs/+L6K8kOP64FJ295kICy0ll89qTkSUi+Or yadA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=hR9NNmOdT5rcLSqoSR1KORhykwTT8D7K6IAvdiYy3eY=; b=hlZFSr6miMeXrXsI9dY8fA7x7zcycgy2EQr8qx6ig9L1GNi/fANF7rKDHdZLDgygW0 0QUr6f5txwp0FSDZwdn52Dt63Fzc5JfksSIefyv3aOZp1z8gS0YUFxwAjKGZmRV6Z0LA oydWLM/ftnymrGQF9A7saNLpW2+ZFGOGQFWiIuE0d7icLQphkM6L2zMmi8jLiOC4jg5b zPEG8LELPKl/vnF5Fhw34tq3cW6Zz59COgABBSesnngbWX6lyZK4l9OHlh3KV1mdoVou ez2OhLfRsnG0E84VesCkLwojD0gDmjt20pCGWj0Y9WUi6a1VXOhmM1c7HxzZmSNmytqG O3kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QOYnNsDv; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z55si1941352edz.254.2019.10.03.10.13.10; Thu, 03 Oct 2019 10:13:34 -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=@gmail.com header.s=20161025 header.b=QOYnNsDv; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390199AbfJCRLm (ORCPT + 99 others); Thu, 3 Oct 2019 13:11:42 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:55608 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391824AbfJCRLl (ORCPT ); Thu, 3 Oct 2019 13:11:41 -0400 Received: by mail-wm1-f66.google.com with SMTP id a6so2807158wma.5 for ; Thu, 03 Oct 2019 10:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hR9NNmOdT5rcLSqoSR1KORhykwTT8D7K6IAvdiYy3eY=; b=QOYnNsDv1gwHX85of27SNOuKONUoPfvQQVqfYJXpU7xrtANp1JXm7xGADM1k3Rj39Y wuEN2+2O2C9I9LdjX2F7mBAyEVCIGHm6Al93ev4WyxORN1ftWok0/BHnDXFQHll7PeQW 57RmpTRhynLJQ9lNlZqwsMBzCsQL7Dso5s0kzp+ULgpB/k/lAjcIpucQqATRQsIMfQ1c WHEhHVw1Dovos6057W/7VftABpYCbqQ50TSG+rOZX/hcpDK9MxdR7TnnNkpx0YCi9R8e Ck6HmcUhdjcqQ95uUvLZ+QT3T130Wdr9O4GRiGvKgxzTWZI1fQMlVMsjwipZV4n1BE2Z 1Zwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hR9NNmOdT5rcLSqoSR1KORhykwTT8D7K6IAvdiYy3eY=; b=hbeu3EXutnBy8QFLZc64kTw6FAkDkRTdp0b+NocAKy5TyuT/VsrA1T1dfTNoTIeJOg 81oiZJdKiXtqoLMkwOQlV1Q9M+qeBfBCSk/1E5ZZXJViMsI24vS16iwV2R8clfksCEHp 3Kba+8br7FdgjRrFt+Ay5s04vPlyWlzUG+Uxk6i61wLJ0YfWB2UwinjAIwnbax84KJbx q1f0F385KuP1qVkqPZLlh3ekz0GfhulkIo9wgCMffINuR4Hkp48yOeMSfuFNO7xgyVGO mrJKQcwV3WOJS5WIc2T/elhTVVDoH/itIRLtaRu7gdwl7gvAl3t7v39ADmt2q6bhDrLz 4jQA== X-Gm-Message-State: APjAAAVvER+esBZcLZv/MEHqzdFpNXRPmkyoqDqFa5ENyg7+/5n44b5D iZPECYOVCeAJ00UKBZEkCz4= X-Received: by 2002:a05:600c:2057:: with SMTP id p23mr7495542wmg.17.1570122699103; Thu, 03 Oct 2019 10:11:39 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f8:222:2f1b::2]) by smtp.gmail.com with ESMTPSA id j1sm7067386wrg.24.2019.10.03.10.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2019 10:11:38 -0700 (PDT) From: Nathan Chancellor To: Christian Brauner , Aleksa Sarai Cc: Kees Cook , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH] usercopy: Add parentheses around assignment in test_copy_struct_from_user Date: Thu, 3 Oct 2019 10:11:21 -0700 Message-Id: <20191003171121.2723619-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clang warns: lib/test_user_copy.c:96:10: warning: using the result of an assignment as a condition without parentheses [-Wparentheses] if (ret |= test(umem_src == NULL, "kmalloc failed")) ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/test_user_copy.c:96:10: note: place parentheses around the assignment to silence this warning if (ret |= test(umem_src == NULL, "kmalloc failed")) ^ ( ) lib/test_user_copy.c:96:10: note: use '!=' to turn this compound assignment into an inequality comparison if (ret |= test(umem_src == NULL, "kmalloc failed")) ^~ != Add the parentheses as it suggests because this is intentional. Fixes: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper") Link: https://github.com/ClangBuiltLinux/linux/issues/731 Signed-off-by: Nathan Chancellor --- lib/test_user_copy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/test_user_copy.c b/lib/test_user_copy.c index 950ee88cd6ac..e365ace06538 100644 --- a/lib/test_user_copy.c +++ b/lib/test_user_copy.c @@ -93,11 +93,11 @@ static int test_copy_struct_from_user(char *kmem, char __user *umem, size_t ksize, usize; umem_src = kmalloc(size, GFP_KERNEL); - if (ret |= test(umem_src == NULL, "kmalloc failed")) + if ((ret |= test(umem_src == NULL, "kmalloc failed"))) goto out_free; expected = kmalloc(size, GFP_KERNEL); - if (ret |= test(expected == NULL, "kmalloc failed")) + if ((ret |= test(expected == NULL, "kmalloc failed"))) goto out_free; /* Fill umem with a fixed byte pattern. */ -- 2.23.0