[Mesa-dev] [PATCH 01/12] genxml: Silence about a billion unused parameter warnings

Ian Romanick idr at freedesktop.org
Tue Jun 27 17:13:46 UTC 2017


On 06/27/2017 10:04 AM, Dylan Baker wrote:
> Quoting Ian Romanick (2017-06-26 16:22:34)
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> v2: Use textwrap.dedent to make the source line a lot shorter.
>> Shortening (?) the line was requested by Jason.
>>
>> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
>> ---
>>  src/intel/genxml/gen_pack_header.py | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/intel/genxml/gen_pack_header.py b/src/intel/genxml/gen_pack_header.py
>> index fefbc9a..a96a232 100644
>> --- a/src/intel/genxml/gen_pack_header.py
>> +++ b/src/intel/genxml/gen_pack_header.py
>> @@ -8,6 +8,7 @@ import xml.parsers.expat
>>  import re
>>  import sys
>>  import copy
>> +import textwrap
>>  
>>  license =  """/*
>>   * Copyright (C) 2016 Intel Corporation
>> @@ -578,8 +579,12 @@ class Parser(object):
>>  
>>      def emit_pack_function(self, name, group):
>>          name = self.gen_prefix(name)
>> -        print("static inline void\n%s_pack(__gen_user_data *data, void * restrict dst,\n%sconst struct %s * restrict values)\n{" %
>> -              (name, ' ' * (len(name) + 6), name))
>> +        print(textwrap.dedent("""\
>> +            static inline void
>> +            %s_pack(__attribute__((unused)) __gen_user_data *data,
>> +            %s__attribute__((unused)) void * restrict dst,
>> +            %s__attribute__((unused)) const struct %s * restrict values)
>> +            {""") % (name, ' ' * (len(name) + 6), ' ' * (len(name) + 6), name))
> 
> There are a couple of things you could do here to simplify this a bit.
> One is that textwrap.dedent will remove the same number of spaces from every
> line (the shortest, so in this case the length removed will be equal to the
> number of spaces before "static"), so you don't need to do the + 6 to the
> len(name), you could just put those in the string. The second is that using
> str.format() will save duplicating the inputs:
> 
> print(textwrap.dedent("""\
>     static inline void
>     {0}_pack(__attribute__((unused)) __gen_user_data *data,
>           {1}__attribute__((unused)) void * restrict dst,
>           {1}__attribute__((unused)) const struct {0} * restrict values)
>     {""").format(name, ' ' * (len(name))))
> 
> Either way,
> Reviewed-by: Dylan Baker <dylan at pnwbakers.com>

Right. #obvious. :) I'll make that change.

>>  
>>          (dwords, length) = group.collect_dwords_and_length()
>>          if length:
>> -- 
>> 2.9.4
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170627/cbf6192f/attachment.sig>


More information about the mesa-dev mailing list