From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id B00115919 for ; Thu, 17 Apr 2014 13:07:02 +0200 (CEST) Received: from hmsreliant.think-freely.org ([2001:470:8:a08:7aac:c0ff:fec2:933b] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1Wak9k-0007DU-JA; Thu, 17 Apr 2014 07:07:02 -0400 Date: Thu, 17 Apr 2014 07:06:59 -0400 From: Neil Horman To: "Ananyev, Konstantin" Message-ID: <20140417110659.GE13715@hmsreliant.think-freely.org> References: <1397585169-14537-1-git-send-email-nhorman@tuxdriver.com> <1397585169-14537-6-git-send-email-nhorman@tuxdriver.com> <2601191342CEEE43887BDE71AB9772580EF973E4@IRSMSX105.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2601191342CEEE43887BDE71AB9772580EF973E4@IRSMSX105.ger.corp.intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -2.9 (--) X-Spam-Status: No Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH 05/15] ring: Convert to use of PMD_REGISTER_DRIVER and fix linking X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Apr 2014 11:07:02 -0000 On Thu, Apr 17, 2014 at 09:50:02AM +0000, Ananyev, Konstantin wrote: > Hi Neil, > Few comments from me there. > Thanks > Konstantin > > - parse_kvlist(): > > 1) > node = strchr(name, ':'); > ... > action = strchr(node, ':'); > > We can't expect that input parameter will always be valid. > So need to check that strchr() doesn't return NULL. > > 2) > if (strcmp(action, "ATTACH")) > if (strcmp(action, "CREATE")) > goto out; > ... > info->list[info->count].action = strcmp(action, "ATTACH") ? DEV_CREATE : DEV_ATTACH; > > Can you create a macros for these 2 string constants and use them instead. > Another thing, probably better to reorder it that way: > > if (strcmp(action, "ATTACH") == 0) > info->list[info->count].action = DEV_ATTACH; > else if (strcmp(action, "CREATE") == 0) > info->list[info->count].action = DEV_CREATE; > else > goto out; > > Would save you one strcmp() and looks a bit cleaner. > > 3) > info->list[info->count].node = strtol(node, NULL, 10); > Again we can't assume that input string will always be valid. > Something like that should do, I think: > > char *end; > ... > errno = 0; > info->list[info->count].node = strtoul(node, &end, 10); > if (errno != 0 || *end != 0) { > ret = -EINVAL; > goto out; > } > > 4) > strncpy(info->list[info->count].name, name, PATH_MAX); > When RTE_INSECURE_FUNCTION_WARNING is defined, strncpy() (and some other functions) are marked as poisoned. > Another thing - as I remember, if strlen(name) >= PATH_MAX, then destination string will not be null terminated. > So probably something like that instead: > rte_snprintf(info->list[info->count].name, sizeof(info->list[info->count].name), "%s", name); > > - rte_pmd_ring_devinit(): > > 5) > printf("Parsing kvargs\n"); > Here and everywhere - please use RTE_LOG() instead. > > Thank you Anayev, I'll square these all up and submit a v2 of this patch. Neil