Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2613255rwb; Mon, 3 Oct 2022 03:30:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4mUJX7NNQ/yVLlc5qPUP9vtNEmA1l53X6s/Qn1jDQ73UwxsYoh8TAmKeA6VxW0ZL6V3OWc X-Received: by 2002:aa7:9107:0:b0:553:92a4:d930 with SMTP id 7-20020aa79107000000b0055392a4d930mr21639085pfh.72.1664793039923; Mon, 03 Oct 2022 03:30:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664793039; cv=none; d=google.com; s=arc-20160816; b=a6LEjeWEqDerLP1LubsIPT1GWFf99v4DCBvrIJ0gZS7Cx2B1N/w495Qb4rF3tWODO7 TRWvR5kEKXM2zA6Ctfnu0MSaxMHUTL41GDiOne4tS4lWy+D9lh8nxS3EPIo2k1eiPX8b GUX1jcXawUXKBxeYo2lkF1fSOZOyZjUEqfPYxSpSx1LlpoG9rZKJXMfaQKqNcKRUc3iO M2ZZweX/w1+NMngFKUnDGCROUdAKHjUidfwZ5k+nLBktd5oykgHxdLOGCbvjdqGqgHdh 5cW2man5rBZ49xI0Q1erO6Ntr4dyYwV5Z6kDjndJiSoxoxoOQlEuNqlyAfLvSRTy6gF0 8XoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Wv9ZhLLWe2RnZLmyZs2ymak+/HrkxcPxA+jTtqEzZUI=; b=oOX0QQxxz66xeDjfq99emqTWkpQbTJVK1FokXTRU7uQjdFVIZHxjqtEyorWygIfZMK o0zMyEEA6910pKD3NRvKbCyLU1tw+Ie4VPTNoKC5WlJ9XVEg4uilPGTMZM2rE6ZiWygZ tTJ5bVUxTehVSJAIY2aRttUtirqIpDm/BjC9mSEC6OmXt+JnY6+DJWydiBmhmtOMsJZ9 5T5r0utrODspMAlHYS5eEQ6HH3uGo7afekmAtmJ8F/JgJ/HdyHIrsCSJA5MXCaI8Wdfr gWF135reRtBQLsUn18W93R4Jbj/RPxNJL+4k5Wgq3PLJe5CoCf1CtlOKc4vZIoQ0qoW3 i6iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QnUwUvQw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e19-20020a63f553000000b004398688a988si11241535pgk.382.2022.10.03.03.30.28; Mon, 03 Oct 2022 03:30:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QnUwUvQw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230374AbiJCJok (ORCPT + 99 others); Mon, 3 Oct 2022 05:44:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230055AbiJCJoL (ORCPT ); Mon, 3 Oct 2022 05:44:11 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 684F2F57; Mon, 3 Oct 2022 02:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664789987; x=1696325987; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=sXZaQocFXY9yjGwvBQtBsjXvYzr4OXfPV0g7Jm5zPAQ=; b=QnUwUvQwdhJwbNtfcUNKu7sI38OLk/HXIOhCpWgxUuCio2grX6KdcI5F Dx17ZFfD+jkLuMnMf5D1dcQy2cz/ctB4TJShHSjo5szLb+09aASSpnZIw 9+OkD8v8JVyXkpj7ZDo+x+RDxnK6ajSxMyzLtsH8ClPxeqWHCARgj9ub9 4ardnsR2dnD0Cv5j+pRKBIPTLNfhRosJHSE2N0S/46Fmm+8tZqaUIPDFe dmgyohKmPd04UFV3tys8e0AL1B3kv+GOn0BhW+HXuw+Vuqd01gGOdzb3s ueGw4sk8VSiyThU7rp0NCmCWKKLW7QSg6P7omsqmTNYODGcfnAfD6UcdI w==; X-IronPort-AV: E=McAfee;i="6500,9779,10488"; a="289754335" X-IronPort-AV: E=Sophos;i="5.93,365,1654585200"; d="scan'208";a="289754335" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.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 Cc: Matti Vaittinen , Lars-Peter Clausen , Michael Hennerich , Cosmin Tanislav , Jonathan Cameron , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Benson Leung , Guenter Roeck , Alexandru Ardelean , Nathan Chancellor , Miquel Raynal , Miaoqian Lin , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Paul Cercueil , Mihail Chindris , Gwendal Grignou , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev 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-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7ae09809-4f3c-9872-5a87-0a05e73d39b4@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 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: ... > > > > +??????????? attr[ARRAY_SIZE(iio_buffer_attrs) + i] = > > > > +??????????????? (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