From patchwork Wed Feb 8 11:33:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 9562291 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 1151560434 for ; Wed, 8 Feb 2017 11:35:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04A3F2849E for ; Wed, 8 Feb 2017 11:35:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB59B284CF; Wed, 8 Feb 2017 11:35:50 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CB5072849E for ; Wed, 8 Feb 2017 11:35:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbQVM-0008ID-QC; Wed, 08 Feb 2017 11:33:44 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbQVL-0008I6-Kn for xen-devel@lists.xenproject.org; Wed, 08 Feb 2017 11:33:43 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id 6D/EE-01683-6120B985; Wed, 08 Feb 2017 11:33:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsVyQ0OHTVeUaXa EQfdnPYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP7zzvMBc8FK351v2NtYOzi72Lk4hAS2M0o 8enwHsYuRk4OCQEDiTkrHrCCJCQEjrFI3P96mAkiISdxe+tsqCIpialfr7KD2EICBxgl9l4UB bHZBJQlum4tZgWxRQQUJDb3PgOzmQWKJdb1fQGbIyxgLNH4fwtYL4uAqsS8d/eYQWxegVCJth P9rBDz9ST+HlrLMoGRdwEjwypG9eLUorLUIl1LvaSizPSMktzEzBxdQwNTvdzU4uLE9NScxKR iveT83E2MwHBgAIIdjGtbnQ8xSnIwKYny+jydFSHEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgleL cXaEkGBRanpqRVpmDjAwYdISHDxKIrwhIGne4oLE3OLMdIjUKUZdjlM3Tr9kEmLJy89LlRLn/ cUAVCQAUpRRmgc3AhYllxhlpYR5GYGOEuIpSC3KzSxBlX/FKM7BqCTMmw6yiiczrwRu0yugI5 iAjrh+ehbIESWJCCmpBkb3xIrg90FTpDiX3V/m8YNf6ava2gomxX3GQrJ/ZLJCwu9MT8gKl/B TervyjexPpfpjb4JjxGcIa/m+uGvO1HnC9tzPkE6VwzNXOLY9MufxfjZLV1qU7+Nxy2m+6/OO 5H/NslvSkfw26rx87OnnXWLzt1yYOe9/4dWXhyu3zN3Z97ZhypWgzmtKLMUZiYZazEXFiQAmR 78JjQIAAA== X-Env-Sender: joe@perches.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1486553620!68333722!1 X-Originating-IP: [216.40.44.6] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25754 invoked from network); 8 Feb 2017 11:33:41 -0000 Received: from smtprelay0006.hostedemail.com (HELO smtprelay.hostedemail.com) (216.40.44.6) by server-13.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 Feb 2017 11:33:41 -0000 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id E0C20235FC; Wed, 8 Feb 2017 11:33:39 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: pest13_5a0e239bc3d56 X-Filterd-Recvd-Size: 2976 Received: from joe-laptop.perches.com (unknown [47.151.132.55]) (Authenticated sender: joe@perches.com) by omf08.hostedemail.com (Postfix) with ESMTPA; Wed, 8 Feb 2017 11:33:38 +0000 (UTC) From: Joe Perches To: linux-kernel@vger.kernel.org Date: Wed, 8 Feb 2017 03:33:36 -0800 Message-Id: X-Mailer: git-send-email 2.10.0.rc2.1.g053435c Cc: Juergen Gross , xen-devel@lists.xenproject.org, Boris Ostrovsky Subject: [Xen-devel] [PATCH] xenbus: Neaten xenbus_va_dev_error X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This function error patch can be simplified, so do so. Remove fail: label and somewhat obfuscating, used once "error_path" function. Signed-off-by: Joe Perches --- drivers/xen/xenbus/xenbus_client.c | 39 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index 056da6ee1a35..915d77785193 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -259,53 +259,34 @@ int xenbus_frontend_closed(struct xenbus_device *dev) } EXPORT_SYMBOL_GPL(xenbus_frontend_closed); -/** - * Return the path to the error node for the given device, or NULL on failure. - * If the value returned is non-NULL, then it is the caller's to kfree. - */ -static char *error_path(struct xenbus_device *dev) -{ - return kasprintf(GFP_KERNEL, "error/%s", dev->nodename); -} - - static void xenbus_va_dev_error(struct xenbus_device *dev, int err, const char *fmt, va_list ap) { unsigned int len; - char *printf_buffer = NULL; - char *path_buffer = NULL; + char *printf_buffer; + char *path_buffer; #define PRINTF_BUFFER_SIZE 4096 + printf_buffer = kmalloc(PRINTF_BUFFER_SIZE, GFP_KERNEL); - if (printf_buffer == NULL) - goto fail; + if (!printf_buffer) + return; len = sprintf(printf_buffer, "%i ", -err); - vsnprintf(printf_buffer+len, PRINTF_BUFFER_SIZE-len, fmt, ap); + vsnprintf(printf_buffer + len, PRINTF_BUFFER_SIZE - len, fmt, ap); dev_err(&dev->dev, "%s\n", printf_buffer); - path_buffer = error_path(dev); - - if (path_buffer == NULL) { + path_buffer = kasprintf(GFP_KERNEL, "error/%s", dev->nodename); + if (!path_buffer || + xenbus_write(XBT_NIL, path_buffer, "error", printf_buffer)) dev_err(&dev->dev, "failed to write error node for %s (%s)\n", - dev->nodename, printf_buffer); - goto fail; - } + dev->nodename, printf_buffer); - if (xenbus_write(XBT_NIL, path_buffer, "error", printf_buffer) != 0) { - dev_err(&dev->dev, "failed to write error node for %s (%s)\n", - dev->nodename, printf_buffer); - goto fail; - } - -fail: kfree(printf_buffer); kfree(path_buffer); } - /** * xenbus_dev_error * @dev: xenbus device