[Mesa-dev] [PATCH] glapi: Fix -Wduplicate-decl-specifier due to double-const

Kenneth Graunke kenneth at whitecape.org
Sun Jun 25 06:48:11 UTC 2017


On Thursday, June 22, 2017 3:17:21 PM PDT Chad Versace wrote:
> Fix all lines in src/mesa/main/marshal_generated.c that declare
> double-const variables. Below is all such lines, with duplicates
> removed:
> 
>    $ grep 'const const' marshal_generated.c | sort -u
>    const const GLboolean * pointer = cmd->pointer;
>    const const GLvoid * indices = cmd->indices;
>    const const GLvoid * pointer = cmd->pointer;
> 
> Cc: Ian Romanick <idr at freedesktop.org>
> ---
>  src/mapi/glapi/gen/gl_marshal.py | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mapi/glapi/gen/gl_marshal.py b/src/mapi/glapi/gen/gl_marshal.py
> index f52b9b7b810..38196c461ea 100644
> --- a/src/mapi/glapi/gen/gl_marshal.py
> +++ b/src/mapi/glapi/gen/gl_marshal.py
> @@ -176,11 +176,19 @@ class PrintCode(gl_XML.gl_print_base):
>          with indent():
>              for p in func.fixed_params:
>                  if p.count:
> -                    out('const {0} * {1} = cmd->{1};'.format(
> -                            p.get_base_type_string(), p.name))
> +                    p_decl = '{0} * {1} = cmd->{1};'.format(
> +                            p.get_base_type_string(), p.name)
>                  else:
> -                    out('const {0} {1} = cmd->{1};'.format(
> -                            p.type_string(), p.name))
> +                    p_decl = '{0} {1} = cmd->{1};'.format(
> +                            p.type_string(), p.name)
> +
> +                if not p_decl.startswith('const '):
> +                    # Declare all local function variables as const, even if
> +                    # the original parameter is not const.
> +                    p_decl = 'const ' + p_decl
> +
> +                out(p_decl)
> +
>              if func.variable_params:
>                  for p in func.variable_params:
>                      out('const {0} * {1};'.format(
> 

Thank you for fixing this up!

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170624/9020ee40/attachment.sig>


More information about the mesa-dev mailing list