From mboxrd@z Thu Jan 1 00:00:00 1970 From: Neil Horman Subject: Re: [PATCH 05/15] ring: Convert to use of PMD_REGISTER_DRIVER and fix linking Date: Thu, 17 Apr 2014 07:06:59 -0400 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 Cc: "dev-VfR2kkLFssw@public.gmane.org" To: "Ananyev, Konstantin" Return-path: Content-Disposition: inline In-Reply-To: <2601191342CEEE43887BDE71AB9772580EF973E4-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 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