[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v2 22/22] softmmu/physmem: Clean up local variable shadow
From: |
Peter Xu |
Subject: |
Re: [RFC PATCH v2 22/22] softmmu/physmem: Clean up local variable shadowing |
Date: |
Tue, 5 Sep 2023 11:50:58 -0400 |
On Mon, Sep 04, 2023 at 05:31:30PM +0100, Daniel P. Berrangé wrote:
> On Mon, Sep 04, 2023 at 06:12:34PM +0200, Philippe Mathieu-Daudé wrote:
> > Fix:
> >
> > softmmu/physmem.c: In function
> > ‘cpu_physical_memory_snapshot_and_clear_dirty’:
> > softmmu/physmem.c:916:27: warning: declaration of ‘offset’ shadows a
> > parameter [-Wshadow=compatible-local]
> > 916 | unsigned long offset = page % DIRTY_MEMORY_BLOCK_SIZE;
> > | ^~~~~~
> > softmmu/physmem.c:892:31: note: shadowed declaration is here
> > 892 | (MemoryRegion *mr, hwaddr offset, hwaddr length, unsigned
> > client)
> > | ~~~~~~~^~~~~~
> >
> > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> > ---
> > RFC: Please double-check how 'offset' is used few lines later.
>
> I don't see an issue - those lines are in an outer scope, so won't
> be accessing the 'offset' you've changed, they'll be the parameter
> instead. If you want to sanity check though, presumably the asm
> dissassembly for this method should be the same before/after this
> change
(and if it didn't do so then it's a bug..)
>
> > ---
> > softmmu/physmem.c | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
>
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
- Re: [PATCH v2 17/22] util/vhost-user-server: Clean up local variable shadowing, (continued)
- [PATCH v2 18/22] semihosting/arm-compat: Clean up local variable shadowing, Philippe Mathieu-Daudé, 2023/09/04
- [PATCH v2 19/22] linux-user/strace: Clean up local variable shadowing, Philippe Mathieu-Daudé, 2023/09/04
- [PATCH v2 20/22] sysemu/device_tree: Clean up local variable shadowing, Philippe Mathieu-Daudé, 2023/09/04
- [PATCH v2 21/22] softmmu/memory: Clean up local variable shadowing, Philippe Mathieu-Daudé, 2023/09/04
- [RFC PATCH v2 22/22] softmmu/physmem: Clean up local variable shadowing, Philippe Mathieu-Daudé, 2023/09/04
- Re: [PATCH v2 00/22] (few more) Steps towards enabling -Wshadow, Markus Armbruster, 2023/09/29