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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 6E6CBC433E2 for ; Thu, 17 Sep 2020 12:39:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3219C2087D for ; Thu, 17 Sep 2020 12:39:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726864AbgIQMjw (ORCPT ); Thu, 17 Sep 2020 08:39:52 -0400 Received: from mga12.intel.com ([192.55.52.136]:17406 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbgIQMgH (ORCPT ); Thu, 17 Sep 2020 08:36:07 -0400 X-Greylist: delayed 501 seconds by postgrey-1.27 at vger.kernel.org; Thu, 17 Sep 2020 08:35:56 EDT IronPort-SDR: fd79BEHzpQKWVRy46I/7xhpDdyTgT5OGwJGtXBSiHszomggQzvHZLQybBGDqZKdWAOpB8zwKzw w8dTuZWx4O4A== X-IronPort-AV: E=McAfee;i="6000,8403,9746"; a="139188102" X-IronPort-AV: E=Sophos;i="5.76,436,1592895600"; d="scan'208";a="139188102" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2020 05:25:37 -0700 IronPort-SDR: jMwGTc1ljHPuFBxuAjHrcoVSsWcREA7H6qljjXAyITclEhlpWZmxmCgo2Qt68QLHzh5nWtxjLw hwXWkcDrbg+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,436,1592895600"; d="scan'208";a="336395898" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga008.jf.intel.com with ESMTP; 17 Sep 2020 05:25:33 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1kIsyf-00HK03-ST; Thu, 17 Sep 2020 15:25:29 +0300 Date: Thu, 17 Sep 2020 15:25:29 +0300 From: Andy Shevchenko To: Dan Carpenter Cc: Sakari Ailus , Daniel Scally , devel@driverdev.osuosl.org, robh@kernel.org, jorhand@linux.microsoft.com, linux-media@vger.kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, kieran.bingham@ideasonboard.com, kitakar@gmail.com, bingbu.cao@intel.com, mchehab@kernel.org, davem@davemloft.net, tian.shu.qiu@intel.com, yong.zhi@intel.com Subject: Re: [RFC PATCH] Add bridge driver to connect sensors to CIO2 device via software nodes on ACPI platforms Message-ID: <20200917122529.GJ3956970@smile.fi.intel.com> References: <20200916213618.8003-1-djrscally@gmail.com> <20200917103343.GW26842@paasikivi.fi.intel.com> <20200917104941.GP4282@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200917104941.GP4282@kadam> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 17, 2020 at 01:49:41PM +0300, Dan Carpenter wrote: > On Thu, Sep 17, 2020 at 01:33:43PM +0300, Sakari Ailus wrote: > > > + int i, ret; > > > > unsigned int i > > > > Why? > > For list iterators then "int i;" is best... For sizes then unsigned is > sometimes best. Or if it's part of the hardware spec or network spec > unsigned is best. Otherwise unsigned variables cause a ton of bugs. > They're not as intuitive as signed variables. Imagine if there is an > error in this loop and you want to unwind. With a signed variable you > can do: > > while (--i >= 0) > cleanup(&bridge.sensors[i]); Ha-ha. It's actually a counter argument to your stuff because above is the same as while (i--) cleanup(&bridge.sensors[i]); with pretty much unsigned int i. > There are very few times where raising the type maximum from 2 billion > to 4 billion fixes anything. -- With Best Regards, Andy Shevchenko 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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 B4992C43461 for ; Thu, 17 Sep 2020 12:25:44 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 35EF7206A1 for ; Thu, 17 Sep 2020 12:25:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35EF7206A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id D115A875BF; Thu, 17 Sep 2020 12:25:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NaCZjBGXTUaA; Thu, 17 Sep 2020 12:25:43 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 51AA3875A9; Thu, 17 Sep 2020 12:25:43 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 394641BF381 for ; Thu, 17 Sep 2020 12:25:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 26727275A6 for ; Thu, 17 Sep 2020 12:25:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NlwyMAh23T29 for ; Thu, 17 Sep 2020 12:25:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by silver.osuosl.org (Postfix) with ESMTPS id 2EFA120512 for ; Thu, 17 Sep 2020 12:25:41 +0000 (UTC) IronPort-SDR: VI6iYJ8h3gcDly8MfQABMeH3t7fOrxKyE2biu7Ie6kcLwefDwZ9PqKUZcyP0xHPPkL9FTq/XEK TuGG3fGxQe7g== X-IronPort-AV: E=McAfee;i="6000,8403,9746"; a="157087498" X-IronPort-AV: E=Sophos;i="5.76,436,1592895600"; d="scan'208";a="157087498" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2020 05:25:37 -0700 IronPort-SDR: jMwGTc1ljHPuFBxuAjHrcoVSsWcREA7H6qljjXAyITclEhlpWZmxmCgo2Qt68QLHzh5nWtxjLw hwXWkcDrbg+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,436,1592895600"; d="scan'208";a="336395898" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga008.jf.intel.com with ESMTP; 17 Sep 2020 05:25:33 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1kIsyf-00HK03-ST; Thu, 17 Sep 2020 15:25:29 +0300 Date: Thu, 17 Sep 2020 15:25:29 +0300 From: Andy Shevchenko To: Dan Carpenter Subject: Re: [RFC PATCH] Add bridge driver to connect sensors to CIO2 device via software nodes on ACPI platforms Message-ID: <20200917122529.GJ3956970@smile.fi.intel.com> References: <20200916213618.8003-1-djrscally@gmail.com> <20200917103343.GW26842@paasikivi.fi.intel.com> <20200917104941.GP4282@kadam> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200917104941.GP4282@kadam> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, robh@kernel.org, mchehab@kernel.org, jorhand@linux.microsoft.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, kieran.bingham@ideasonboard.com, Daniel Scally , yong.zhi@intel.com, Sakari Ailus , bingbu.cao@intel.com, kitakar@gmail.com, davem@davemloft.net, tian.shu.qiu@intel.com, linux-media@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" On Thu, Sep 17, 2020 at 01:49:41PM +0300, Dan Carpenter wrote: > On Thu, Sep 17, 2020 at 01:33:43PM +0300, Sakari Ailus wrote: > > > + int i, ret; > > > > unsigned int i > > > > Why? > > For list iterators then "int i;" is best... For sizes then unsigned is > sometimes best. Or if it's part of the hardware spec or network spec > unsigned is best. Otherwise unsigned variables cause a ton of bugs. > They're not as intuitive as signed variables. Imagine if there is an > error in this loop and you want to unwind. With a signed variable you > can do: > > while (--i >= 0) > cleanup(&bridge.sensors[i]); Ha-ha. It's actually a counter argument to your stuff because above is the same as while (i--) cleanup(&bridge.sensors[i]); with pretty much unsigned int i. > There are very few times where raising the type maximum from 2 billion > to 4 billion fixes anything. -- With Best Regards, Andy Shevchenko _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel