From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B22EDA046B for ; Wed, 26 Jun 2019 14:52:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C4DE020BD; Wed, 26 Jun 2019 14:52:21 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 5F101271 for ; Wed, 26 Jun 2019 14:52:20 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2019 05:52:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,419,1557212400"; d="scan'208";a="155857400" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.237.220.101]) ([10.237.220.101]) by orsmga008.jf.intel.com with ESMTP; 26 Jun 2019 05:52:18 -0700 To: Bruce Richardson , Thomas Monjalon Cc: David Marchand , dev References: <20190626104056.26829-1-thomas@monjalon.net> <305b244d-ef0a-937b-9628-94aaede96b27@intel.com> <8628822.145IoVqhEV@xps> <20190626123623.GB862@bricha3-MOBL.ger.corp.intel.com> From: "Burakov, Anatoly" Message-ID: Date: Wed, 26 Jun 2019 13:52:17 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190626123623.GB862@bricha3-MOBL.ger.corp.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 26-Jun-19 1:36 PM, Bruce Richardson wrote: > On Wed, Jun 26, 2019 at 01:55:53PM +0200, Thomas Monjalon wrote: >> 26/06/2019 13:43, Burakov, Anatoly: >>> On 26-Jun-19 12:39 PM, David Marchand wrote: >>>> On Wed, Jun 26, 2019 at 1:36 PM Thomas Monjalon wrote: >>>> >>>>> 26/06/2019 13:20, David Marchand: >>>>>> On Wed, Jun 26, 2019 at 12:41 PM Thomas Monjalon >>>>>> wrote: >>>>>> >>>>>>> When adding an alarm, if an error happen when registering >>>>>>> the common alarm callback, it is not considered as a major failure. >>>>>>> The alarm is then inserted in the list. >>>>>>> However it was returning an error code after inserting the alarm. >>>>>>> >>>>>>> The error code is reset to 0 so the behaviour and the return code >>>>>>> are consistent. >>>>>>> Other return code related lines are cleaned up for easier >>>>> understanding. >>>>>>> >>>>> [...] >>>>>>> --- a/lib/librte_eal/linux/eal/eal_alarm.c >>>>>>> +++ b/lib/librte_eal/linux/eal/eal_alarm.c >>>>>>> if (!handler_registered) { >>>>>>> - ret |= rte_intr_callback_register(&intr_handle, >>>>>>> + ret = rte_intr_callback_register(&intr_handle, >>>>>>> eal_alarm_callback, NULL); >>>>>>> - handler_registered = (ret == 0) ? 1 : 0; >>>>>>> + if (ret == 0) >>>>>>> + handler_registered = 1; >>>>>>> + else >>>>>>> + /* not fatal, callback can be registered later >>>>> */ >>>>>>> + ret = 0; >>>>>>> } >>>>>> >>>>>> Well, then it means that you don't want to touch ret at all. >>>>>> How about: >>>>>> if (rte_intr_callback_register(&intr_handle, >>>>>> eal_alarm_callback, NULL) == 0) >>>>>> handler_registered = 1; >>>>>> >>>>>> ? >>>>> >>>>> Too much simple :) >>>>> >>>>> I think we try to avoid calling a function in a "if" >>>>> per coding style. >>>>> And my proposal has the benefit of offering a comment >>>>> about the non-fatal error. >>>>> >>>> >>>> /* not fatal, callback can be registered later */ >>>> if (rte_intr_callback_register(&intr_handle, >>>> eal_alarm_callback, NULL) == 0) >>>> handler_registered = 1; >>>> >>> >>> I prefer the original. It's more explicit and conveys the intention >>> better. Did i break the tie? :) >> >> I was going to send a v2 with David's suggestion. >> Now I'm confused. >> > I always tend to prefer shorter versions, so +1 for v2 (does that make it a > v3? :-) ) > > /Bruce > OK, but then the suggested comment needs to be fixed. It makes it seem like registering the handler is the "non fatal" part. Perhaps something like: /* failed register is not a fatal error - callback can be registered later */ -- Thanks, Anatoly