From patchwork Sun Apr 9 19:47:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9671761 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 39CA6600CB for ; Sun, 9 Apr 2017 19:48:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2543527D29 for ; Sun, 9 Apr 2017 19:48:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A19127F4B; Sun, 9 Apr 2017 19:48:08 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A497C27D29 for ; Sun, 9 Apr 2017 19:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752645AbdDITsG (ORCPT ); Sun, 9 Apr 2017 15:48:06 -0400 Received: from mout.web.de ([217.72.192.78]:55198 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752320AbdDITsF (ORCPT ); Sun, 9 Apr 2017 15:48:05 -0400 Received: from [192.168.1.2] ([77.181.114.244]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M5g0a-1c8e2Q4AWG-00xa0D; Sun, 09 Apr 2017 21:47:59 +0200 Subject: [PATCH 2/5] target: Delete error messages for failed memory allocations From: SF Markus Elfring To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, Bart Van Assche , "Nicholas A. Bellinger" Cc: LKML , kernel-janitors@vger.kernel.org, Wolfram Sang References: <337dfdee-8a9f-9bb3-639a-ea47758966f1@users.sourceforge.net> Message-ID: <0ba7f3ea-612d-c3a6-16de-8237e41da041@users.sourceforge.net> Date: Sun, 9 Apr 2017 21:47:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 MIME-Version: 1.0 In-Reply-To: <337dfdee-8a9f-9bb3-639a-ea47758966f1@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:OkbvstsIkcCa0P5iSneRrCdcAqCUaGw25fUAn5cVngXZzXX7QtV L+K+VKEQd1DDHnTlmUzPB0wbboF1FM49ewhVZlyRnAqRCtoN9UFQzwiQX4VQng0cTP+mhmn F2j56iZ52z/4UYsFNdxrRbo8J3c3vZdtXa1xTU5rTbs8X9cUgVNpPByMEcGkYfIoRGhFgtD +sF86W8bSwSD/VJzXt30w== X-UI-Out-Filterresults: notjunk:1; V01:K0:AmOZBwvGTsY=:XP8yMnXDN06AwjSQWGy9Xa 2hW+pf7oM35dYUfkw+7NLRn0e3VV9UqYSqUw26iJrk7B2CyFp6BDyR0cZOswGrpFjhRNmqGZ2 +Ic4s4YM0SYk5cEpDpmGe6rhZ/Ri+83WmrKrVra/zUDDhv+NLe8uXMAIS4DIbC19B2pVaZ84T 3X/MCgf8Zb3QweY/St6YFwQLoe4Cbo6cJ7WJ1hqfM1UBHspOFpqQ2LYRrI3+VUrZGgh8fRaDm XPJv4Vi5JUplHUcmKDnR98ZSMbKq5ctFhZLa5N0LBQlX0RUgWmX/mpv4MkksOq2LqpQvAlOf7 bY1ADjNRMD2wdmMOCHWp4DhFoZ58+rzalW/2ogqHdEhxnLz3fiX89gjQNhaV3iFYxu0JdIFHQ OZB48jAifZcIu4H57k6CSSKkfS+AJaUH5hyeMgo9uKzztEa8U8AaDSk30cm5Tr+3vdg7iCMVW Ofa1sbYkNG0SPndrM7sajfwTxpKN9X1zLFdNS2+HAb7yTnTbtOlWLg8BZvh8agsbLaLeAhZWH hxCDCJvF8UtU2CH/sxUsgmjQ0VehP0Zt/H9ew1fDw2J0tUYFV6G6loKJr5bHiJcm06f06h/03 AwQ132Gq/Nz2mW5EoM/UmLnsN4+LCbFWgrk01MrUszQufc4Lp2P/ROXjRTEgRZEWIsIOcYYwh p6sfdEWrnyMVWZ7cjuciOK9qYUSwziU60ugaoxg1WyWW0m+e0r4G4UG7sFq88GcPu2CuDJv5x K1i8q5L2YvWlWfRCGSKCreuMi682lCGf8LqMIydVin9f2CLnosHoP0Yz+0m5SY/cSPnPm3xRB +SecZDF Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 9 Apr 2017 19:20:26 +0200 The script "checkpatch.pl" pointed information out like the following. WARNING: Possible unnecessary 'out of memory' message Thus remove such statements here. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring --- drivers/target/target_core_rd.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c index 026857861107..838dc128d494 100644 --- a/drivers/target/target_core_rd.c +++ b/drivers/target/target_core_rd.c @@ -48,10 +48,8 @@ static int rd_attach_hba(struct se_hba *hba, u32 host_id) struct rd_host *rd_host; rd_host = kzalloc(sizeof(struct rd_host), GFP_KERNEL); - if (!rd_host) { - pr_err("Unable to allocate memory for struct rd_host\n"); + if (!rd_host) return -ENOMEM; - } rd_host->rd_host_id = host_id; @@ -148,11 +146,8 @@ static int rd_allocate_sgl_table(struct rd_dev *rd_dev, struct rd_dev_sg_table * sg = kcalloc(sg_per_table + chain_entry, sizeof(*sg), GFP_KERNEL); - if (!sg) { - pr_err("Unable to allocate scatterlist array" - " for struct rd_dev\n"); + if (!sg) return -ENOMEM; - } sg_init_table(sg, sg_per_table + chain_entry); @@ -211,11 +206,8 @@ static int rd_build_device_space(struct rd_dev *rd_dev) sg_tables = (total_sg_needed / max_sg_per_table) + 1; sg_table = kcalloc(sg_tables, sizeof(*sg_table), GFP_KERNEL); - if (!sg_table) { - pr_err("Unable to allocate memory for Ramdisk" - " scatterlist tables\n"); + if (!sg_table) return -ENOMEM; - } rd_dev->sg_table_array = sg_table; rd_dev->sg_table_count = sg_tables; @@ -271,11 +263,8 @@ static int rd_build_prot_space(struct rd_dev *rd_dev, int prot_length, int block sg_tables = (total_sg_needed / max_sg_per_table) + 1; sg_table = kcalloc(sg_tables, sizeof(*sg_table), GFP_KERNEL); - if (!sg_table) { - pr_err("Unable to allocate memory for Ramdisk protection" - " scatterlist tables\n"); + if (!sg_table) return -ENOMEM; - } rd_dev->sg_prot_array = sg_table; rd_dev->sg_prot_count = sg_tables; @@ -297,10 +286,8 @@ static struct se_device *rd_alloc_device(struct se_hba *hba, const char *name) struct rd_host *rd_host = hba->hba_ptr; rd_dev = kzalloc(sizeof(struct rd_dev), GFP_KERNEL); - if (!rd_dev) { - pr_err("Unable to allocate memory for struct rd_dev\n"); + if (!rd_dev) return NULL; - } rd_dev->rd_host = rd_host;