Skip to content

Commit 76f26e4

Browse files
committed
hw/xen: Use xs_node_read() from xs_node_vscanf()
Reduce some duplication. Signed-off-by: David Woodhouse <[email protected]> Reviewed-by: Anthony PERARD <[email protected]> Acked-by: Roger Pau Monné <[email protected]>
1 parent 7a0b74d commit 76f26e4

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

hw/xen/trace-events

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ xen_device_remove_watch(const char *type, char *name, const char *node, const ch
3838
xs_node_create(const char *node) "%s"
3939
xs_node_destroy(const char *node) "%s"
4040
xs_node_vprintf(char *path, char *value) "%s %s"
41-
xs_node_vscanf(char *path, char *value) "%s %s"
4241
xs_node_read(const char *path, const char *value) "%s %s"
4342
xs_node_watch(char *path) "%s"
4443
xs_node_unwatch(char *path) "%s"

hw/xen/xen-bus-helper.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,22 @@ int xs_node_vscanf(struct qemu_xs_handle *h, xs_transaction_t tid,
105105
const char *node, const char *key, Error **errp,
106106
const char *fmt, va_list ap)
107107
{
108-
char *path, *value;
108+
char *value;
109109
int rc;
110110

111-
path = (strlen(node) != 0) ? g_strdup_printf("%s/%s", node, key) :
112-
g_strdup(key);
113-
value = qemu_xen_xs_read(h, tid, path, NULL);
114-
115-
trace_xs_node_vscanf(path, value);
111+
if (node && strlen(node) != 0) {
112+
value = xs_node_read(h, tid, NULL, errp, "%s/%s", node, key);
113+
} else {
114+
value = xs_node_read(h, tid, NULL, errp, "%s", key);
115+
}
116116

117117
if (value) {
118118
rc = vsscanf(value, fmt, ap);
119119
} else {
120-
error_setg_errno(errp, errno, "failed to read from '%s'",
121-
path);
122120
rc = EOF;
123121
}
124122

125123
free(value);
126-
g_free(path);
127124

128125
return rc;
129126
}

0 commit comments

Comments
 (0)