[dpdk-dev] [PATCH 1/5] eal: refactor plugin list append from eal_parse_args() to a helper function

Bruce Richardson bruce.richardson at intel.com
Fri Oct 16 14:57:28 CEST 2015


On Fri, Oct 16, 2015 at 02:58:13PM +0300, Panu Matilainen wrote:
> Signed-off-by: Panu Matilainen <pmatilai at redhat.com>
> ---
>  lib/librte_eal/linuxapp/eal/eal.c | 28 +++++++++++++++++++---------
>  1 file changed, 19 insertions(+), 9 deletions(-)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
> index 33e1067..cc66d9f 100644
> --- a/lib/librte_eal/linuxapp/eal/eal.c
> +++ b/lib/librte_eal/linuxapp/eal/eal.c
> @@ -530,6 +530,24 @@ eal_log_level_parse(int argc, char **argv)
>  	optind = 0; /* reset getopt lib */
>  }
>  
> +static int
> +eal_plugin_add(const char *path)
> +{
> +	struct shared_driver *solib;
> +
> +	solib = malloc(sizeof(*solib));
> +	if (solib == NULL) {
> +		RTE_LOG(ERR, EAL, "malloc(solib) failed\n");
> +		return -1;
> +	}
> +	memset(solib, 0, sizeof(*solib));
> +	strncpy(solib->name, path, PATH_MAX-1);
> +	solib->name[PATH_MAX-1] = 0;

I always prefer a one-line snprintf to the above two-line code. :-)

/Bruce


More information about the dev mailing list