Re: [PATCH v2 04/21] hw/block: Pass DeviceState to pflash_cfi01_get_memory()

2023-01-13 Thread Peter Maydell
On Mon, 9 Jan 2023 at 23:43, Bernhard Beschow wrote: > > > > Am 9. Januar 2023 12:08:16 UTC schrieb "Philippe Mathieu-Daudé" > : > >The point of a getter() function is to not expose the structure > >internal fields. Otherwise callers could simply access the > >PFlashCFI01::mem field. "modern" QO

Re: [PATCH v2 04/21] hw/block: Pass DeviceState to pflash_cfi01_get_memory()

2023-01-09 Thread Bernhard Beschow
Am 9. Januar 2023 12:08:16 UTC schrieb "Philippe Mathieu-Daudé" : >The point of a getter() function is to not expose the structure >internal fields. Otherwise callers could simply access the >PFlashCFI01::mem field. The getter also works with a typedef which doesn't need the structure exposed.

[PATCH v2 04/21] hw/block: Pass DeviceState to pflash_cfi01_get_memory()

2023-01-09 Thread Philippe Mathieu-Daudé
The point of a getter() function is to not expose the structure internal fields. Otherwise callers could simply access the PFlashCFI01::mem field. Have the callers pass a DeviceState* argument. The QOM type check is done in the callee. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Bin Meng