From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DDDFC43461 for ; Thu, 17 Sep 2020 05:30:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC09B206A2 for ; Thu, 17 Sep 2020 05:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600320641; bh=UGaV4bPDAIQKtAtd9YR88RIFno2wkC9EtNA2IyAhL74=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=ObgDYAutLFYZvcrI8GevQsZr31pxgOnC1XeWV/FEMbJXfqJTrUTF53WH8oJ4tl/YM JEi1vL6Vpb9Fit3JqgVpI/mTuKaCK7Xh3CbwCMBJx7dXfj5tqUKTGC0PEB+bK8gfiM VcAzkRCxcuU8W7eAXRqKi4Abmt63yT7D+czT8iXI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726343AbgIQFak (ORCPT ); Thu, 17 Sep 2020 01:30:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:53190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbgIQFaa (ORCPT ); Thu, 17 Sep 2020 01:30:30 -0400 X-Greylist: delayed 386 seconds by postgrey-1.27 at vger.kernel.org; Thu, 17 Sep 2020 01:30:30 EDT Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7195820872; Thu, 17 Sep 2020 05:24:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600320244; bh=UGaV4bPDAIQKtAtd9YR88RIFno2wkC9EtNA2IyAhL74=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=w37CBUhxXjLcNTQwpYRXoCYtiOQ253HRAqe6sUGlOiirWNiUbjy4DYLDp6ooGfDHg wa6WYy86p/QMso1Ub0WrRyvKVvvgfuqF5MyDIlB7NW6ILpggMyUjDuNr6+cDJjQ1aH UDMqkdYvN02eDQ+Z2AcJer8uQYzc1jlKS0p4TKLs= Date: Thu, 17 Sep 2020 07:24:00 +0200 From: Greg KH To: Vinod Koul Cc: Srinivas Kandagatla , davem@davemloft.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] bitfield.h: annotate type_replace_bits functions with __must_check Message-ID: <20200917052400.GA44257@kroah.com> References: <20200916150333.11790-1-srinivas.kandagatla@linaro.org> <20200916152059.GA3018065@kroah.com> <66657ed6-b8ef-7e8d-b77c-9fd65453f53e@linaro.org> <20200917040459.GU2968@vkoul-mobl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200917040459.GU2968@vkoul-mobl> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 17, 2020 at 09:34:59AM +0530, Vinod Koul wrote: > On 16-09-20, 16:33, Srinivas Kandagatla wrote: > > > > > > On 16/09/2020 16:20, Greg KH wrote: > > > On Wed, Sep 16, 2020 at 04:03:33PM +0100, Srinivas Kandagatla wrote: > > > > usage of apis like u32_replace_bits() without actually catching the return > > > > value could hide problems without any warning! > > > > > > > > Found this with recent usage of this api in SoundWire! > > > > Having __must_check annotation would really catch this issues in future! > > > > > > > > Signed-off-by: Srinivas Kandagatla > > > > --- > > > > include/linux/bitfield.h | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h > > > > index 4e035aca6f7e..eb4f69253946 100644 > > > > --- a/include/linux/bitfield.h > > > > +++ b/include/linux/bitfield.h > > > > @@ -131,7 +131,7 @@ static __always_inline __##type type##_encode_bits(base v, base field) \ > > > > __field_overflow(); \ > > > > return to((v & field_mask(field)) * field_multiplier(field)); \ > > > > } \ > > > > -static __always_inline __##type type##_replace_bits(__##type old, \ > > > > +static __always_inline __must_check __##type type##_replace_bits(__##type old, \ > > > > base val, base field) \ > > > > { \ > > > > return (old & ~to(field)) | type##_encode_bits(val, field); \ > > > > -- > > > > 2.21.0 > > > > > > > > > > Don't add __must_check to things that if merged will instantly cause > > > build warnings to the system, that's just rude :( > > Currently there are not many users for this api, found only one instance in > > drivers/net/ipa/ipa_table.c which is also fixed with > > https://lkml.org/lkml/2020/9/10/1062 > > > > > > > > Fix up everything first, and then try to make this type of change. > > > > > > But why does this function have to be checked? > > As this function would return updated value, this check is more to with > > using the return value! > > > > It is easy for someone to ignore this return value assuming that the new > > value is already updated! So this check should help! > > > > TBH, This is what happened when we(vkoul and me) tried use this api :-) > > So the only user of this has been moved to *p_replace_bits(), looking > back I think we should remove *_replace_bits (no users atm) and > duplicate of *p_replace_bits(). If not adding this patch would be > sensible thing to do > > Somehow I feel former is a better idea ;-) Yes, please remove it if there is no users. thanks, greg k-h