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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8D7AC433FE for ; Mon, 3 Oct 2022 09:40:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hkltHgEmg7nxaYhbCPB75u0pQ7jt7kGZAbZNo0itYgc=; b=1GLQ0JYn5rIUcW XNuKzTYQ3gE6mIGOpmz9iNAmsdpRIYzqxKOUtBZCpu7cPNQMHq/IPJNabLY06reI+2LZ2zxRKjmRl g8ErjbvtkgiK5nai0xDpym1uicAf2rPUjxRV7dMPlNUlY7jmtiNEclJlOLIdg3pdK64QZffCSbTdY 8cR/3A1zU4m1LK1Fd6kmLeGvx3yQG6LCscBtVvZse6RMEjh4QRAt9uOKoLzUF1PHNbrc2br6KzLaX iEYIH27BJcCF1MsH1bmP5QApAZ2Jnq7JxlPNJ12SNLMI0zsVLAP3LUhdc4YMmMSqBFhi+M7u5NhfS q0hhiFKJvZUOicR/S+7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofHvM-005633-5A; Mon, 03 Oct 2022 09:39:44 +0000 Received: from mga18.intel.com ([134.134.136.126]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofHvJ-005616-Fx for linux-arm-kernel@lists.infradead.org; Mon, 03 Oct 2022 09:39:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664789981; x=1696325981; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=sXZaQocFXY9yjGwvBQtBsjXvYzr4OXfPV0g7Jm5zPAQ=; b=mgf59svrq7s7M+Tlh3xMblnCPwA3sLoyYCdutEK22omIXIY3SZ/S4ieQ L040wBSEgf0Xg/oOb9fmlmL5seJI3z92mhV3OabS6kEaDYWM4QIxm9mVj NvR1zRxP26Z7bVyUZUo+qDynzZFckiML/zbiUi/juATY8yCWw7sN06lTh p77YVC4n9zMOAPBQaGkW8lkCrjGPy2IdWeVIuBfTnO3HP69sRGg6XM0VF ji7a7PIF42LRd2yvqKEdUzPFFbA0lTyGwgf0kzrJZGImLpvU7gIOcsRUC JykYr6ISJOxMQynWkk+MBApQ47sx6DZpcKkPZp3u4TzG+Pvug2/lxE1Dp Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10488"; a="285725744" X-IronPort-AV: E=Sophos;i="5.93,365,1654585200"; d="scan'208";a="285725744" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2022 02:39:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10488"; a="727691643" X-IronPort-AV: E=Sophos;i="5.93,365,1654585200"; d="scan'208";a="727691643" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga002.fm.intel.com with ESMTP; 03 Oct 2022 02:39:32 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1ofHv8-001Rh9-19; Mon, 03 Oct 2022 12:39:30 +0300 Date: Mon, 3 Oct 2022 12:39:30 +0300 From: Andy Shevchenko To: Matti Vaittinen Subject: Re: [RFT PATCH v3 10/10] iio: Don't silently expect attribute types Message-ID: References: <63f54787a684eb1232f1c5d275a09c786987fe4a.1664782676.git.mazziesaccount@gmail.com> <7ae09809-4f3c-9872-5a87-0a05e73d39b4@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <7ae09809-4f3c-9872-5a87-0a05e73d39b4@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221003_023941_621221_10510179 X-CRM114-Status: GOOD ( 32.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , linux-iio@vger.kernel.org, Gwendal Grignou , linux-kernel@vger.kernel.org, Paul Cercueil , Miquel Raynal , Guenter Roeck , chrome-platform@lists.linux.dev, Lars-Peter Clausen , Miaoqian Lin , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Alexandru Ardelean , Mihail Chindris , Michael Hennerich , Cosmin Tanislav , Nathan Chancellor , Benson Leung , linux-arm-kernel@lists.infradead.org, Matti Vaittinen , Eugen Hristev , Claudiu Beznea , Jonathan Cameron Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Oct 03, 2022 at 12:02:56PM +0300, Matti Vaittinen wrote: > On 10/3/22 11:58, Matti Vaittinen wrote: > > On 10/3/22 11:43, Andy Shevchenko wrote: > > > On Mon, Oct 03, 2022 at 11:13:53AM +0300, Matti Vaittinen wrote: ... > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 attr[ARRAY_SIZE(iio_buffer_attrs= ) + i] =3D > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (struct attribute *)= &id_attr->dev_attr.attr; > > > = > > > ...and explicit casting here. Isn't attr is already of a struct > > > attribute? > > = > > I am glad you asked :) > > This is one of the "things" I was not really happy about. Here we hide > > the fact that our array is full of pointers to _const_ data. If we don't > > cast the compiler points this out. Old code did the same thing but it > > did this by just doing a memcpy for the pointers - which I personally > > consider even worse as it gets really easy to miss this. The cast at > > least hints there is something slightly "fishy" going on. > > = > > My "gut feeling" about the correct fix is we should check if some > > attributes in the array (stored to the struct here) actually need to be > > modified later (which I doubt). If I was keen on betting I'd bet we > > could switch the struct definition to also contain pointers to const > > attributes. I am afraid this would mean quite a few more changes to the > > function signatures (changing struct attribute * to const struct > > attribute *) here and there - and possibly also require some changes to > > drivers. Thus I didn't even look at that option in the scope of this > > fix. It should probably be a separate refactoring series. But yes - this > > cast should catch attention as it did. > > = > = > Actually, now that you pointed it out - do you think this would warrant a > FIXME comment? Makes sense to me, but I'm not a maintainer of IIO :-) -- = With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel