Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp343191rdb; Thu, 5 Oct 2023 07:35:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGO7JcNSpX3RgOo0psrhtTsHOSxXJuVrdSW3XddaZZt7g+oOuXVdxiBYn1FVHa7z3Z1qBBj X-Received: by 2002:a17:902:ec91:b0:1bf:1367:b7fb with SMTP id x17-20020a170902ec9100b001bf1367b7fbmr6606889plg.46.1696516503360; Thu, 05 Oct 2023 07:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696516503; cv=none; d=google.com; s=arc-20160816; b=MMvfL3bxKBfAH84mpwvWu/Px8CWh2FN0x+RO0qeqv8Q5ymjJ6Hbgg9yUJIs+4dQgLy I2f3me2sbYJL9QYsJXqx44w8g6D225n9P1FbsZQnfyrwJdFSxk9J+npvCvEHZX1SWH4m tKmtXq+p4/HBqvRAXugM6aQ43zs5nCYum5BbW5qNyw4tqd3dWyXKA9M3OMPURcWvDwWb LNdXtJEV82d8C9gwv5uOJaUfwHuAkBN8JVimZ2WJOh35YlkGuSm6EdWkeePCuGKGncXX ckqY+vCISO6H4xskBhVLB8Fd9xOFsS/WN8B7bOUA3l7DsAbwWWk9dS0aL35ImCaOG3+G SsZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:message-id:in-reply-to:subject:cc:to:from :date; bh=YWLYReLiagLMH/Y5qXoLkoOMbHOOt9xrXxRHMyRNPlU=; fh=lediKfS2YksK6lAt+WwphMzb0t3pAZk3xwVeI53YcUY=; b=eB5n3CvmXoiySDnX9cr8y/UGnSoBx+iCIKVZF76EC8tVCd1J5AGdjASUaQ2rhTfW0V dHGH2BpsZk1SQTvaepj1TJztZBCdRuSx+nhiGUXhALPT+1VER8b24tWZdtcosmxcpT/3 CIWGCADsdJqk+gcz/W5h13FzCEL1IK2KeIydc6KHLrnACIQmeow5fChh13Z196INuQe5 sdRxTbfg8tSXUsFcmwZsoGbCu5+a243+EOV/VRljEPF2fGb4apCqBsw4m8uQkERJdDmg mNYBsgG7po6DkoRICF5yFSmGCZtHWBY93QI4rnyO7d9mfHTOswPto/JSFMo2f39A3q4s LoiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id d18-20020a170903231200b001bbac6722e6si1723706plh.371.2023.10.05.07.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:35:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2D2A78028230; Thu, 5 Oct 2023 07:35:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234011AbjJEOex (ORCPT + 99 others); Thu, 5 Oct 2023 10:34:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235115AbjJEOdL (ORCPT ); Thu, 5 Oct 2023 10:33:11 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C342261B4; Thu, 5 Oct 2023 05:24:16 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 6F01992009C; Thu, 5 Oct 2023 14:24:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 6B00692009B; Thu, 5 Oct 2023 13:24:12 +0100 (BST) Date: Thu, 5 Oct 2023 13:24:12 +0100 (BST) From: "Maciej W. Rozycki" To: Dan Carpenter cc: Su Hui , Greg Kroah-Hartman , rafael@kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] driver base: slience unused warning In-Reply-To: Message-ID: References: <45027fa0-cda5-2a80-f1cd-ed805d2717ee@nfschina.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:35:02 -0700 (PDT) On Wed, 4 Oct 2023, Dan Carpenter wrote: > > > This variable is been used but never be read, so gcc and W=1 give such > > > warning. > > > > > > drivers/base/module.c:36:6: error: > > > variable ‘no_warn’ set but not used [-Werror=unused-but-set-variable] > > > > > > I wanted to use "__maybe_unused" to avoid  this warning. > > > > > > However it seems like a wrong using of "__maybe_unused" as Greg KH said: > > > > > > "But no_warn is being used in this file, it's being set but not read > > > which is ok. That's a real use, so this change really isn't correct, > > > sorry." > > > > The warning itself is a real issue to be sorted though. Is this a use > > case for `#pragma GCC diagnostic'? > > I thought Greg liked using __maybe_unused in this case? This is > drivers/base. Do the rest of us even get a vote? ;) > > If I do have a vote then #pragma is always the worst option. Linus has > taught me to dislike pragmas a lot. I'm not a great supporter of this solution, but at least it's guaranteed to work by definition. Otherwise we could try to outsmart the compiler; perhaps: (no_warn = sysfs_create_link(&drv->p->kobj, &mk->kobj, "module")), no_warn; would work. At the end of the day it's us who told the compiler to warn if the result of `sysfs_create_link' is unused with all the consequences. And while assigning to `no_warn' technically fulfils the requirement, the variable itself isn't used beyond being assigned to, which the compiler rightfully complains about because we asked for it. It's up to us really to tell the compiler what we want it to complain about and what we do not. Maciej