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

Reply via email to