From patchwork Wed Jul 3 08:10:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 168391 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp555825ilk; Wed, 3 Jul 2019 01:11:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGaBObQbj/lp44/usb1jzBfD7a9DjHMkHgx56/BHQF71a/N8/SBavHcZmuy1SylqQ+QDdY X-Received: by 2002:a63:fd50:: with SMTP id m16mr26007366pgj.192.1562141499114; Wed, 03 Jul 2019 01:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562141499; cv=none; d=google.com; s=arc-20160816; b=HXss73ja9TfY4vUNZKUbsuE4Z21qoXkmurgElWRjBKNz5/9LUTYIZQiAIiwh3iNRyx XIUboEXUHS5n6itZbNrhFNVC282uUpqrCh92Xd7LWHaQmn9zEbGO2Zk/jHLk/Dy11//h DXXPM7L2sEnYmltxxjAnt2SxiEpeFNWNZkRc2GL14ubJFa5e22wbntI7ntnkYPupZ4oB RyQDjCfrZEBbgLboS1oBR3xDm2sY4jGSm5vLJBq+g69rvgB3w+7t5+2W2kmrATHQoQBR OlMXO0o175S7YhYh7Tg7sJQJOGziCSRkrKjWHU/qjaxXQgChGTNVYit7Zba8y2KDvA2p Vq/Q== 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; bh=IZbXqjobTC2DFjqqu1+6m8eLN9s7MTM8EC2xeZieNT4=; b=sXi2R0t6fGphdzy0bb76GvuDbIAs4JkpeOBL7V31SC4LsDiFBwXPDCN97jn+dG1llQ svdMTJKwKUCm8pEapXy7juDI4Q6nNwinGpkHeYB4ZYh13bcvtdCxs2lhloUCH3TwUH0u kxa3SE/KjHCW5HqP7DLb+Dr0KLDBfWdkW8y2XUXgG5v7KlczWUn3R1s4YlbA+DQbtuTe fELm9/Dn4xkNUVzFbc6WTxVD4Q2z81xGiDvIIa6MHUh6noYjEHSOULwoH6oCVKDrgDjx +inHlEFMfaKp3FpaL2PYaQR5S7KDItDRpndtZDGSIe643jRenjOYRKbVPb9jfB/W1NHw h2lw== 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 q14si1607139pgq.588.2019.07.03.01.11.38; Wed, 03 Jul 2019 01:11:39 -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 S1727231AbfGCILh (ORCPT + 30 others); Wed, 3 Jul 2019 04:11:37 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:45825 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727046AbfGCILg (ORCPT ); Wed, 3 Jul 2019 04:11:36 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MzR0i-1iV4Li0jo0-00vQf3; Wed, 03 Jul 2019 10:11:22 +0200 From: Arnd Bergmann To: Ingo Molnar , Peter Zijlstra Cc: Arnd Bergmann , Andrew Morton , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH] waitqueue: fix clang -Wuninitialized warnings Date: Wed, 3 Jul 2019 10:10:55 +0200 Message-Id: <20190703081119.209976-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:K19QOQm10YrblmzdHMiiEdH0R3Hfi5j9kdim9yq0TZ8m68yPfrf zc4ljV6rZgbNb0id7kRgg3RD20cRcEG//g7uqbs/KebGMidFMqq4jpSBc7lulwdbYZK8FZ+ FGKhfX+OXwLKujaqMZwBzT3c1AaiU36nhDgSmMjfktF7JFW5grp9SL7zyClIEFJSIaHk5In NOKG2LRGrVD0S07O22/CA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Mv1pXsjnFJI=:isvJAEUZheIz0k5bW5GLiZ RSjRwvdDkT3jk+TYdx8ttPYbD9rpOdHn9CN1Ekg90GpdroDrASnYRm7aCSudGdYmo/srOL++3 ZlqC3aLqLO8BXorw1OE5ctCXoJzqkIzOi9omfeH8LEU8E2p2yjYhohhneLsSoTOXRmDh2rgIN JbVGvC4fFij2ZgYamHCNskRrVwbPIVH+MWAjJ+o3akXxXOQVvIzX2w168TkYeQy48EV0fvNZp Aw/vw7zs6fdMdL1RLk4NrTrq08Kw0tAbt8IS6oSCn4gPte1GaTPyhYUTh0vHtBumj3jBA68PN PklWJBz2fps63FcUzLJGUD+OHKdaSyz2MED9ADVke5xuzvr/Uj5gM12PiCjg4RtgbmE2mQVmj 462A55diQqaSPrQPgyMB/SoFVssmCbtiIWlUiPXv8Nx0Dqx8yLs0XIpw7VqRuRkVoeoZQkaFe eBQmzHp+KYRSFtWgOl/waPSyXnWyn/iKCj6Gmsi7EHVwwimOJImbYHx4dtV/6YynkbBco/uUt ucUQU4YxCmKw36vikqD9wCT09E1TAI9mPr9TvXj/FvflQobgzIY4+Sex74PpJhu7L8Q+h4sll 2xbzvdyR7yGz0CiKAY2jdwM/Yt2D2bP7N0zXJSWFeDa1G+jmhNMEItjKwPGU2F+EA6o8afvuw l0RF6z4eW186Ccsp4k+QrvdY37BC9ddZTHPKgW44b60IOZt9PDvlAsJKqLFjQkmyo6zXKIHCj oXVUJkyaADFe/4PHiW8PX1DN09EPmwv7Zr/vjg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When CONFIG_LOCKDEP is set, every use of DECLARE_WAIT_QUEUE_HEAD_ONSTACK() produces an annoying warning from clang, which is particularly annoying for allmodconfig builds: fs/namei.c:1646:34: error: variable 'wq' is uninitialized when used within its own initialization [-Werror,-Wuninitialized] DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); ^~ include/linux/wait.h:74:63: note: expanded from macro 'DECLARE_WAIT_QUEUE_HEAD_ONSTACK' struct wait_queue_head name = __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) ~~~~ ^~~~ include/linux/wait.h:72:33: note: expanded from macro '__WAIT_QUEUE_HEAD_INIT_ONSTACK' ({ init_waitqueue_head(&name); name; }) ^~~~ After playing with it for a while, I have found a way to rephrase the macro in a way that should work well with both gcc and clang and not produce this warning. The open-coded __WAIT_QUEUE_HEAD_INIT_ONSTACK is a little more verbose than the original version by Peter Zijlstra, but avoids the gcc-ism that suppresses warnings when assigning a variable to itself. Cc: Peter Zijlstra Signed-off-by: Arnd Bergmann --- include/linux/wait.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 2.20.0 Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor diff --git a/include/linux/wait.h b/include/linux/wait.h index ddb959641709..84e39643b780 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -68,8 +68,15 @@ extern void __init_waitqueue_head(struct wait_queue_head *wq_head, const char *n } while (0) #ifdef CONFIG_LOCKDEP -# define __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) \ - ({ init_waitqueue_head(&name); name; }) +# define __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) { \ + .lock = __SPIN_LOCK_UNLOCKED(name.lock), \ + .head = ({ \ + static struct lock_class_key __key; \ + lockdep_set_class_and_name(&(name).lock, &__key, # name); \ + (struct list_head){ &(name).head, &(name).head }; \ + }), \ +} + # define DECLARE_WAIT_QUEUE_HEAD_ONSTACK(name) \ struct wait_queue_head name = __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) #else