[PATCH 10/11] net/eth: Clean up local variable shadowing

Philippe Mathieu-Daudé posted 11 patches 2 years, 5 months ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Beniamino Galvani <b.galvani@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, Strahinja Jankovic <strahinja.p.jankovic@gmail.com>, "Cédric Le Goater" <clg@kaod.org>, Andrew Jeffery <andrew@aj.id.au>, Joel Stanley <joel@jms.id.au>, John Snow <jsnow@redhat.com>, Laurent Vivier <laurent@vivier.eu>, Alistair Francis <alistair.francis@wdc.com>, David Gibson <david@gibson.dropbear.id.au>, Dmitry Fleytman <dmitry.fleytman@gmail.com>, Akihiko Odaki <akihiko.odaki@daynix.com>, Jason Wang <jasowang@redhat.com>, Alexander Graf <agraf@csgraf.de>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
There is a newer version of this series
[PATCH 10/11] net/eth: Clean up local variable shadowing
Posted by Philippe Mathieu-Daudé 2 years, 5 months ago
Fix:

  net/eth.c:435:20: error: declaration shadows a local variable [-Werror,-Wshadow]
            size_t input_size = iov_size(pkt, pkt_frags);
                   ^
  net/eth.c:413:16: note: previous declaration is here
        size_t input_size = iov_size(pkt, pkt_frags);
               ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 net/eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/eth.c b/net/eth.c
index 649e66bb1f..cf030eed7b 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -432,7 +432,7 @@ _eth_get_rss_ex_src_addr(const struct iovec *pkt, int pkt_frags,
         }
 
         if (opthdr.type == IP6_OPT_HOME) {
-            size_t input_size = iov_size(pkt, pkt_frags);
+            input_size = iov_size(pkt, pkt_frags);
 
             if (input_size < opt_offset + sizeof(opthdr)) {
                 return false;
-- 
2.41.0


Re: [PATCH 10/11] net/eth: Clean up local variable shadowing
Posted by Akihiko Odaki 2 years, 5 months ago
On 2023/09/01 7:56, Philippe Mathieu-Daudé wrote:
> Fix:
> 
>    net/eth.c:435:20: error: declaration shadows a local variable [-Werror,-Wshadow]
>              size_t input_size = iov_size(pkt, pkt_frags);
>                     ^
>    net/eth.c:413:16: note: previous declaration is here
>          size_t input_size = iov_size(pkt, pkt_frags);
>                 ^
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   net/eth.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/eth.c b/net/eth.c
> index 649e66bb1f..cf030eed7b 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -432,7 +432,7 @@ _eth_get_rss_ex_src_addr(const struct iovec *pkt, int pkt_frags,
>           }
>   
>           if (opthdr.type == IP6_OPT_HOME) {
> -            size_t input_size = iov_size(pkt, pkt_frags);
> +            input_size = iov_size(pkt, pkt_frags);

You can just remove this statement.

>   
>               if (input_size < opt_offset + sizeof(opthdr)) {
>                   return false;

Re: [PATCH 10/11] net/eth: Clean up local variable shadowing
Posted by Philippe Mathieu-Daudé 2 years, 5 months ago
On 1/9/23 09:07, Akihiko Odaki wrote:
> On 2023/09/01 7:56, Philippe Mathieu-Daudé wrote:
>> Fix:
>>
>>    net/eth.c:435:20: error: declaration shadows a local variable 
>> [-Werror,-Wshadow]
>>              size_t input_size = iov_size(pkt, pkt_frags);
>>                     ^
>>    net/eth.c:413:16: note: previous declaration is here
>>          size_t input_size = iov_size(pkt, pkt_frags);
>>                 ^
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   net/eth.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/eth.c b/net/eth.c
>> index 649e66bb1f..cf030eed7b 100644
>> --- a/net/eth.c
>> +++ b/net/eth.c
>> @@ -432,7 +432,7 @@ _eth_get_rss_ex_src_addr(const struct iovec *pkt, 
>> int pkt_frags,
>>           }
>>           if (opthdr.type == IP6_OPT_HOME) {
>> -            size_t input_size = iov_size(pkt, pkt_frags);
>> +            input_size = iov_size(pkt, pkt_frags);
> 
> You can just remove this statement.

Clever eh, thanks!