Skip to content

Commit 60cc2eb

Browse files
elmarcoMarkus Armbruster
authored and
Markus Armbruster
committed
qlit: rename compare_litqobj_to_qobj() to qlit_equal_qobject()
compare_litqobj_to_qobj() lacks a qlit_ prefix. Moreover, "compare" suggests -1, 0, +1 for less than, equal and greater than. The function actually returns non-zero for equal, zero for unequal. Rename to qlit_equal_qobject(). Its return type will be cleaned up in the next patch. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20170825105913.4060-6-marcandre.lureau@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
1 parent d5cd8fb commit 60cc2eb

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

include/qapi/qmp/qlit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ struct QLitDictEntry {
4444
#define QLIT_QLIST(val) \
4545
{ .type = QTYPE_QLIST, .value.qlist = (val) }
4646

47-
int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs);
47+
int qlit_equal_qobject(QLitObject *lhs, QObject *rhs);
4848

4949
#endif /* QLIT_H */

qobject/qlit.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ static void compare_helper(QObject *obj, void *opaque)
3838
}
3939

4040
helper->result =
41-
compare_litqobj_to_qobj(&helper->objs[helper->index++], obj);
41+
qlit_equal_qobject(&helper->objs[helper->index++], obj);
4242
}
4343

44-
int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs)
44+
int qlit_equal_qobject(QLitObject *lhs, QObject *rhs)
4545
{
4646
int64_t val;
4747

@@ -63,7 +63,7 @@ int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs)
6363
QObject *obj = qdict_get(qobject_to_qdict(rhs),
6464
lhs->value.qdict[i].key);
6565

66-
if (!compare_litqobj_to_qobj(&lhs->value.qdict[i].value, obj)) {
66+
if (!qlit_equal_qobject(&lhs->value.qdict[i].value, obj)) {
6767
return 0;
6868
}
6969
}

tests/check-qjson.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -1094,13 +1094,13 @@ static void simple_dict(void)
10941094
QString *str;
10951095

10961096
obj = qobject_from_json(test_cases[i].encoded, &error_abort);
1097-
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
1097+
g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) == 1);
10981098

10991099
str = qobject_to_json(obj);
11001100
qobject_decref(obj);
11011101

11021102
obj = qobject_from_json(qstring_get_str(str), &error_abort);
1103-
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
1103+
g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) == 1);
11041104
qobject_decref(obj);
11051105
QDECREF(str);
11061106
}
@@ -1203,13 +1203,13 @@ static void simple_list(void)
12031203
QString *str;
12041204

12051205
obj = qobject_from_json(test_cases[i].encoded, &error_abort);
1206-
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
1206+
g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) == 1);
12071207

12081208
str = qobject_to_json(obj);
12091209
qobject_decref(obj);
12101210

12111211
obj = qobject_from_json(qstring_get_str(str), &error_abort);
1212-
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
1212+
g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) == 1);
12131213
qobject_decref(obj);
12141214
QDECREF(str);
12151215
}
@@ -1265,13 +1265,13 @@ static void simple_whitespace(void)
12651265
QString *str;
12661266

12671267
obj = qobject_from_json(test_cases[i].encoded, &error_abort);
1268-
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
1268+
g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) == 1);
12691269

12701270
str = qobject_to_json(obj);
12711271
qobject_decref(obj);
12721272

12731273
obj = qobject_from_json(qstring_get_str(str), &error_abort);
1274-
g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
1274+
g_assert(qlit_equal_qobject(&test_cases[i].decoded, obj) == 1);
12751275

12761276
qobject_decref(obj);
12771277
QDECREF(str);
@@ -1295,7 +1295,7 @@ static void simple_varargs(void)
12951295
g_assert(embedded_obj != NULL);
12961296

12971297
obj = qobject_from_jsonf("[%d, 2, %p]", 1, embedded_obj);
1298-
g_assert(compare_litqobj_to_qobj(&decoded, obj) == 1);
1298+
g_assert(qlit_equal_qobject(&decoded, obj) == 1);
12991299

13001300
qobject_decref(obj);
13011301
}

0 commit comments

Comments
 (0)