From patchwork Thu Apr 26 18:07:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 10366615 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B5E4D60225 for ; Thu, 26 Apr 2018 18:08:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A097729115 for ; Thu, 26 Apr 2018 18:08:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94792291B5; Thu, 26 Apr 2018 18:08:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F207529115 for ; Thu, 26 Apr 2018 18:08:27 +0000 (UTC) Received: from localhost ([::1]:43872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBlJj-0003sz-7U for patchwork-qemu-devel@patchwork.kernel.org; Thu, 26 Apr 2018 14:08:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBlIn-0003GY-42 for qemu-devel@nongnu.org; Thu, 26 Apr 2018 14:07:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBlIi-0004T6-Qs for qemu-devel@nongnu.org; Thu, 26 Apr 2018 14:07:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51134 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fBlIi-0004T1-Ji for qemu-devel@nongnu.org; Thu, 26 Apr 2018 14:07:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F3FE6EC01A; Thu, 26 Apr 2018 18:07:19 +0000 (UTC) Received: from [10.10.120.65] (ovpn-120-65.rdu2.redhat.com [10.10.120.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34F5C2022EE7; Thu, 26 Apr 2018 18:07:17 +0000 (UTC) To: Ian Jackson References: <1524761612-5307-1-git-send-email-ian.jackson@eu.citrix.com> <1524761612-5307-4-git-send-email-ian.jackson@eu.citrix.com> <60a2650a-ff36-1641-51b1-5c5b1a36f18a@redhat.com> <23266.4013.789190.625834@mariner.uk.xensource.com> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Organization: Red Hat, Inc. Message-ID: Date: Thu, 26 Apr 2018 13:07:16 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <23266.4013.789190.625834@mariner.uk.xensource.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 26 Apr 2018 18:07:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 26 Apr 2018 18:07:20 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: [Qemu-devel] [RFC PATCH 3/7] error reporting: Use error_report_errno in obvious places X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , Alistair Francis , qemu-devel@nongnu.org, =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On 04/26/2018 12:43 PM, Ian Jackson wrote: > Eric Blake writes ("Re: [RFC PATCH 3/7] error reporting: Use error_report_errno in obvious places"): >> Misses a lot of two-line instances, such as: >> $ git grep -A1 error_report | grep -C1 strerror.errno >> ... > ... >> If we're going to clean up these instances, we might as well look harder >> for them. Can Coccinelle be coaxed into helping us (at least for >> identifying callsites, even if I can't figure out how to make it >> slice-and-dice format strings)? > > I have never used Coccinelle, so I don't know. It was quite easy to detect spots that would benefit from this pattern; I'm less certain about getting Coccinelle to rewrite them, but at least knowing where they are makes it easier to ensure you aren't missing obvious candidates: $ cat error_report.cocci @@ expression E; @@ * error_report(..., strerror(E)) $ spatch --sp-file error_report.cocci \ --macro-file scripts/cocci-macro-file.h --dir . 2>/dev/null \ grep -c error_report 149 Between patch 2 and 5, I thus see 149 instances of a call to strerror() embedded as the last parameter to error_report(), which is more than you found. As an example, the tail of the Coccinelle output shows the one in block/file-posix.c that I demonstrated that you missed, plus the one in util/osdep.c that your simpler perl script caught: ... --- ./block/file-posix.c +++ /tmp/nothing/block/file-posix.c @@ -1762,8 +1762,6 @@ static int raw_regular_truncate(int fd, out: if (result < 0) { if (ftruncate(fd, current_length) < 0) { - error_report("Failed to restore old file length: %s", - strerror(errno)); } } diff -u -p ./util/osdep.c /tmp/nothing/util/osdep.c --- ./util/osdep.c +++ /tmp/nothing/util/osdep.c @@ -89,7 +89,6 @@ static int qemu_mprotect__osdep(void *ad return 0; #else if (mprotect(addr, size, prot)) { - error_report("%s: mprotect failed: %s", __func__, strerror(errno)); return -1; } return 0;