[ovs-dev] [PATCH] Make struct stress_option members const
Ben Pfaff
blp at nicira.com
Mon Mar 19 18:18:10 UTC 2012
When I apply this patch I get:
../ovsdb/ovsdb-server.c:128:32: warning: incorrect type in argument 1 (different modifiers)
../ovsdb/ovsdb-server.c:128:32: expected char **argv
../ovsdb/ovsdb-server.c:128:32: got char const **<noident>
../ovsdb/ovsdb-server.c: In function ‘main’:
../ovsdb/ovsdb-server.c:128: error: passing argument 1 of ‘process_start’ from incompatible pointer type
../lib/process.h:26: note: expected ‘char **’ but argument is of type ‘const char **’
On Mon, Mar 19, 2012 at 07:20:30AM +0900, Simon Horman wrote:
> Make the name and description members of struct stress_option
> const as they are used to store constant strings.
>
> Signed-off-by: Simon Horman <horms at verge.net.au>
>
> ---
>
> $ gcc --version
> gcc (Debian 4.6.2-4) 4.6.2
> Copyright (C) 2011 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> $ make
> ...
> lib/netlink-socket.c:294:2: warning: initialization discards ‘const’ qualifier from pointer target type [enabled by default]
> lib/netlink-socket.c:294:2: warning: initialization discards ‘const’ qualifier from pointer target type [enabled by default]
> ---
> lib/stress.h | 4 ++--
> ovsdb/ovsdb-server.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lib/stress.h b/lib/stress.h
> index 9d6ea97..386db29 100644
> --- a/lib/stress.h
> +++ b/lib/stress.h
> @@ -21,8 +21,8 @@
>
> struct stress_option {
> /* Properties. */
> - char *name; /* Short identifier string */
> - char *description; /* Description of what the option stresses. */
> + const char *name; /* Short identifier string */
> + const char *description; /* Description of what the option stresses. */
> unsigned int recommended; /* Recommended period. */
> unsigned int min; /* Minimum period that can be set. */
> unsigned int max; /* Maximum period that can be set. */
> diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
> index 9e0636e..f79e529 100644
> --- a/ovsdb/ovsdb-server.c
> +++ b/ovsdb/ovsdb-server.c
> @@ -118,7 +118,7 @@ main(int argc, char *argv[])
> }
>
> if (run_command) {
> - char *run_argv[4];
> + const char *run_argv[4];
>
> run_argv[0] = "/bin/sh";
> run_argv[1] = "-c";
> --
> 1.7.6.3
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
More information about the dev
mailing list