From patchwork Thu Jun 28 09:23:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10493377 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 E72DA60325 for ; Thu, 28 Jun 2018 09:23:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4E6929E29 for ; Thu, 28 Jun 2018 09:23:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C90BB29E37; Thu, 28 Jun 2018 09:23: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 9D6A629E29 for ; Thu, 28 Jun 2018 09:23:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934800AbeF1JX1 (ORCPT ); Thu, 28 Jun 2018 05:23:27 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:57756 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933512AbeF1JX0 (ORCPT ); Thu, 28 Jun 2018 05:23:26 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5S9JKFQ033713; Thu, 28 Jun 2018 09:23:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=uegw+4C8w79fE9qckjHw1R62cYKtLGYaQOCXoY3b1iM=; b=d4iDazV4F+tYg8DTyrWMu+ERUug/FAlGFifNjpMmzBgxBE/YoB2TmT2pHQJof+Map8VR Zxp3ths6ucWgV0zBlElM1C0pkZJyKqpGJ5nSfK/TaUORUYZ+Dwc1ynYAFlsAIo4aMm2M 5t8BNxu7cYZ41yr4oBQ/YinR3rKMIrTMj8C3sNiabgqVmFF8athWC6p0XImdDRKYugJs +kpWrepsWQpIq6nRqjSqLyzF3feemzek1sRt4i1KAu1jejbJsw3LA1ynkhi8aOuBSOVs HVCw5QvlR+7G4mJZicoMtHmRiWpLUDZ78aqXt/1ErtYsVbsIlOJihKgVTfhu/AC2r8NK jA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2jum581g1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Jun 2018 09:23:21 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w5S9NJR2019258 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Jun 2018 09:23:20 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5S9NJ5B013654; Thu, 28 Jun 2018 09:23:19 GMT Received: from kili.mountain (/197.157.0.49) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 28 Jun 2018 02:23:18 -0700 Date: Thu, 28 Jun 2018 12:23:10 +0300 From: Dan Carpenter To: QLogic-Storage-Upstream@cavium.com, Manish Rangankar Cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] scsi: qedi: tidy up a size caculation Message-ID: <20180628092310.ta2qzatghjtgnzx7@kili.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170113 (1.7.2) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8937 signatures=668703 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=979 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806280107 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 The id_tbl->table pointer points to unsigned long so static checkers complain that instead of 4 we should be allocating sizeof(long) bytes. We're trying to allocate enough bits for the bitmap. The size variable is always 1024. (1024 / 32 * 4) is the same as (1024 / 64 * 8) so this doesn't change runtime, but this is the more idiomatic way to do it and makes the static checker happy. Signed-off-by: Dan Carpenter Acked-by: Manish Rangankar diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index cf274a79e77a..682f3ce31014 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -524,7 +524,7 @@ static int qedi_init_id_tbl(struct qedi_portid_tbl *id_tbl, u16 size, id_tbl->max = size; id_tbl->next = next; spin_lock_init(&id_tbl->lock); - id_tbl->table = kcalloc(DIV_ROUND_UP(size, 32), 4, GFP_KERNEL); + id_tbl->table = kcalloc(BITS_TO_LONGS(size), sizeof(long), GFP_KERNEL); if (!id_tbl->table) return -ENOMEM;