[PATCH 01/40] qemuMonitorJSONObjectProperty: Make 'str' member const

Peter Krempa posted 40 patches 5 years ago
[PATCH 01/40] qemuMonitorJSONObjectProperty: Make 'str' member const
Posted by Peter Krempa 5 years ago
The code only reads it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_monitor_json.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index ba1531fee8..64af758885 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -477,7 +477,7 @@ struct _qemuMonitorJSONObjectProperty {
         unsigned int ui;
         unsigned long long ul;
         double d;
-        char *str;
+        const char *str;
     } val;
 };

-- 
2.29.2

Re: [PATCH 01/40] qemuMonitorJSONObjectProperty: Make 'str' member const
Posted by Michal Privoznik 4 years, 12 months ago
On 2/6/21 9:32 AM, Peter Krempa wrote:
> The code only reads it.

Is that so? qemuMonitorJSONGetObjectProperty() strdup()-s into ->str.

> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>   src/qemu/qemu_monitor_json.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
> index ba1531fee8..64af758885 100644
> --- a/src/qemu/qemu_monitor_json.h
> +++ b/src/qemu/qemu_monitor_json.h
> @@ -477,7 +477,7 @@ struct _qemuMonitorJSONObjectProperty {
>           unsigned int ui;
>           unsigned long long ul;
>           double d;
> -        char *str;
> +        const char *str;
>       } val;
>   };
> 

Michal