On 10/20/20 1:17 PM, Peng Liang wrote:
On 10/19/2020 6:35 PM, Philippe Mathieu-Daudé wrote:
On 10/19/20 11:34 AM, Peng Liang wrote:
VMStateDescription.fields should be end with VMSTATE_END_OF_LIST().
However, microbit_i2c_vmstate doesn't follow it. Let's change it.
It might be easy to add a Coccinelle script to avoid future errors.
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
I tried to add a Coccinelle script to add VMSTATE_END_OF_LIST() to the
end of VMStateDescription.fields. For those who are not defined as
compound literals, it works well. However, I cannot make it work for
those defined as compound literals. And Julia doesn't think compound
literals are supported currently[1]. So maybe currently it's hard to
check the error using Coccinelle :(
Interesting.
Thanks for my colleague Biaoxiang Ye, who wrote a shell script to find
the errors, I didn't find other similar errors.
Thanks for giving it a try. We could commit and run the script
in a gitlab-ci job to avoid such regressions.
[1]
https://lore.kernel.org/cocci/alpine.DEB.2.22.394.2010201143330.2736@hadrien/T/#t
Thanks,
Peng
Fixes: 9d68bf564e ("arm: Stub out NRF51 TWI magnetometer/accelerometer
detection")
Reported-by: Euler Robot <[email protected]>
Signed-off-by: Peng Liang <[email protected]>
---
hw/i2c/microbit_i2c.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/i2c/microbit_i2c.c b/hw/i2c/microbit_i2c.c
index 802473982082..e92f9f84ea81 100644
--- a/hw/i2c/microbit_i2c.c
+++ b/hw/i2c/microbit_i2c.c
@@ -83,6 +83,7 @@ static const VMStateDescription microbit_i2c_vmstate
= {
.fields = (VMStateField[]) {
VMSTATE_UINT32_ARRAY(regs, MicrobitI2CState,
MICROBIT_I2C_NREGS),
VMSTATE_UINT32(read_idx, MicrobitI2CState),
+ VMSTATE_END_OF_LIST()
},
};
.