From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7BB4ECE587 for ; Mon, 14 Oct 2019 09:33:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7EA0B206A3 for ; Mon, 14 Oct 2019 09:33:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730979AbfJNJdD (ORCPT ); Mon, 14 Oct 2019 05:33:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38752 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730667AbfJNJdD (ORCPT ); Mon, 14 Oct 2019 05:33:03 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC26310C092A; Mon, 14 Oct 2019 09:33:02 +0000 (UTC) Received: from thuth.remote.csb (dhcp-200-228.str.redhat.com [10.33.200.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6F945DA8D; Mon, 14 Oct 2019 09:32:58 +0000 (UTC) Subject: Re: [kvm-unit-tests PATCH] lib: use an argument which doesn't require default argument promotion To: Bill Wendling Cc: Paolo Bonzini , David Hildenbrand , kvm list , =?UTF-8?B?THVrw6HFoSBEb2t0b3I=?= , David Gibson , Laurent Vivier , Andrew Jones References: <986a6fc2-ef7b-4df4-8d4e-a4ab94238b32@redhat.com> <30edb4bd-535d-d29c-3f4e-592adfa41163@redhat.com> <7f7fa66f-9e6c-2e48-03b2-64ebca36df99@redhat.com> From: Thomas Huth Openpgp: preference=signencrypt Autocrypt: addr=thuth@redhat.com; prefer-encrypt=mutual; keydata= mQINBFH7eUwBEACzyOXKU+5Pcs6wNpKzrlJwzRl3VGZt95VCdb+FgoU9g11m7FWcOafrVRwU yYkTm9+7zBUc0sW5AuPGR/dp3pSLX/yFWsA/UB4nJsHqgDvDU7BImSeiTrnpMOTXb7Arw2a2 4CflIyFqjCpfDM4MuTmzTjXq4Uov1giGE9X6viNo1pxyEpd7PanlKNnf4PqEQp06X4IgUacW tSGj6Gcns1bCuHV8OPWLkf4hkRnu8hdL6i60Yxz4E6TqlrpxsfYwLXgEeswPHOA6Mn4Cso9O 0lewVYfFfsmokfAVMKWzOl1Sr0KGI5T9CpmRfAiSHpthhHWnECcJFwl72NTi6kUcUzG4se81 O6n9d/kTj7pzTmBdfwuOZ0YUSqcqs0W+l1NcASSYZQaDoD3/SLk+nqVeCBB4OnYOGhgmIHNW 0CwMRO/GK+20alxzk//V9GmIM2ACElbfF8+Uug3pqiHkVnKqM7W9/S1NH2qmxB6zMiJUHlTH gnVeZX0dgH27mzstcF786uPcdEqS0KJuxh2kk5IvUSL3Qn3ZgmgdxBMyCPciD/1cb7/Ahazr 3ThHQXSHXkH/aDXdfLsKVuwDzHLVSkdSnZdt5HHh75/NFHxwaTlydgfHmFFwodK8y/TjyiGZ zg2Kje38xnz8zKn9iesFBCcONXS7txENTzX0z80WKBhK+XSFJwARAQABtB5UaG9tYXMgSHV0 aCA8dGh1dGhAcmVkaGF0LmNvbT6JAjgEEwECACIFAlVgX6oCGwMGCwkIBwMCBhUIAgkKCwQW AgMBAh4BAheAAAoJEC7Z13T+cC21EbIP/ii9cvT2HHGbFRl8HqGT6+7Wkb+XLMqJBMAIGiQK QIP3xk1HPTsLfVG0ao4hy/oYk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Arm63o39me/bRUQeQVSxEBmg66yshF9HkcUPGVeC4B0TPwz+HFcVhheo6hoJjLq knFOPLRj+0h+ZL+D0GenyqD3CyuyeTT5dGcNU9qT74bdSr20k/CklvI7S9yoQje8BeQAHtdV cvO8XCLrpGuw9SgOS7OP5oI26a0548M4KldAY+kqX6XVphEw3/6U1KTf7WxW5zYLTtadjISB X9xsRWSU+Yqs3C7oN5TIPSoj9tXMoxZkCIHWvnqGwZ7JhwARAQABiQIfBBgBAgAJBQJR+3lM AhsMAAoJEC7Z13T+cC21hPAQAIsBL9MdGpdEpvXs9CYrBkd6tS9mbaSWj6XBDfA1AEdQkBOn ZH1Qt7HJesk+qNSnLv6+jP4VwqK5AFMrKJ6IjE7jqgzGxtcZnvSjeDGPF1h2CKZQPpTw890k fy18AvgFHkVk2Oylyexw3aOBsXg6ukN44vIFqPoc+YSU0+0QIdYJp/XFsgWxnFIMYwDpxSHS 5fdDxUjsk3UBHZx+IhFjs2siVZi5wnHIqM7eK9abr2cK2weInTBwXwqVWjsXZ4tq5+jQrwDK cvxIcwXdUTLGxc4/Z/VRH1PZSvfQxdxMGmNTGaXVNfdFZjm4fz0mz+OUi6AHC4CZpwnsliGV ODqwX8Y1zic9viSTbKS01ZNp175POyWViUk9qisPZB7ypfSIVSEULrL347qY/hm9ahhqmn17 Ng255syASv3ehvX7iwWDfzXbA0/TVaqwa1YIkec+/8miicV0zMP9siRcYQkyTqSzaTFBBmqD oiT+z+/E59qj/EKfyce3sbC9XLjXv3mHMrq1tKX4G7IJGnS989E/fg6crv6NHae9Ckm7+lSs IQu4bBP2GxiRQ+NV3iV/KU3ebMRzqIC//DCOxzQNFNJAKldPe/bKZMCxEqtVoRkuJtNdp/5a yXFZ6TfE1hGKrDBYAm4vrnZ4CXFSBDllL59cFFOJCkn4Xboj/aVxxJxF30bn Organization: Red Hat Message-ID: Date: Mon, 14 Oct 2019 11:32:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Mon, 14 Oct 2019 09:33:02 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 14/10/2019 10.14, Bill Wendling wrote: > On Mon, Oct 14, 2019 at 12:57 AM Thomas Huth wrote: >> >> On 11/10/2019 20.36, Bill Wendling wrote: >>> I apologize for the breakage. I'm not sure how this escaped me. Here's >>> a proposed fix. Thoughts? >>> >>> commit 5fa1940140fd75a97f3ac5ae2e4de9e1bef645d0 >>> Author: Bill Wendling >>> Date: Fri Oct 11 11:26:03 2019 -0700 >>> >>> Use a status enum for reporting pass/fail >>> >>> Some values passed into "report" as "pass/fail" are larger than the >>> size of the parameter. Use instead a status enum so that the size of the >>> argument no longer matters. >>> >>> diff --git a/lib/libcflat.h b/lib/libcflat.h >>> index b6635d9..8f80a1c 100644 >>> --- a/lib/libcflat.h >>> +++ b/lib/libcflat.h >>> @@ -95,13 +95,22 @@ extern int vsnprintf(char *buf, int size, const >>> char *fmt, va_list va) >>> extern int vprintf(const char *fmt, va_list va) >>> __attribute__((format(printf, 1, 0))); >>> >>> +enum status { PASSED, FAILED }; >>> + >>> +#define STATUS(x) ((x) != 0 ? PASSED : FAILED) >>> + >>> +#define report(msg_fmt, status, ...) \ >>> + report_status(msg_fmt, STATUS(status) __VA_OPT__(,) __VA_ARGS__) >>> +#define report_xfail(msg_fmt, xfail, status, ...) \ >>> + report_xfail_status(msg_fmt, xfail, STATUS(status) __VA_OPT__(,) __VA_ARGS__) >>> + >>> void report_prefix_pushf(const char *prefix_fmt, ...) >>> __attribute__((format(printf, 1, 2))); >>> extern void report_prefix_push(const char *prefix); >>> extern void report_prefix_pop(void); >>> -extern void report(const char *msg_fmt, unsigned pass, ...) >>> +extern void report_status(const char *msg_fmt, unsigned pass, ...) >>> __attribute__((format(printf, 1, 3))); >>> -extern void report_xfail(const char *msg_fmt, bool xfail, unsigned pass, ...) >>> +extern void report_xfail_status(const char *msg_fmt, bool xfail, enum >>> status status, ...) >>> __attribute__((format(printf, 1, 4))); >>> extern void report_abort(const char *msg_fmt, ...) >>> __attribute__((format(printf, 1, 2))) >>> diff --git a/lib/report.c b/lib/report.c >>> index 2a5f549..4ba2ac0 100644 >>> --- a/lib/report.c >>> +++ b/lib/report.c >>> @@ -80,12 +80,12 @@ void report_prefix_pop(void) >>> spin_unlock(&lock); >>> } >>> >>> -static void va_report(const char *msg_fmt, >>> - bool pass, bool xfail, bool skip, va_list va) >>> +static void va_report(const char *msg_fmt, enum status status, bool xfail, >>> + bool skip, va_list va) >>> { >>> const char *prefix = skip ? "SKIP" >>> - : xfail ? (pass ? "XPASS" : "XFAIL") >>> - : (pass ? "PASS" : "FAIL"); >>> + : xfail ? (status == PASSED ? "XPASS" : "XFAIL") >>> + : (status == PASSED ? "PASS" : "FAIL"); >>> >>> spin_lock(&lock); >>> >>> @@ -96,27 +96,27 @@ static void va_report(const char *msg_fmt, >>> puts("\n"); >>> if (skip) >>> skipped++; >>> - else if (xfail && !pass) >>> + else if (xfail && status == FAILED) >>> xfailures++; >>> - else if (xfail || !pass) >>> + else if (xfail || status == FAILED) >>> failures++; >>> >>> spin_unlock(&lock); >>> } >>> >>> -void report(const char *msg_fmt, unsigned pass, ...) >>> +void report_status(const char *msg_fmt, enum status status, ...) >>> { >>> va_list va; >>> - va_start(va, pass); >>> - va_report(msg_fmt, pass, false, false, va); >>> + va_start(va, status); >>> + va_report(msg_fmt, status, false, false, va); >>> va_end(va); >>> } >>> >>> -void report_xfail(const char *msg_fmt, bool xfail, unsigned pass, ...) >>> +void report_xfail_status(const char *msg_fmt, bool xfail, enum status >>> status, ...) >>> { >>> va_list va; >>> - va_start(va, pass); >>> - va_report(msg_fmt, pass, xfail, false, va); >>> + va_start(va, status); >>> + va_report(msg_fmt, status, xfail, false, va); >>> va_end(va); >>> } >> >> That's certainly a solution... but I wonder whether it might be easier >> to simply fix the failing tests instead, to make sure that they do not >> pass a value > sizeof(int) to report() and report_xfail_status() ? >> > It may be easier, but it won't stop future changes from encountering > the same issue. True. >> Another idea would be to swap the parameters of report() and >> report_xfail_status() : >> > It's a bit non-standard, but I don't have much of a preference. It > would take changing tons of places in the code base though. Yes, it's a bigger change now ... but with your approach, I'm a little bit afraid that we'll forget the reason over the years, so one day in the future somebody might wonder what's this "enum status" magic all about and more or less revert your patch again... so if we take your patch, I think there should either be some comments in the code as explanation, or we might want to add builds with clang to the .travis.yml and gitlab-ci.yml files to make sure that we keep building the kvm-unit-tests with clang, too. Thomas