[dpdk-dev] [PATCH] kvargs: make pointers in string arrays const

Olivier Matz olivier.matz at 6wind.com
Fri Jan 13 18:44:45 CET 2017


On Thu, 12 Jan 2017 16:18:27 +0000, Bruce Richardson
<bruce.richardson at intel.com> wrote:
> Change the parameters of functions from const char *valid[] to
> const char * const valid[]. This additional const is needed to
> allow us to fix some checkpatch warnings, as well as being good
> programming practice.
> 
> For the checkpatch warnings, if we have a set of command line
> args that we want to check defined as:
> 	static const char *args[] = { "arg1", "arg2", NULL };
> 	kvlist = rte_kvargs_parse(params, args);
> 
> checkpatch will complain:
> 	WARNING:STATIC_CONST_CHAR_ARRAY: static const char *
> 	array should probably be static const char * const
> 
> Adding the additional const to the definition of the args
> will then trigger a compiler error in the absense of this
> change to the kvargs library, as we lose the const in the
> call to kvargs_parse.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>

Acked-by: Olivier Matz <olivier.matz at 6wind.com>


More information about the dev mailing list