From patchwork Sun Apr 9 14:28:42 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: 9671575 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 E42FD6020C for ; Sun, 9 Apr 2017 14:29:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3DAA26E81 for ; Sun, 9 Apr 2017 14:29:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5591283FE; Sun, 9 Apr 2017 14:29:30 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham 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 703B326E81 for ; Sun, 9 Apr 2017 14:29:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752320AbdDIO33 (ORCPT ); Sun, 9 Apr 2017 10:29:29 -0400 Received: from mout.web.de ([212.227.17.11]:58224 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752198AbdDIO32 (ORCPT ); Sun, 9 Apr 2017 10:29:28 -0400 Received: from [192.168.1.2] ([77.181.114.244]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LvjrE-1c13Ex21fQ-017Rsg; Sun, 09 Apr 2017 16:28:47 +0200 Subject: [PATCH 3/3] iscsi-target: Improve size determinations in four functions From: SF Markus Elfring To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, Bart Van Assche , Hannes Reinecke , "Nicholas A. Bellinger" , Varun Prakash References: Cc: LKML , kernel-janitors@vger.kernel.org Message-ID: Date: Sun, 9 Apr 2017 16:28:42 +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: Content-Language: en-GB X-Provags-ID: V03:K0:34JYLzMAzs8DYpSHFmFXiX/DoZibLgadaEfFIk2ut2mS1LFkKO+ a8xMRNVypB+wxoI2tVusL+cArJkqHq3MO3FnmyUoH+8b1xnz5v+UjTQ+X+wDiwSdQvew9LJ rLuJID63+OyakAB5zpC7qDUQJnW3lfDhM1Hs49cAamRj7cpbv12umm31FZoA5lTpB7cmBp9 Bt0aw89BVJRiPW12ZFsdw== X-UI-Out-Filterresults: notjunk:1; V01:K0:Gn3nCwSAVp4=:zoxIFr5E5yUCqpDXyXvZaZ G1uwlMmAzBI0V7+UL6bbtWkK5548uu9IDhgkywWU/ewLWO25xMw5+QwNkhaxFFULc6XI5yJ6s CVMUtfUYT5NL7XWhWCO5ZnhHVyyQ906bos0jYKy+h5wcI7TobOdbQR6mFhQucFyj+tTLEIiUM EO16NKfXtI92WRR9sEzqh/oVueqUmj9q9GM1+XK/xIdC/QksF9dWS8yAd7SThC5V3vFCVEm1/ knMcvVskZHuFTtDpK04sBEL2hp5MPP6y1IMEjM6Hn1ibUfvul71Gf76JfsFY7rKkoCYIJwbrE C0rz/coHp8uYh0KAIznyDI9sm4x7d7Vfmn3/RZH1rC9OLMa+mdibKV93sWj7w60ADtvCTdmK6 WNvskAYdKw3Bo/edWBPKrems1qWhL7d7Hfqvgb1EimZgjtd1GdfHfUF3WBRTS3l7iCuEePww/ dWPw9QWp2KHtp81okkJU66vULP0rgwX3lhkW7fIMYP8pFawjewG+JXlmEOzoeVRg6W826uo2p ukxcJUjkY2zMUYgmFeS660fZDTbFuzNmYaw2KdxjqrY/nVtAS1J6Bec05s7Huk7qtHp9HcTx1 SES1ZleSKhPHR2wBA3tEGWPsj9i5INYzVK5m87yJaD5DK6NL9gRqgaj3Mb5fzluTuYIVr81pU nmMAkyu+9mwcOwRo2xPMVWkBh3xfoI5zXCxUQXLCuPAt+uNQhkV6WucSOuuqlXBQIhptihPy/ xdfj4oybn+gU05ZBt2a4dSWwXeBmXL0QrqMkCXeoT0mjDowcy0JwyQqHTiRLv4E+4zWe84mWL 32P+LDV Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 9 Apr 2017 16:00:39 +0200 Replace the specification of four data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determinations a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/target/iscsi/iscsi_target.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 196e9dd138ca..5ef6eb238174 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -128,7 +128,7 @@ struct iscsi_tiqn *iscsit_add_tiqn(unsigned char *buf) return ERR_PTR(-EINVAL); } - tiqn = kzalloc(sizeof(struct iscsi_tiqn), GFP_KERNEL); + tiqn = kzalloc(sizeof(*tiqn), GFP_KERNEL); if (!tiqn) return ERR_PTR(-ENOMEM); @@ -360,7 +360,7 @@ struct iscsi_np *iscsit_add_np( return np; } - np = kzalloc(sizeof(struct iscsi_np), GFP_KERNEL); + np = kzalloc(sizeof(*np), GFP_KERNEL); if (!np) { mutex_unlock(&np_lock); return ERR_PTR(-ENOMEM); @@ -694,8 +694,7 @@ static int __init iscsi_target_init_module(void) int ret = 0, size; pr_debug("iSCSI-Target "ISCSIT_VERSION"\n"); - - iscsit_global = kzalloc(sizeof(struct iscsit_global), GFP_KERNEL); + iscsit_global = kzalloc(sizeof(*iscsit_global), GFP_KERNEL); if (!iscsit_global) return -1; @@ -1987,8 +1986,7 @@ iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, hdr->refcmdsn = cpu_to_be32(ISCSI_RESERVED_TAG); cmd->data_direction = DMA_NONE; - - cmd->tmr_req = kzalloc(sizeof(struct iscsi_tmr_req), GFP_KERNEL); + cmd->tmr_req = kzalloc(sizeof(*cmd->tmr_req), GFP_KERNEL); if (!cmd->tmr_req) return iscsit_add_reject_cmd(cmd, ISCSI_REASON_BOOKMARK_NO_RESOURCES,