qmp hmp: Consistently name Error * objects err, and not errp

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
Markus Armbruster 2014-05-02 13:26:29 +02:00 committed by Luiz Capitulino
parent 636713bad4
commit e940f543ae
9 changed files with 240 additions and 240 deletions

View file

@ -308,12 +308,12 @@ Here's the implementation of the "hello-world" HMP command:
void hmp_hello_world(Monitor *mon, const QDict *qdict) void hmp_hello_world(Monitor *mon, const QDict *qdict)
{ {
const char *message = qdict_get_try_str(qdict, "message"); const char *message = qdict_get_try_str(qdict, "message");
Error *errp = NULL; Error *err = NULL;
qmp_hello_world(!!message, message, &errp); qmp_hello_world(!!message, message, &err);
if (errp) { if (err) {
monitor_printf(mon, "%s\n", error_get_pretty(errp)); monitor_printf(mon, "%s\n", error_get_pretty(err));
error_free(errp); error_free(err);
return; return;
} }
} }
@ -328,7 +328,7 @@ There are three important points to be noticed:
2. hmp_hello_world() performs error checking. In this example we just print 2. hmp_hello_world() performs error checking. In this example we just print
the error description to the user, but we could do more, like taking the error description to the user, but we could do more, like taking
different actions depending on the error qmp_hello_world() returns different actions depending on the error qmp_hello_world() returns
3. The "errp" variable must be initialized to NULL before performing the 3. The "err" variable must be initialized to NULL before performing the
QMP call QMP call
There's one last step to actually make the command available to monitor users, There's one last step to actually make the command available to monitor users,
@ -480,12 +480,12 @@ Here's the HMP counterpart of the query-alarm-clock command:
void hmp_info_alarm_clock(Monitor *mon) void hmp_info_alarm_clock(Monitor *mon)
{ {
QemuAlarmClock *clock; QemuAlarmClock *clock;
Error *errp = NULL; Error *err = NULL;
clock = qmp_query_alarm_clock(&errp); clock = qmp_query_alarm_clock(&err);
if (errp) { if (err) {
monitor_printf(mon, "Could not query alarm clock information\n"); monitor_printf(mon, "Could not query alarm clock information\n");
error_free(errp); error_free(err);
return; return;
} }
@ -631,12 +631,12 @@ has to traverse the list, it's shown below for reference:
void hmp_info_alarm_methods(Monitor *mon) void hmp_info_alarm_methods(Monitor *mon)
{ {
TimerAlarmMethodList *method_list, *method; TimerAlarmMethodList *method_list, *method;
Error *errp = NULL; Error *err = NULL;
method_list = qmp_query_alarm_methods(&errp); method_list = qmp_query_alarm_methods(&err);
if (errp) { if (err) {
monitor_printf(mon, "Could not query alarm methods\n"); monitor_printf(mon, "Could not query alarm methods\n");
error_free(errp); error_free(err);
return; return;
} }

138
hmp.c
View file

@ -754,10 +754,10 @@ void hmp_memsave(Monitor *mon, const QDict *qdict)
uint32_t size = qdict_get_int(qdict, "size"); uint32_t size = qdict_get_int(qdict, "size");
const char *filename = qdict_get_str(qdict, "filename"); const char *filename = qdict_get_str(qdict, "filename");
uint64_t addr = qdict_get_int(qdict, "val"); uint64_t addr = qdict_get_int(qdict, "val");
Error *errp = NULL; Error *err = NULL;
qmp_memsave(addr, size, filename, true, monitor_get_cpu_index(), &errp); qmp_memsave(addr, size, filename, true, monitor_get_cpu_index(), &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_pmemsave(Monitor *mon, const QDict *qdict) void hmp_pmemsave(Monitor *mon, const QDict *qdict)
@ -765,21 +765,21 @@ void hmp_pmemsave(Monitor *mon, const QDict *qdict)
uint32_t size = qdict_get_int(qdict, "size"); uint32_t size = qdict_get_int(qdict, "size");
const char *filename = qdict_get_str(qdict, "filename"); const char *filename = qdict_get_str(qdict, "filename");
uint64_t addr = qdict_get_int(qdict, "val"); uint64_t addr = qdict_get_int(qdict, "val");
Error *errp = NULL; Error *err = NULL;
qmp_pmemsave(addr, size, filename, &errp); qmp_pmemsave(addr, size, filename, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_ringbuf_write(Monitor *mon, const QDict *qdict) void hmp_ringbuf_write(Monitor *mon, const QDict *qdict)
{ {
const char *chardev = qdict_get_str(qdict, "device"); const char *chardev = qdict_get_str(qdict, "device");
const char *data = qdict_get_str(qdict, "data"); const char *data = qdict_get_str(qdict, "data");
Error *errp = NULL; Error *err = NULL;
qmp_ringbuf_write(chardev, data, false, 0, &errp); qmp_ringbuf_write(chardev, data, false, 0, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_ringbuf_read(Monitor *mon, const QDict *qdict) void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
@ -787,13 +787,13 @@ void hmp_ringbuf_read(Monitor *mon, const QDict *qdict)
uint32_t size = qdict_get_int(qdict, "size"); uint32_t size = qdict_get_int(qdict, "size");
const char *chardev = qdict_get_str(qdict, "device"); const char *chardev = qdict_get_str(qdict, "device");
char *data; char *data;
Error *errp = NULL; Error *err = NULL;
int i; int i;
data = qmp_ringbuf_read(chardev, size, false, 0, &errp); data = qmp_ringbuf_read(chardev, size, false, 0, &err);
if (errp) { if (err) {
monitor_printf(mon, "%s\n", error_get_pretty(errp)); monitor_printf(mon, "%s\n", error_get_pretty(err));
error_free(errp); error_free(err);
return; return;
} }
@ -828,7 +828,7 @@ static bool key_is_missing(const BlockInfo *bdev)
void hmp_cont(Monitor *mon, const QDict *qdict) void hmp_cont(Monitor *mon, const QDict *qdict)
{ {
BlockInfoList *bdev_list, *bdev; BlockInfoList *bdev_list, *bdev;
Error *errp = NULL; Error *err = NULL;
bdev_list = qmp_query_block(NULL); bdev_list = qmp_query_block(NULL);
for (bdev = bdev_list; bdev; bdev = bdev->next) { for (bdev = bdev_list; bdev; bdev = bdev->next) {
@ -839,8 +839,8 @@ void hmp_cont(Monitor *mon, const QDict *qdict)
} }
} }
qmp_cont(&errp); qmp_cont(&err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
out: out:
qapi_free_BlockInfoList(bdev_list); qapi_free_BlockInfoList(bdev_list);
@ -853,41 +853,41 @@ void hmp_system_wakeup(Monitor *mon, const QDict *qdict)
void hmp_inject_nmi(Monitor *mon, const QDict *qdict) void hmp_inject_nmi(Monitor *mon, const QDict *qdict)
{ {
Error *errp = NULL; Error *err = NULL;
qmp_inject_nmi(&errp); qmp_inject_nmi(&err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_set_link(Monitor *mon, const QDict *qdict) void hmp_set_link(Monitor *mon, const QDict *qdict)
{ {
const char *name = qdict_get_str(qdict, "name"); const char *name = qdict_get_str(qdict, "name");
int up = qdict_get_bool(qdict, "up"); int up = qdict_get_bool(qdict, "up");
Error *errp = NULL; Error *err = NULL;
qmp_set_link(name, up, &errp); qmp_set_link(name, up, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_block_passwd(Monitor *mon, const QDict *qdict) void hmp_block_passwd(Monitor *mon, const QDict *qdict)
{ {
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
const char *password = qdict_get_str(qdict, "password"); const char *password = qdict_get_str(qdict, "password");
Error *errp = NULL; Error *err = NULL;
qmp_block_passwd(true, device, false, NULL, password, &errp); qmp_block_passwd(true, device, false, NULL, password, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_balloon(Monitor *mon, const QDict *qdict) void hmp_balloon(Monitor *mon, const QDict *qdict)
{ {
int64_t value = qdict_get_int(qdict, "value"); int64_t value = qdict_get_int(qdict, "value");
Error *errp = NULL; Error *err = NULL;
qmp_balloon(value, &errp); qmp_balloon(value, &err);
if (errp) { if (err) {
monitor_printf(mon, "balloon: %s\n", error_get_pretty(errp)); monitor_printf(mon, "balloon: %s\n", error_get_pretty(err));
error_free(errp); error_free(err);
} }
} }
@ -895,10 +895,10 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
{ {
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
int64_t size = qdict_get_int(qdict, "size"); int64_t size = qdict_get_int(qdict, "size");
Error *errp = NULL; Error *err = NULL;
qmp_block_resize(true, device, false, NULL, size, &errp); qmp_block_resize(true, device, false, NULL, size, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_drive_mirror(Monitor *mon, const QDict *qdict) void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
@ -909,11 +909,11 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
int reuse = qdict_get_try_bool(qdict, "reuse", 0); int reuse = qdict_get_try_bool(qdict, "reuse", 0);
int full = qdict_get_try_bool(qdict, "full", 0); int full = qdict_get_try_bool(qdict, "full", 0);
enum NewImageMode mode; enum NewImageMode mode;
Error *errp = NULL; Error *err = NULL;
if (!filename) { if (!filename) {
error_set(&errp, QERR_MISSING_PARAMETER, "target"); error_set(&err, QERR_MISSING_PARAMETER, "target");
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
return; return;
} }
@ -926,8 +926,8 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
qmp_drive_mirror(device, filename, !!format, format, qmp_drive_mirror(device, filename, !!format, format,
full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
true, mode, false, 0, false, 0, false, 0, true, mode, false, 0, false, 0, false, 0,
false, 0, false, 0, &errp); false, 0, false, 0, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_drive_backup(Monitor *mon, const QDict *qdict) void hmp_drive_backup(Monitor *mon, const QDict *qdict)
@ -938,11 +938,11 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
int reuse = qdict_get_try_bool(qdict, "reuse", 0); int reuse = qdict_get_try_bool(qdict, "reuse", 0);
int full = qdict_get_try_bool(qdict, "full", 0); int full = qdict_get_try_bool(qdict, "full", 0);
enum NewImageMode mode; enum NewImageMode mode;
Error *errp = NULL; Error *err = NULL;
if (!filename) { if (!filename) {
error_set(&errp, QERR_MISSING_PARAMETER, "target"); error_set(&err, QERR_MISSING_PARAMETER, "target");
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
return; return;
} }
@ -954,8 +954,8 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
qmp_drive_backup(device, filename, !!format, format, qmp_drive_backup(device, filename, !!format, format,
full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
true, mode, false, 0, false, 0, false, 0, &errp); true, mode, false, 0, false, 0, false, 0, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict) void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
@ -965,13 +965,13 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
const char *format = qdict_get_try_str(qdict, "format"); const char *format = qdict_get_try_str(qdict, "format");
int reuse = qdict_get_try_bool(qdict, "reuse", 0); int reuse = qdict_get_try_bool(qdict, "reuse", 0);
enum NewImageMode mode; enum NewImageMode mode;
Error *errp = NULL; Error *err = NULL;
if (!filename) { if (!filename) {
/* In the future, if 'snapshot-file' is not specified, the snapshot /* In the future, if 'snapshot-file' is not specified, the snapshot
will be taken internally. Today it's actually required. */ will be taken internally. Today it's actually required. */
error_set(&errp, QERR_MISSING_PARAMETER, "snapshot-file"); error_set(&err, QERR_MISSING_PARAMETER, "snapshot-file");
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
return; return;
} }
@ -979,18 +979,18 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
qmp_blockdev_snapshot_sync(true, device, false, NULL, qmp_blockdev_snapshot_sync(true, device, false, NULL,
filename, false, NULL, filename, false, NULL,
!!format, format, !!format, format,
true, mode, &errp); true, mode, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict) void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
{ {
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
const char *name = qdict_get_str(qdict, "name"); const char *name = qdict_get_str(qdict, "name");
Error *errp = NULL; Error *err = NULL;
qmp_blockdev_snapshot_internal_sync(device, name, &errp); qmp_blockdev_snapshot_internal_sync(device, name, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict) void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
@ -998,11 +998,11 @@ void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
const char *device = qdict_get_str(qdict, "device"); const char *device = qdict_get_str(qdict, "device");
const char *name = qdict_get_str(qdict, "name"); const char *name = qdict_get_str(qdict, "name");
const char *id = qdict_get_try_str(qdict, "id"); const char *id = qdict_get_try_str(qdict, "id");
Error *errp = NULL; Error *err = NULL;
qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id, qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
true, name, &errp); true, name, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_migrate_cancel(Monitor *mon, const QDict *qdict) void hmp_migrate_cancel(Monitor *mon, const QDict *qdict)
@ -1310,7 +1310,7 @@ void hmp_device_del(Monitor *mon, const QDict *qdict)
void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
{ {
Error *errp = NULL; Error *err = NULL;
int paging = qdict_get_try_bool(qdict, "paging", 0); int paging = qdict_get_try_bool(qdict, "paging", 0);
int zlib = qdict_get_try_bool(qdict, "zlib", 0); int zlib = qdict_get_try_bool(qdict, "zlib", 0);
int lzo = qdict_get_try_bool(qdict, "lzo", 0); int lzo = qdict_get_try_bool(qdict, "lzo", 0);
@ -1324,8 +1324,8 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
char *prot; char *prot;
if (zlib + lzo + snappy > 1) { if (zlib + lzo + snappy > 1) {
error_setg(&errp, "only one of '-z|-l|-s' can be set"); error_setg(&err, "only one of '-z|-l|-s' can be set");
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
return; return;
} }
@ -1351,8 +1351,8 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
prot = g_strconcat("file:", file, NULL); prot = g_strconcat("file:", file, NULL);
qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length, qmp_dump_guest_memory(paging, prot, has_begin, begin, has_length, length,
true, dump_format, &errp); true, dump_format, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
g_free(prot); g_free(prot);
} }
@ -1444,19 +1444,19 @@ out:
void hmp_getfd(Monitor *mon, const QDict *qdict) void hmp_getfd(Monitor *mon, const QDict *qdict)
{ {
const char *fdname = qdict_get_str(qdict, "fdname"); const char *fdname = qdict_get_str(qdict, "fdname");
Error *errp = NULL; Error *err = NULL;
qmp_getfd(fdname, &errp); qmp_getfd(fdname, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_closefd(Monitor *mon, const QDict *qdict) void hmp_closefd(Monitor *mon, const QDict *qdict)
{ {
const char *fdname = qdict_get_str(qdict, "fdname"); const char *fdname = qdict_get_str(qdict, "fdname");
Error *errp = NULL; Error *err = NULL;
qmp_closefd(fdname, &errp); qmp_closefd(fdname, &err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_send_key(Monitor *mon, const QDict *qdict) void hmp_send_key(Monitor *mon, const QDict *qdict)
@ -1606,10 +1606,10 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict) void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
{ {
Error *errp = NULL; Error *err = NULL;
qmp_nbd_server_stop(&errp); qmp_nbd_server_stop(&err);
hmp_handle_error(mon, &errp); hmp_handle_error(mon, &err);
} }
void hmp_cpu_add(Monitor *mon, const QDict *qdict) void hmp_cpu_add(Monitor *mon, const QDict *qdict)

View file

@ -50,7 +50,7 @@ void qmp_enable_command(const char *name);
bool qmp_command_is_enabled(const QmpCommand *cmd); bool qmp_command_is_enabled(const QmpCommand *cmd);
const char *qmp_command_name(const QmpCommand *cmd); const char *qmp_command_name(const QmpCommand *cmd);
bool qmp_has_success_response(const QmpCommand *cmd); bool qmp_has_success_response(const QmpCommand *cmd);
QObject *qmp_build_error_object(Error *errp); QObject *qmp_build_error_object(Error *err);
typedef void (*qmp_cmd_callback_fn)(QmpCommand *cmd, void *opaque); typedef void (*qmp_cmd_callback_fn)(QmpCommand *cmd, void *opaque);
void qmp_for_each_command(qmp_cmd_callback_fn fn, void *opaque); void qmp_for_each_command(qmp_cmd_callback_fn fn, void *opaque);

View file

@ -110,11 +110,11 @@ static QObject *do_qmp_dispatch(QObject *request, Error **errp)
return ret; return ret;
} }
QObject *qmp_build_error_object(Error *errp) QObject *qmp_build_error_object(Error *err)
{ {
return qobject_from_jsonf("{ 'class': %s, 'desc': %s }", return qobject_from_jsonf("{ 'class': %s, 'desc': %s }",
ErrorClass_lookup[error_get_class(errp)], ErrorClass_lookup[error_get_class(err)],
error_get_pretty(errp)); error_get_pretty(err));
} }
QObject *qmp_dispatch(QObject *request) QObject *qmp_dispatch(QObject *request)

View file

@ -86,13 +86,13 @@ static void test_validate_struct(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
TestStruct *p = NULL; TestStruct *p = NULL;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }"); v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
visit_type_TestStruct(v, &p, NULL, &errp); visit_type_TestStruct(v, &p, NULL, &err);
g_assert(!errp); g_assert(!err);
g_free(p->string); g_free(p->string);
g_free(p); g_free(p);
} }
@ -101,13 +101,13 @@ static void test_validate_struct_nested(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
UserDefNested *udp = NULL; UserDefNested *udp = NULL;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = validate_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string' }, 'string2': 'string2'}}}"); v = validate_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string' }, 'string2': 'string2'}}}");
visit_type_UserDefNested(v, &udp, NULL, &errp); visit_type_UserDefNested(v, &udp, NULL, &err);
g_assert(!errp); g_assert(!err);
qapi_free_UserDefNested(udp); qapi_free_UserDefNested(udp);
} }
@ -115,13 +115,13 @@ static void test_validate_list(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
UserDefOneList *head = NULL; UserDefOneList *head = NULL;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44 } ]"); v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44 } ]");
visit_type_UserDefOneList(v, &head, NULL, &errp); visit_type_UserDefOneList(v, &head, NULL, &err);
g_assert(!errp); g_assert(!err);
qapi_free_UserDefOneList(head); qapi_free_UserDefOneList(head);
} }
@ -130,12 +130,12 @@ static void test_validate_union(TestInputVisitorData *data,
{ {
UserDefUnion *tmp = NULL; UserDefUnion *tmp = NULL;
Visitor *v; Visitor *v;
Error *errp = NULL; Error *err = NULL;
v = validate_test_init(data, "{ 'type': 'b', 'integer': 41, 'data' : { 'integer': 42 } }"); v = validate_test_init(data, "{ 'type': 'b', 'integer': 41, 'data' : { 'integer': 42 } }");
visit_type_UserDefUnion(v, &tmp, NULL, &errp); visit_type_UserDefUnion(v, &tmp, NULL, &err);
g_assert(!errp); g_assert(!err);
qapi_free_UserDefUnion(tmp); qapi_free_UserDefUnion(tmp);
} }
@ -144,7 +144,7 @@ static void test_validate_union_flat(TestInputVisitorData *data,
{ {
UserDefFlatUnion *tmp = NULL; UserDefFlatUnion *tmp = NULL;
Visitor *v; Visitor *v;
Error *errp = NULL; Error *err = NULL;
v = validate_test_init(data, v = validate_test_init(data,
"{ 'enum1': 'value1', " "{ 'enum1': 'value1', "
@ -152,8 +152,8 @@ static void test_validate_union_flat(TestInputVisitorData *data,
"'boolean': true }"); "'boolean': true }");
/* TODO when generator bug is fixed, add 'integer': 41 */ /* TODO when generator bug is fixed, add 'integer': 41 */
visit_type_UserDefFlatUnion(v, &tmp, NULL, &errp); visit_type_UserDefFlatUnion(v, &tmp, NULL, &err);
g_assert(!errp); g_assert(!err);
qapi_free_UserDefFlatUnion(tmp); qapi_free_UserDefFlatUnion(tmp);
} }
@ -162,12 +162,12 @@ static void test_validate_union_anon(TestInputVisitorData *data,
{ {
UserDefAnonUnion *tmp = NULL; UserDefAnonUnion *tmp = NULL;
Visitor *v; Visitor *v;
Error *errp = NULL; Error *err = NULL;
v = validate_test_init(data, "42"); v = validate_test_init(data, "42");
visit_type_UserDefAnonUnion(v, &tmp, NULL, &errp); visit_type_UserDefAnonUnion(v, &tmp, NULL, &err);
g_assert(!errp); g_assert(!err);
qapi_free_UserDefAnonUnion(tmp); qapi_free_UserDefAnonUnion(tmp);
} }
@ -175,13 +175,13 @@ static void test_validate_fail_struct(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
TestStruct *p = NULL; TestStruct *p = NULL;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo', 'extra': 42 }"); v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo', 'extra': 42 }");
visit_type_TestStruct(v, &p, NULL, &errp); visit_type_TestStruct(v, &p, NULL, &err);
g_assert(errp); g_assert(err);
if (p) { if (p) {
g_free(p->string); g_free(p->string);
} }
@ -192,13 +192,13 @@ static void test_validate_fail_struct_nested(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
UserDefNested *udp = NULL; UserDefNested *udp = NULL;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = validate_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}"); v = validate_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}");
visit_type_UserDefNested(v, &udp, NULL, &errp); visit_type_UserDefNested(v, &udp, NULL, &err);
g_assert(errp); g_assert(err);
qapi_free_UserDefNested(udp); qapi_free_UserDefNested(udp);
} }
@ -206,13 +206,13 @@ static void test_validate_fail_list(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
UserDefOneList *head = NULL; UserDefOneList *head = NULL;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]"); v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44, 'extra': 'ggg' } ]");
visit_type_UserDefOneList(v, &head, NULL, &errp); visit_type_UserDefOneList(v, &head, NULL, &err);
g_assert(errp); g_assert(err);
qapi_free_UserDefOneList(head); qapi_free_UserDefOneList(head);
} }
@ -220,13 +220,13 @@ static void test_validate_fail_union(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
UserDefUnion *tmp = NULL; UserDefUnion *tmp = NULL;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = validate_test_init(data, "{ 'type': 'b', 'data' : { 'integer': 42 } }"); v = validate_test_init(data, "{ 'type': 'b', 'data' : { 'integer': 42 } }");
visit_type_UserDefUnion(v, &tmp, NULL, &errp); visit_type_UserDefUnion(v, &tmp, NULL, &err);
g_assert(errp); g_assert(err);
qapi_free_UserDefUnion(tmp); qapi_free_UserDefUnion(tmp);
} }
@ -234,13 +234,13 @@ static void test_validate_fail_union_flat(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
UserDefFlatUnion *tmp = NULL; UserDefFlatUnion *tmp = NULL;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = validate_test_init(data, "{ 'string': 'c', 'integer': 41, 'boolean': true }"); v = validate_test_init(data, "{ 'string': 'c', 'integer': 41, 'boolean': true }");
visit_type_UserDefFlatUnion(v, &tmp, NULL, &errp); visit_type_UserDefFlatUnion(v, &tmp, NULL, &err);
g_assert(errp); g_assert(err);
qapi_free_UserDefFlatUnion(tmp); qapi_free_UserDefFlatUnion(tmp);
} }
@ -249,12 +249,12 @@ static void test_validate_fail_union_anon(TestInputVisitorData *data,
{ {
UserDefAnonUnion *tmp = NULL; UserDefAnonUnion *tmp = NULL;
Visitor *v; Visitor *v;
Error *errp = NULL; Error *err = NULL;
v = validate_test_init(data, "3.14"); v = validate_test_init(data, "3.14");
visit_type_UserDefAnonUnion(v, &tmp, NULL, &errp); visit_type_UserDefAnonUnion(v, &tmp, NULL, &err);
g_assert(errp); g_assert(err);
qapi_free_UserDefAnonUnion(tmp); qapi_free_UserDefAnonUnion(tmp);
} }

View file

@ -90,13 +90,13 @@ static void test_visitor_in_int(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
int64_t res = 0, value = -42; int64_t res = 0, value = -42;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = visitor_input_test_init(data, "%" PRId64, value); v = visitor_input_test_init(data, "%" PRId64, value);
visit_type_int(v, &res, NULL, &errp); visit_type_int(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpint(res, ==, value); g_assert_cmpint(res, ==, value);
} }
@ -104,7 +104,7 @@ static void test_visitor_in_int_overflow(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
int64_t res = 0; int64_t res = 0;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
/* this will overflow a Qint/int64, so should be deserialized into /* this will overflow a Qint/int64, so should be deserialized into
@ -113,22 +113,22 @@ static void test_visitor_in_int_overflow(TestInputVisitorData *data,
*/ */
v = visitor_input_test_init(data, "%f", DBL_MAX); v = visitor_input_test_init(data, "%f", DBL_MAX);
visit_type_int(v, &res, NULL, &errp); visit_type_int(v, &res, NULL, &err);
g_assert(errp); g_assert(err);
error_free(errp); error_free(err);
} }
static void test_visitor_in_bool(TestInputVisitorData *data, static void test_visitor_in_bool(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
Error *errp = NULL; Error *err = NULL;
bool res = false; bool res = false;
Visitor *v; Visitor *v;
v = visitor_input_test_init(data, "true"); v = visitor_input_test_init(data, "true");
visit_type_bool(v, &res, NULL, &errp); visit_type_bool(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpint(res, ==, true); g_assert_cmpint(res, ==, true);
} }
@ -136,13 +136,13 @@ static void test_visitor_in_number(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
double res = 0, value = 3.14; double res = 0, value = 3.14;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = visitor_input_test_init(data, "%f", value); v = visitor_input_test_init(data, "%f", value);
visit_type_number(v, &res, NULL, &errp); visit_type_number(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpfloat(res, ==, value); g_assert_cmpfloat(res, ==, value);
} }
@ -150,13 +150,13 @@ static void test_visitor_in_string(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
char *res = NULL, *value = (char *) "Q E M U"; char *res = NULL, *value = (char *) "Q E M U";
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = visitor_input_test_init(data, "%s", value); v = visitor_input_test_init(data, "%s", value);
visit_type_str(v, &res, NULL, &errp); visit_type_str(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpstr(res, ==, value); g_assert_cmpstr(res, ==, value);
g_free(res); g_free(res);
@ -165,7 +165,7 @@ static void test_visitor_in_string(TestInputVisitorData *data,
static void test_visitor_in_enum(TestInputVisitorData *data, static void test_visitor_in_enum(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
EnumOne i; EnumOne i;
@ -174,8 +174,8 @@ static void test_visitor_in_enum(TestInputVisitorData *data,
v = visitor_input_test_init(data, "%s", EnumOne_lookup[i]); v = visitor_input_test_init(data, "%s", EnumOne_lookup[i]);
visit_type_EnumOne(v, &res, NULL, &errp); visit_type_EnumOne(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpint(i, ==, res); g_assert_cmpint(i, ==, res);
visitor_input_teardown(data, NULL); visitor_input_teardown(data, NULL);
@ -217,13 +217,13 @@ static void test_visitor_in_struct(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
TestStruct *p = NULL; TestStruct *p = NULL;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }"); v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
visit_type_TestStruct(v, &p, NULL, &errp); visit_type_TestStruct(v, &p, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpint(p->integer, ==, -42); g_assert_cmpint(p->integer, ==, -42);
g_assert(p->boolean == true); g_assert(p->boolean == true);
g_assert_cmpstr(p->string, ==, "foo"); g_assert_cmpstr(p->string, ==, "foo");
@ -242,13 +242,13 @@ static void test_visitor_in_struct_nested(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
UserDefNested *udp = NULL; UserDefNested *udp = NULL;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = visitor_input_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string' }, 'string2': 'string2'}}}"); v = visitor_input_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string' }, 'string2': 'string2'}}}");
visit_type_UserDefNested(v, &udp, NULL, &errp); visit_type_UserDefNested(v, &udp, NULL, &err);
g_assert(!errp); g_assert(!err);
check_and_free_str(udp->string0, "string0"); check_and_free_str(udp->string0, "string0");
check_and_free_str(udp->dict1.string1, "string1"); check_and_free_str(udp->dict1.string1, "string1");
@ -265,14 +265,14 @@ static void test_visitor_in_list(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
UserDefOneList *item, *head = NULL; UserDefOneList *item, *head = NULL;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
int i; int i;
v = visitor_input_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44 } ]"); v = visitor_input_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44 } ]");
visit_type_UserDefOneList(v, &head, NULL, &errp); visit_type_UserDefOneList(v, &head, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert(head != NULL); g_assert(head != NULL);
for (i = 0, item = head; item; item = item->next, i++) { for (i = 0, item = head; item; item = item->next, i++) {
@ -634,16 +634,16 @@ static void test_visitor_in_errors(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
TestStruct *p = NULL; TestStruct *p = NULL;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = visitor_input_test_init(data, "{ 'integer': false, 'boolean': 'foo', 'string': -42 }"); v = visitor_input_test_init(data, "{ 'integer': false, 'boolean': 'foo', 'string': -42 }");
visit_type_TestStruct(v, &p, NULL, &errp); visit_type_TestStruct(v, &p, NULL, &err);
g_assert(errp); g_assert(err);
g_assert(p->string == NULL); g_assert(p->string == NULL);
error_free(errp); error_free(err);
g_free(p->string); g_free(p->string);
g_free(p); g_free(p);
} }

View file

@ -45,11 +45,11 @@ static void test_visitor_out_int(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
int64_t value = -42; int64_t value = -42;
Error *errp = NULL; Error *err = NULL;
QObject *obj; QObject *obj;
visit_type_int(data->ov, &value, NULL, &errp); visit_type_int(data->ov, &value, NULL, &err);
g_assert(!errp); g_assert(!err);
obj = qmp_output_get_qobject(data->qov); obj = qmp_output_get_qobject(data->qov);
g_assert(obj != NULL); g_assert(obj != NULL);
@ -62,12 +62,12 @@ static void test_visitor_out_int(TestOutputVisitorData *data,
static void test_visitor_out_bool(TestOutputVisitorData *data, static void test_visitor_out_bool(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
Error *errp = NULL; Error *err = NULL;
bool value = true; bool value = true;
QObject *obj; QObject *obj;
visit_type_bool(data->ov, &value, NULL, &errp); visit_type_bool(data->ov, &value, NULL, &err);
g_assert(!errp); g_assert(!err);
obj = qmp_output_get_qobject(data->qov); obj = qmp_output_get_qobject(data->qov);
g_assert(obj != NULL); g_assert(obj != NULL);
@ -81,11 +81,11 @@ static void test_visitor_out_number(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
double value = 3.14; double value = 3.14;
Error *errp = NULL; Error *err = NULL;
QObject *obj; QObject *obj;
visit_type_number(data->ov, &value, NULL, &errp); visit_type_number(data->ov, &value, NULL, &err);
g_assert(!errp); g_assert(!err);
obj = qmp_output_get_qobject(data->qov); obj = qmp_output_get_qobject(data->qov);
g_assert(obj != NULL); g_assert(obj != NULL);
@ -99,11 +99,11 @@ static void test_visitor_out_string(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
char *string = (char *) "Q E M U"; char *string = (char *) "Q E M U";
Error *errp = NULL; Error *err = NULL;
QObject *obj; QObject *obj;
visit_type_str(data->ov, &string, NULL, &errp); visit_type_str(data->ov, &string, NULL, &err);
g_assert(!errp); g_assert(!err);
obj = qmp_output_get_qobject(data->qov); obj = qmp_output_get_qobject(data->qov);
g_assert(obj != NULL); g_assert(obj != NULL);
@ -117,12 +117,12 @@ static void test_visitor_out_no_string(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
char *string = NULL; char *string = NULL;
Error *errp = NULL; Error *err = NULL;
QObject *obj; QObject *obj;
/* A null string should return "" */ /* A null string should return "" */
visit_type_str(data->ov, &string, NULL, &errp); visit_type_str(data->ov, &string, NULL, &err);
g_assert(!errp); g_assert(!err);
obj = qmp_output_get_qobject(data->qov); obj = qmp_output_get_qobject(data->qov);
g_assert(obj != NULL); g_assert(obj != NULL);
@ -135,13 +135,13 @@ static void test_visitor_out_no_string(TestOutputVisitorData *data,
static void test_visitor_out_enum(TestOutputVisitorData *data, static void test_visitor_out_enum(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
Error *errp = NULL; Error *err = NULL;
QObject *obj; QObject *obj;
EnumOne i; EnumOne i;
for (i = 0; i < ENUM_ONE_MAX; i++) { for (i = 0; i < ENUM_ONE_MAX; i++) {
visit_type_EnumOne(data->ov, &i, "unused", &errp); visit_type_EnumOne(data->ov, &i, "unused", &err);
g_assert(!errp); g_assert(!err);
obj = qmp_output_get_qobject(data->qov); obj = qmp_output_get_qobject(data->qov);
g_assert(obj != NULL); g_assert(obj != NULL);
@ -156,13 +156,13 @@ static void test_visitor_out_enum_errors(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
EnumOne i, bad_values[] = { ENUM_ONE_MAX, -1 }; EnumOne i, bad_values[] = { ENUM_ONE_MAX, -1 };
Error *errp; Error *err;
for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) { for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
errp = NULL; err = NULL;
visit_type_EnumOne(data->ov, &bad_values[i], "unused", &errp); visit_type_EnumOne(data->ov, &bad_values[i], "unused", &err);
g_assert(errp); g_assert(err);
error_free(errp); error_free(err);
} }
} }
@ -193,12 +193,12 @@ static void test_visitor_out_struct(TestOutputVisitorData *data,
.boolean = false, .boolean = false,
.string = (char *) "foo"}; .string = (char *) "foo"};
TestStruct *p = &test_struct; TestStruct *p = &test_struct;
Error *errp = NULL; Error *err = NULL;
QObject *obj; QObject *obj;
QDict *qdict; QDict *qdict;
visit_type_TestStruct(data->ov, &p, NULL, &errp); visit_type_TestStruct(data->ov, &p, NULL, &err);
g_assert(!errp); g_assert(!err);
obj = qmp_output_get_qobject(data->qov); obj = qmp_output_get_qobject(data->qov);
g_assert(obj != NULL); g_assert(obj != NULL);
@ -217,7 +217,7 @@ static void test_visitor_out_struct_nested(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
int64_t value = 42; int64_t value = 42;
Error *errp = NULL; Error *err = NULL;
UserDefNested *ud2; UserDefNested *ud2;
QObject *obj; QObject *obj;
QDict *qdict, *dict1, *dict2, *dict3, *userdef; QDict *qdict, *dict1, *dict2, *dict3, *userdef;
@ -242,8 +242,8 @@ static void test_visitor_out_struct_nested(TestOutputVisitorData *data,
ud2->dict1.dict3.userdef2->base->integer = value; ud2->dict1.dict3.userdef2->base->integer = value;
ud2->dict1.dict3.string3 = g_strdup(strings[3]); ud2->dict1.dict3.string3 = g_strdup(strings[3]);
visit_type_UserDefNested(data->ov, &ud2, "unused", &errp); visit_type_UserDefNested(data->ov, &ud2, "unused", &err);
g_assert(!errp); g_assert(!err);
obj = qmp_output_get_qobject(data->qov); obj = qmp_output_get_qobject(data->qov);
g_assert(obj != NULL); g_assert(obj != NULL);
@ -283,16 +283,16 @@ static void test_visitor_out_struct_errors(TestOutputVisitorData *data,
EnumOne bad_values[] = { ENUM_ONE_MAX, -1 }; EnumOne bad_values[] = { ENUM_ONE_MAX, -1 };
UserDefZero b; UserDefZero b;
UserDefOne u = { .base = &b }, *pu = &u; UserDefOne u = { .base = &b }, *pu = &u;
Error *errp; Error *err;
int i; int i;
for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) { for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
errp = NULL; err = NULL;
u.has_enum1 = true; u.has_enum1 = true;
u.enum1 = bad_values[i]; u.enum1 = bad_values[i];
visit_type_UserDefOne(data->ov, &pu, "unused", &errp); visit_type_UserDefOne(data->ov, &pu, "unused", &err);
g_assert(errp); g_assert(err);
error_free(errp); error_free(err);
} }
} }
@ -328,7 +328,7 @@ static void test_visitor_out_list(TestOutputVisitorData *data,
const int max_items = 10; const int max_items = 10;
bool value_bool = true; bool value_bool = true;
int value_int = 10; int value_int = 10;
Error *errp = NULL; Error *err = NULL;
QListEntry *entry; QListEntry *entry;
QObject *obj; QObject *obj;
QList *qlist; QList *qlist;
@ -345,8 +345,8 @@ static void test_visitor_out_list(TestOutputVisitorData *data,
head = p; head = p;
} }
visit_type_TestStructList(data->ov, &head, NULL, &errp); visit_type_TestStructList(data->ov, &head, NULL, &err);
g_assert(!errp); g_assert(!err);
obj = qmp_output_get_qobject(data->qov); obj = qmp_output_get_qobject(data->qov);
g_assert(obj != NULL); g_assert(obj != NULL);

View file

@ -54,62 +54,62 @@ static void test_visitor_in_int(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
int64_t res = 0, value = -42; int64_t res = 0, value = -42;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = visitor_input_test_init(data, "-42"); v = visitor_input_test_init(data, "-42");
visit_type_int(v, &res, NULL, &errp); visit_type_int(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpint(res, ==, value); g_assert_cmpint(res, ==, value);
} }
static void test_visitor_in_bool(TestInputVisitorData *data, static void test_visitor_in_bool(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
Error *errp = NULL; Error *err = NULL;
bool res = false; bool res = false;
Visitor *v; Visitor *v;
v = visitor_input_test_init(data, "true"); v = visitor_input_test_init(data, "true");
visit_type_bool(v, &res, NULL, &errp); visit_type_bool(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpint(res, ==, true); g_assert_cmpint(res, ==, true);
visitor_input_teardown(data, unused); visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, "yes"); v = visitor_input_test_init(data, "yes");
visit_type_bool(v, &res, NULL, &errp); visit_type_bool(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpint(res, ==, true); g_assert_cmpint(res, ==, true);
visitor_input_teardown(data, unused); visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, "on"); v = visitor_input_test_init(data, "on");
visit_type_bool(v, &res, NULL, &errp); visit_type_bool(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpint(res, ==, true); g_assert_cmpint(res, ==, true);
visitor_input_teardown(data, unused); visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, "false"); v = visitor_input_test_init(data, "false");
visit_type_bool(v, &res, NULL, &errp); visit_type_bool(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpint(res, ==, false); g_assert_cmpint(res, ==, false);
visitor_input_teardown(data, unused); visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, "no"); v = visitor_input_test_init(data, "no");
visit_type_bool(v, &res, NULL, &errp); visit_type_bool(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpint(res, ==, false); g_assert_cmpint(res, ==, false);
visitor_input_teardown(data, unused); visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, "off"); v = visitor_input_test_init(data, "off");
visit_type_bool(v, &res, NULL, &errp); visit_type_bool(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpint(res, ==, false); g_assert_cmpint(res, ==, false);
} }
@ -117,13 +117,13 @@ static void test_visitor_in_number(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
double res = 0, value = 3.14; double res = 0, value = 3.14;
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = visitor_input_test_init(data, "3.14"); v = visitor_input_test_init(data, "3.14");
visit_type_number(v, &res, NULL, &errp); visit_type_number(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpfloat(res, ==, value); g_assert_cmpfloat(res, ==, value);
} }
@ -131,13 +131,13 @@ static void test_visitor_in_string(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
char *res = NULL, *value = (char *) "Q E M U"; char *res = NULL, *value = (char *) "Q E M U";
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
v = visitor_input_test_init(data, value); v = visitor_input_test_init(data, value);
visit_type_str(v, &res, NULL, &errp); visit_type_str(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpstr(res, ==, value); g_assert_cmpstr(res, ==, value);
g_free(res); g_free(res);
@ -146,7 +146,7 @@ static void test_visitor_in_string(TestInputVisitorData *data,
static void test_visitor_in_enum(TestInputVisitorData *data, static void test_visitor_in_enum(TestInputVisitorData *data,
const void *unused) const void *unused)
{ {
Error *errp = NULL; Error *err = NULL;
Visitor *v; Visitor *v;
EnumOne i; EnumOne i;
@ -155,8 +155,8 @@ static void test_visitor_in_enum(TestInputVisitorData *data,
v = visitor_input_test_init(data, EnumOne_lookup[i]); v = visitor_input_test_init(data, EnumOne_lookup[i]);
visit_type_EnumOne(v, &res, NULL, &errp); visit_type_EnumOne(v, &res, NULL, &err);
g_assert(!errp); g_assert(!err);
g_assert_cmpint(i, ==, res); g_assert_cmpint(i, ==, res);
visitor_input_teardown(data, NULL); visitor_input_teardown(data, NULL);

View file

@ -45,11 +45,11 @@ static void test_visitor_out_int(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
int64_t value = -42; int64_t value = -42;
Error *errp = NULL; Error *err = NULL;
char *str; char *str;
visit_type_int(data->ov, &value, NULL, &errp); visit_type_int(data->ov, &value, NULL, &err);
g_assert(!errp); g_assert(!err);
str = string_output_get_string(data->sov); str = string_output_get_string(data->sov);
g_assert(str != NULL); g_assert(str != NULL);
@ -60,12 +60,12 @@ static void test_visitor_out_int(TestOutputVisitorData *data,
static void test_visitor_out_bool(TestOutputVisitorData *data, static void test_visitor_out_bool(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
Error *errp = NULL; Error *err = NULL;
bool value = true; bool value = true;
char *str; char *str;
visit_type_bool(data->ov, &value, NULL, &errp); visit_type_bool(data->ov, &value, NULL, &err);
g_assert(!errp); g_assert(!err);
str = string_output_get_string(data->sov); str = string_output_get_string(data->sov);
g_assert(str != NULL); g_assert(str != NULL);
@ -77,11 +77,11 @@ static void test_visitor_out_number(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
double value = 3.14; double value = 3.14;
Error *errp = NULL; Error *err = NULL;
char *str; char *str;
visit_type_number(data->ov, &value, NULL, &errp); visit_type_number(data->ov, &value, NULL, &err);
g_assert(!errp); g_assert(!err);
str = string_output_get_string(data->sov); str = string_output_get_string(data->sov);
g_assert(str != NULL); g_assert(str != NULL);
@ -93,11 +93,11 @@ static void test_visitor_out_string(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
char *string = (char *) "Q E M U"; char *string = (char *) "Q E M U";
Error *errp = NULL; Error *err = NULL;
char *str; char *str;
visit_type_str(data->ov, &string, NULL, &errp); visit_type_str(data->ov, &string, NULL, &err);
g_assert(!errp); g_assert(!err);
str = string_output_get_string(data->sov); str = string_output_get_string(data->sov);
g_assert(str != NULL); g_assert(str != NULL);
@ -109,12 +109,12 @@ static void test_visitor_out_no_string(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
char *string = NULL; char *string = NULL;
Error *errp = NULL; Error *err = NULL;
char *str; char *str;
/* A null string should return "" */ /* A null string should return "" */
visit_type_str(data->ov, &string, NULL, &errp); visit_type_str(data->ov, &string, NULL, &err);
g_assert(!errp); g_assert(!err);
str = string_output_get_string(data->sov); str = string_output_get_string(data->sov);
g_assert(str != NULL); g_assert(str != NULL);
@ -125,13 +125,13 @@ static void test_visitor_out_no_string(TestOutputVisitorData *data,
static void test_visitor_out_enum(TestOutputVisitorData *data, static void test_visitor_out_enum(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
Error *errp = NULL; Error *err = NULL;
char *str; char *str;
EnumOne i; EnumOne i;
for (i = 0; i < ENUM_ONE_MAX; i++) { for (i = 0; i < ENUM_ONE_MAX; i++) {
visit_type_EnumOne(data->ov, &i, "unused", &errp); visit_type_EnumOne(data->ov, &i, "unused", &err);
g_assert(!errp); g_assert(!err);
str = string_output_get_string(data->sov); str = string_output_get_string(data->sov);
g_assert(str != NULL); g_assert(str != NULL);
@ -144,13 +144,13 @@ static void test_visitor_out_enum_errors(TestOutputVisitorData *data,
const void *unused) const void *unused)
{ {
EnumOne i, bad_values[] = { ENUM_ONE_MAX, -1 }; EnumOne i, bad_values[] = { ENUM_ONE_MAX, -1 };
Error *errp; Error *err;
for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) { for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
errp = NULL; err = NULL;
visit_type_EnumOne(data->ov, &bad_values[i], "unused", &errp); visit_type_EnumOne(data->ov, &bad_values[i], "unused", &err);
g_assert(errp); g_assert(err);
error_free(errp); error_free(err);
} }
} }