Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/812483/?format=api
{ "id": 812483, "url": "http://patchwork.ozlabs.org/api/patches/812483/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170911172022.4738-3-eblake@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170911172022.4738-3-eblake@redhat.com>", "list_archive_url": null, "date": "2017-09-11T17:19:46", "name": "[v7,02/38] qtest: Don't perform side effects inside assertion", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "57e37ff004b0661b731a5abb551067a6e2690cb1", "submitter": { "id": 6591, "url": "http://patchwork.ozlabs.org/api/people/6591/?format=api", "name": "Eric Blake", "email": "eblake@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170911172022.4738-3-eblake@redhat.com/mbox/", "series": [ { "id": 2534, "url": "http://patchwork.ozlabs.org/api/series/2534/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2534", "date": "2017-09-11T17:19:47", "name": "Preliminary libqtest cleanups", "version": 7, "mbox": "http://patchwork.ozlabs.org/series/2534/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/812483/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/812483/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com" ], "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrZmB4V4tz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 03:34:02 +1000 (AEST)", "from localhost ([::1]:59383 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drSau-0002T9-KG\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 13:34:00 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:38093)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1drSNt-0006qS-9C\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:20:35 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1drSNq-0000wo-UP\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:20:33 -0400", "from mx1.redhat.com ([209.132.183.28]:51226)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>) id 1drSNq-0000wV-LO\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:20:30 -0400", "from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id C0AFC169367\n\tfor <qemu-devel@nongnu.org>; Mon, 11 Sep 2017 17:20:29 +0000 (UTC)", "from red.redhat.com (ovpn-120-44.rdu2.redhat.com [10.10.120.44])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 6DA535D968;\n\tMon, 11 Sep 2017 17:20:28 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com C0AFC169367", "From": "Eric Blake <eblake@redhat.com>", "To": "qemu-devel@nongnu.org", "Date": "Mon, 11 Sep 2017 12:19:46 -0500", "Message-Id": "<20170911172022.4738-3-eblake@redhat.com>", "In-Reply-To": "<20170911172022.4738-1-eblake@redhat.com>", "References": "<20170911172022.4738-1-eblake@redhat.com>", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.14", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.39]);\n\tMon, 11 Sep 2017 17:20:29 +0000 (UTC)", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]", "X-Received-From": "209.132.183.28", "Subject": "[Qemu-devel] [PATCH v7 02/38] qtest: Don't perform side effects\n\tinside assertion", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "pbonzini@redhat.com, thuth@redhat.com, armbru@redhat.com", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "Assertions should be separate from the side effects, since in\ntheory, g_assert() can be disabled (in practice, we can't really\never do that).\n\nSigned-off-by: Eric Blake <eblake@redhat.com>\nReviewed-by: Thomas Huth <thuth@redhat.com>\n---\n qtest.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++-------------------\n 1 file changed, 57 insertions(+), 23 deletions(-)", "diff": "diff --git a/qtest.c b/qtest.c\nindex 88a09e9afc..cbbfb71114 100644\n--- a/qtest.c\n+++ b/qtest.c\n@@ -332,10 +332,13 @@ static void qtest_process_command(CharBackend *chr, gchar **words)\n strcmp(words[0], \"outl\") == 0) {\n unsigned long addr;\n unsigned long value;\n+ int ret;\n\n g_assert(words[1] && words[2]);\n- g_assert(qemu_strtoul(words[1], NULL, 0, &addr) == 0);\n- g_assert(qemu_strtoul(words[2], NULL, 0, &value) == 0);\n+ ret = qemu_strtoul(words[1], NULL, 0, &addr);\n+ g_assert(ret == 0);\n+ ret = qemu_strtoul(words[2], NULL, 0, &value);\n+ g_assert(ret == 0);\n g_assert(addr <= 0xffff);\n\n if (words[0][3] == 'b') {\n@@ -352,9 +355,11 @@ static void qtest_process_command(CharBackend *chr, gchar **words)\n strcmp(words[0], \"inl\") == 0) {\n unsigned long addr;\n uint32_t value = -1U;\n+ int ret;\n\n g_assert(words[1]);\n- g_assert(qemu_strtoul(words[1], NULL, 0, &addr) == 0);\n+ ret = qemu_strtoul(words[1], NULL, 0, &addr);\n+ g_assert(ret == 0);\n g_assert(addr <= 0xffff);\n\n if (words[0][2] == 'b') {\n@@ -372,10 +377,13 @@ static void qtest_process_command(CharBackend *chr, gchar **words)\n strcmp(words[0], \"writeq\") == 0) {\n uint64_t addr;\n uint64_t value;\n+ int ret;\n\n g_assert(words[1] && words[2]);\n- g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);\n- g_assert(qemu_strtou64(words[2], NULL, 0, &value) == 0);\n+ ret = qemu_strtou64(words[1], NULL, 0, &addr);\n+ g_assert(ret == 0);\n+ ret = qemu_strtou64(words[2], NULL, 0, &value);\n+ g_assert(ret == 0);\n\n if (words[0][5] == 'b') {\n uint8_t data = value;\n@@ -401,9 +409,11 @@ static void qtest_process_command(CharBackend *chr, gchar **words)\n strcmp(words[0], \"readq\") == 0) {\n uint64_t addr;\n uint64_t value = UINT64_C(-1);\n+ int ret;\n\n g_assert(words[1]);\n- g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);\n+ ret = qemu_strtou64(words[1], NULL, 0, &addr);\n+ g_assert(ret == 0);\n\n if (words[0][4] == 'b') {\n uint8_t data;\n@@ -427,10 +437,13 @@ static void qtest_process_command(CharBackend *chr, gchar **words)\n uint64_t addr, len, i;\n uint8_t *data;\n char *enc;\n+ int ret;\n\n g_assert(words[1] && words[2]);\n- g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);\n- g_assert(qemu_strtou64(words[2], NULL, 0, &len) == 0);\n+ ret = qemu_strtou64(words[1], NULL, 0, &addr);\n+ g_assert(ret == 0);\n+ ret = qemu_strtou64(words[2], NULL, 0, &len);\n+ g_assert(ret == 0);\n /* We'd send garbage to libqtest if len is 0 */\n g_assert(len);\n\n@@ -451,10 +464,13 @@ static void qtest_process_command(CharBackend *chr, gchar **words)\n uint64_t addr, len;\n uint8_t *data;\n gchar *b64_data;\n+ int ret;\n\n g_assert(words[1] && words[2]);\n- g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);\n- g_assert(qemu_strtou64(words[2], NULL, 0, &len) == 0);\n+ ret = qemu_strtou64(words[1], NULL, 0, &addr);\n+ g_assert(ret == 0);\n+ ret = qemu_strtou64(words[2], NULL, 0, &len);\n+ g_assert(ret == 0);\n\n data = g_malloc(len);\n cpu_physical_memory_read(addr, data, len);\n@@ -468,10 +484,13 @@ static void qtest_process_command(CharBackend *chr, gchar **words)\n uint64_t addr, len, i;\n uint8_t *data;\n size_t data_len;\n+ int ret;\n\n g_assert(words[1] && words[2] && words[3]);\n- g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);\n- g_assert(qemu_strtou64(words[2], NULL, 0, &len) == 0);\n+ ret = qemu_strtou64(words[1], NULL, 0, &addr);\n+ g_assert(ret == 0);\n+ ret = qemu_strtou64(words[2], NULL, 0, &len);\n+ g_assert(ret == 0);\n\n data_len = strlen(words[3]);\n if (data_len < 3) {\n@@ -497,11 +516,15 @@ static void qtest_process_command(CharBackend *chr, gchar **words)\n uint64_t addr, len;\n uint8_t *data;\n unsigned long pattern;\n+ int ret;\n\n g_assert(words[1] && words[2] && words[3]);\n- g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);\n- g_assert(qemu_strtou64(words[2], NULL, 0, &len) == 0);\n- g_assert(qemu_strtoul(words[3], NULL, 0, &pattern) == 0);\n+ ret = qemu_strtou64(words[1], NULL, 0, &addr);\n+ g_assert(ret == 0);\n+ ret = qemu_strtou64(words[2], NULL, 0, &len);\n+ g_assert(ret == 0);\n+ ret = qemu_strtoul(words[3], NULL, 0, &pattern);\n+ g_assert(ret == 0);\n\n if (len) {\n data = g_malloc(len);\n@@ -517,10 +540,13 @@ static void qtest_process_command(CharBackend *chr, gchar **words)\n uint8_t *data;\n size_t data_len;\n gsize out_len;\n+ int ret;\n\n g_assert(words[1] && words[2] && words[3]);\n- g_assert(qemu_strtou64(words[1], NULL, 0, &addr) == 0);\n- g_assert(qemu_strtou64(words[2], NULL, 0, &len) == 0);\n+ ret = qemu_strtou64(words[1], NULL, 0, &addr);\n+ g_assert(ret == 0);\n+ ret = qemu_strtou64(words[2], NULL, 0, &len);\n+ g_assert(ret == 0);\n\n data_len = strlen(words[3]);\n if (data_len < 3) {\n@@ -551,11 +577,16 @@ static void qtest_process_command(CharBackend *chr, gchar **words)\n } else if (strcmp(words[0], \"rtas\") == 0) {\n uint64_t res, args, ret;\n unsigned long nargs, nret;\n+ int rc;\n\n- g_assert(qemu_strtoul(words[2], NULL, 0, &nargs) == 0);\n- g_assert(qemu_strtou64(words[3], NULL, 0, &args) == 0);\n- g_assert(qemu_strtoul(words[4], NULL, 0, &nret) == 0);\n- g_assert(qemu_strtou64(words[5], NULL, 0, &ret) == 0);\n+ rc = qemu_strtoul(words[2], NULL, 0, &nargs);\n+ g_assert(rc == 0);\n+ rc = qemu_strtou64(words[3], NULL, 0, &args);\n+ g_assert(rc == 0);\n+ rc = qemu_strtoul(words[4], NULL, 0, &nret);\n+ g_assert(rc == 0);\n+ rc = qemu_strtou64(words[5], NULL, 0, &ret);\n+ g_assert(rc == 0);\n res = qtest_rtas_call(words[1], nargs, args, nret, ret);\n\n qtest_send_prefix(chr);\n@@ -565,7 +596,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)\n int64_t ns;\n\n if (words[1]) {\n- g_assert(qemu_strtoi64(words[1], NULL, 0, &ns) == 0);\n+ int ret = qemu_strtoi64(words[1], NULL, 0, &ns);\n+ g_assert(ret == 0);\n } else {\n ns = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);\n }\n@@ -575,9 +607,11 @@ static void qtest_process_command(CharBackend *chr, gchar **words)\n (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));\n } else if (qtest_enabled() && strcmp(words[0], \"clock_set\") == 0) {\n int64_t ns;\n+ int ret;\n\n g_assert(words[1]);\n- g_assert(qemu_strtoi64(words[1], NULL, 0, &ns) == 0);\n+ ret = qemu_strtoi64(words[1], NULL, 0, &ns);\n+ g_assert(ret == 0);\n qtest_clock_warp(ns);\n qtest_send_prefix(chr);\n qtest_sendf(chr, \"OK %\"PRIi64\"\\n\",\n", "prefixes": [ "v7", "02/38" ] }