diff mbox series

[v3,19/19] qom: Require TypeInfo::class_data points to const data

Message ID 20250212213249.45574-20-philmd@linaro.org
State New
Headers show
Series qom: Constify class_data | expand

Commit Message

Philippe Mathieu-Daudé Feb. 12, 2025, 9:32 p.m. UTC
All TypeInfo::class_data point to const data.
Enforce that in the structure, so future class_data
stays in .rodata.

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

Comments

Richard Henderson Feb. 12, 2025, 10:11 p.m. UTC | #1
On 2/12/25 13:32, Philippe Mathieu-Daudé wrote:
> All TypeInfo::class_data point to const data.
> Enforce that in the structure, so future class_data
> stays in .rodata.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/qom/object.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 1d5b0337242..31adc2ef174 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -488,7 +488,7 @@ struct TypeInfo
>   
>       void (*class_init)(ObjectClass *klass, const void *data);
>       void (*class_base_init)(ObjectClass *klass, const void *data);
> -    const void *class_data;
> +    const void *const class_data;
>   
>       const InterfaceInfo *interfaces;
>   };


This doesn't do what you think it does.
I'm surprised it compiles.


r~
diff mbox series

Patch

diff --git a/include/qom/object.h b/include/qom/object.h
index 1d5b0337242..31adc2ef174 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -488,7 +488,7 @@  struct TypeInfo
 
     void (*class_init)(ObjectClass *klass, const void *data);
     void (*class_base_init)(ObjectClass *klass, const void *data);
-    const void *class_data;
+    const void *const class_data;
 
     const InterfaceInfo *interfaces;
 };