From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A3319A034D; Sat, 26 Feb 2022 18:31:42 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 29A0D410E9; Sat, 26 Feb 2022 18:31:42 +0100 (CET) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by mails.dpdk.org (Postfix) with ESMTP id 5999C4068F for ; Sat, 26 Feb 2022 18:31:41 +0100 (CET) Received: by mail-pl1-f176.google.com with SMTP id l9so6922515pls.6 for ; Sat, 26 Feb 2022 09:31:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WMXTGKXVwY2ep/R1DkTXN2LFHIs8KwF82PoI2+b448o=; b=SW0QOHNTL9lNCyJzUZ38AIGerVFbLuhV3aDRBbq/t8VrGNFtmZyy+sXvEr3nDDose4 tCvL592FIBliX/RAPUDHek5MJy7cW/fhJHVO7/T5bEyDuACBDEa02RwCRU46+TpbJOUn E5rvPiG5A4F0QreC+LjpeYykPAfo/GXQZMcmQ4fmHEtrJz5XUTIDIFQ/d5Hj00oyC19i Oq3D2BTNVxFw+ubrKgWyrn84gHf3cy1g2fO868LFuvHzQCAC5bxz1vzO59KuNHyGEKnl HZVTPx3ZjAyzfKAF513PZcbDoatZejCGn8Sa3g0RMVpPgTMjkg/9YZ5xG3+lNKlqt0bJ AdLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WMXTGKXVwY2ep/R1DkTXN2LFHIs8KwF82PoI2+b448o=; b=NrGRZ1v/I0NWHWL+CLG7kbdWJuCr1b9aBBqXQgAlhKsdMeBJP0PJjqz6pFmKPHK6mi yaDURcm3J/XC3Ov4ej9xEADnrFofJG4iOfB8AmyGbjZu9PXa6Y1SuhxmhjCXISB/V4AM uMVoLp39E2I+UXihVfymYUErijDMRHCgsSVBTMBnGsZIM+txLc8xmsQiZYUj12cTkrCJ raalFj105zv1xP4zHnIbFOExA1/VLvMp7KU0zcv9vNOR69vh3vnI4Q2EU2kDr64Neaje cHGd+41g5+CmIpkCHjE66Dck00iru1A/LNgSc1O//spOWi4PSAUDy0m9FwBNsIul2sMV EPOQ== X-Gm-Message-State: AOAM531kV3HKqmkTpL4LXCO1be+H8tlC8VINMVWSKxg7fYxTid/u9xoL Oz0EHY1E1M6wFl5xCRjizSnm/A== X-Google-Smtp-Source: ABdhPJxNmKzCQi6qy4xSaUTsdA744ud0+/os57Banh60BG0HI0A13QizZwrz2U9HfrSNA12naEx0tA== X-Received: by 2002:a17:902:d0d2:b0:14f:d360:c103 with SMTP id n18-20020a170902d0d200b0014fd360c103mr12734081pln.7.1645896700354; Sat, 26 Feb 2022 09:31:40 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id i2-20020a17090ac40200b001bd0e552d27sm2690076pjt.11.2022.02.26.09.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Feb 2022 09:31:40 -0800 (PST) Date: Sat, 26 Feb 2022 09:31:37 -0800 From: Stephen Hemminger To: Weiguo Li Cc: cristian.dumitrescu@intel.com, wojciechx.liguzinski@intel.com, dev@dpdk.org Subject: Re: [PATCH] sched: add parentheses to if clause Message-ID: <20220226093137.3723b20f@hermes.local> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Sat, 26 Feb 2022 22:55:30 +0800 Weiguo Li wrote: > Add parentheses to 'if' clause, otherwise will enlarged the > chance of error return. > > Fixes: 44c730b0e37971 ("sched: add PIE based congestion management") > > Signed-off-by: Weiguo Li > --- > lib/sched/rte_pie.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/lib/sched/rte_pie.c b/lib/sched/rte_pie.c > index cdb7bab697..51df403a25 100644 > --- a/lib/sched/rte_pie.c > +++ b/lib/sched/rte_pie.c > @@ -18,10 +18,10 @@ rte_pie_rt_data_init(struct rte_pie *pie) > /* Allocate memory to use the PIE data structure */ > pie = rte_malloc(NULL, sizeof(struct rte_pie), 0); > > - if (pie == NULL) > + if (pie == NULL) { > RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__); > - > - return -1; > + return -1; > + } > } > > pie->active = 0; This will make the test in test_pie.c fail. The concept of passing NULL to the routine and expecting allocation is bad idea because the allocated structure is never initialized. Since rte_pie_rt_data_init(NULL) always returned -1. It would make more sense to take out the rte_malloc(). And document it. P.s: the routing should return a negative rte_errno instead of -1 as well.