Re: [PATCH] KVM: arm64: vgic: declear local variable 'flags' before for loop starts

From: Marc Zyngier
Date: Sat Jun 12 2021 - 07:11:27 EST


On Sat, 12 Jun 2021 12:00:14 +0100,
Austin Kim <austindh.kim@xxxxxxxxx> wrote:
>
> From: Austin Kim <austin.kim@xxxxxxx>
>
> Normally local variable 'flags' is defined out of for loop,
> when 'flags' is used as the second parameter in a call to
> spinlock_irq[save/restore] function.
>
> So it had better declear local variable 'flags' ahead of for loop.

Why better? Reducing the scope of a variable is in general good
practice. Do you see any material advantage in moving this variable
out of the loop? Does the compiler generate better code?

Thanks,

M.

--
Without deviation from the norm, progress is not possible.