[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 6/9] chardev: add appropriate getting address
|
From: |
Maxim Davydov |
|
Subject: |
[PATCH v1 6/9] chardev: add appropriate getting address |
|
Date: |
Tue, 29 Mar 2022 00:15:36 +0300 |
Attempt to get address after initialization shouldn't fail on assert in
the qapi automatically generated code. As a possible solution, it can
return null type.
Signed-off-by: Maxim Davydov <maxim.davydov@openvz.org>
---
chardev/char-socket.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index fab2d791d4..f851e3346b 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -33,6 +33,7 @@
#include "qapi/clone-visitor.h"
#include "qapi/qapi-visit-sockets.h"
#include "qemu/yank.h"
+#include "qapi/qmp/qnull.h"
#include "chardev/char-io.h"
#include "chardev/char-socket.h"
@@ -1509,6 +1510,14 @@ char_socket_get_addr(Object *obj, Visitor *v, const char
*name,
{
SocketChardev *s = SOCKET_CHARDEV(obj);
+ QNull *null = NULL;
+
+ /* Return NULL type if getting addr was called after init */
+ if (!s->addr) {
+ visit_type_null(v, NULL, &null, errp);
+ return;
+ }
+
visit_type_SocketAddress(v, name, &s->addr, errp);
}
--
2.31.1
- [PATCH v1 3/9] mem: appropriate handling getting mem region, (continued)
- [PATCH v1 3/9] mem: appropriate handling getting mem region, Maxim Davydov, 2022/03/28
- [PATCH v1 2/9] pci: add null-pointer check, Maxim Davydov, 2022/03/28
- [PATCH v1 4/9] msmouse: add appropriate unregister handler, Maxim Davydov, 2022/03/28
- [PATCH v1 5/9] wctablet: add appropriate unregister handler, Maxim Davydov, 2022/03/28
- [PATCH v1 6/9] chardev: add appropriate getting address,
Maxim Davydov <=
- [PATCH v1 7/9] colo-compare: safe finalization, Maxim Davydov, 2022/03/28
- [PATCH v1 8/9] qom: add command to print initial properties, Maxim Davydov, 2022/03/28
- [PATCH v1 9/9] scripts: printing machine type compat properties, Maxim Davydov, 2022/03/28
- Re: [PATCH v1 0/9] Machine type compatible properties, Igor Mammedov, 2022/03/31