From patchwork Sun Aug 20 20:19:49 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: 9911433 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 DACC1600C8 for ; Sun, 20 Aug 2017 20:20:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF2952852A for ; Sun, 20 Aug 2017 20:20:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C433C286D6; Sun, 20 Aug 2017 20:20:24 +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 96AF62852A for ; Sun, 20 Aug 2017 20:20:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753302AbdHTUUA (ORCPT ); Sun, 20 Aug 2017 16:20:00 -0400 Received: from mout.web.de ([212.227.17.12]:63721 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753191AbdHTUT7 (ORCPT ); Sun, 20 Aug 2017 16:19:59 -0400 Received: from [192.168.1.2] ([92.225.240.160]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MMW2M-1deZxJ08b8-008I6N; Sun, 20 Aug 2017 22:19:51 +0200 Subject: [PATCH 3/4] btrfs: Improve eight size determinations From: SF Markus Elfring To: linux-btrfs@vger.kernel.org, Chris Mason , David Sterba , Josef Bacik Cc: LKML , kernel-janitors@vger.kernel.org References: <360126ba-e45b-0a8d-57b6-83764c4c2bce@users.sourceforge.net> Message-ID: Date: Sun, 20 Aug 2017 22:19:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <360126ba-e45b-0a8d-57b6-83764c4c2bce@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:Iyyh89vfmLXwTMNeUBxNAq3IkdMguggilovcdnw3QiIye2HqnfM sr9QicmznexZnNSgfcfHAVoVTa7zuu7XMKnf0s6RJS5HGjNl6yX2/znCasH6xv5CtKHXJ4K RJ2FOmo8MHdGikkXezK2HsP5CVdlzihpAOLcPrvuPl6DehkPVLMYvh00bcbFfsoSqKIb2hK xr5CjFV07hc/NJNKdcJIg== X-UI-Out-Filterresults: notjunk:1; V01:K0:qW1RK3NBqLk=:Y2qeK9UBHZDEHmbcet41Xm BFMaVZA6MTZnMT930mnn9vx7jTBSmkPSXYZJ9IK4INkvEU5d93k2al0skRdzn3HvX/uyRr62i 1974gjq0t2fV2/9Y4+sO0OaFiFh53wOpMqc66ZjVw4UtQ/rpqpVjShGHfxJLxKWkFNiN+0S09 iJS7v5VqWMHY6rtnwNLEq82PzznpPx69RnnCxhvJyDYgsuJ+ZUldBq812rHZZYYoBO7ExVTgx g1vxEHOE798LMA/yTOY8wYCOI/RNAqFuneBRQoM1jM9cDKQO3y4SlefXZFgIhPDGBCpCod5V0 la6GP5wR3VcELWmTuyUvHc4z7N6GllG5cIni+ECsEbri7JgOSpFAEJ8lrVVDFizIgHXzW0llS HMHMLTkVWg/8VnvUJFPonT4MlXeHhyOkJQUiXFc4kA2xFJHppaiL4iZRhNWRFg+84RocPBoJg S0I8K0YkOtCznlda2Uzx7UIZO2Cxt09J/stAbx5Dd/8uzqugZo5HRpkx3i5ULeP8ULgHzNBW1 lyZXEfVLjtqpWWJnWND/abz76o/N7rvdJSp1pgXf8eHowAmyO2UvVB+IUDOHKfzu3WE4HrmVi cJ6t1G2iUaDdjOEGTw/2NYwrfy06VuHx7ZJhiHjE7yb2OY4CfZfPGztK8dIpmhsn6m6CEYGHk QxWlrpchIoFlL0Xeqd85zF/24ZHNd2lFh13Eyl33BUdeZQabgfMGBGhnyzRAr8/btA6VQS0em Bsm6N9UpnfQnVIPkeWrH9Knalf/UMZxA/u/ZzOQq4mam7dNy7qVuuKrUh/Q88ODs44DOUoQox /s55M/9CD2RlzV1UoxEJIJ0QTak0c95Ntclh2yhBRLszmt6m1Q= Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 20 Aug 2017 21:55:56 +0200 Replace the specification of data types by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Reviewed-by: Timofey Titovets --- fs/btrfs/ctree.c | 10 ++++------ fs/btrfs/delayed-inode.c | 4 ++-- fs/btrfs/raid56.c | 2 +- fs/btrfs/super.c | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index b89c101ef45e..3b49f39eaaf6 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -578,7 +578,7 @@ tree_mod_log_insert_move(struct btrfs_fs_info *fs_info, if (!tree_mod_need_log(fs_info, eb)) return 0; - tm_list = kcalloc(nr_items, sizeof(struct tree_mod_elem *), GFP_NOFS); + tm_list = kcalloc(nr_items, sizeof(*tm_list), GFP_NOFS); if (!tm_list) return -ENOMEM; @@ -677,8 +677,7 @@ tree_mod_log_insert_root(struct btrfs_fs_info *fs_info, if (log_removal && btrfs_header_level(old_root) > 0) { nritems = btrfs_header_nritems(old_root); - tm_list = kcalloc(nritems, sizeof(struct tree_mod_elem *), - GFP_NOFS); + tm_list = kcalloc(nritems, sizeof(*tm_list), GFP_NOFS); if (!tm_list) { ret = -ENOMEM; goto free_tms; @@ -813,8 +812,7 @@ tree_mod_log_eb_copy(struct btrfs_fs_info *fs_info, struct extent_buffer *dst, if (btrfs_header_level(dst) == 0 && btrfs_header_level(src) == 0) return 0; - tm_list = kcalloc(nr_items * 2, sizeof(struct tree_mod_elem *), - GFP_NOFS); + tm_list = kcalloc(nr_items * 2, sizeof(*tm_list), GFP_NOFS); if (!tm_list) return -ENOMEM; @@ -904,7 +902,7 @@ tree_mod_log_free_eb(struct btrfs_fs_info *fs_info, struct extent_buffer *eb) return 0; nritems = btrfs_header_nritems(eb); - tm_list = kcalloc(nritems, sizeof(struct tree_mod_elem *), GFP_NOFS); + tm_list = kcalloc(nritems, sizeof(*tm_list), GFP_NOFS); if (!tm_list) return -ENOMEM; diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index 19e4ad2f3f2e..865aaca445b9 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c @@ -750,13 +750,13 @@ static int btrfs_batch_insert_items(struct btrfs_root *root, */ btrfs_set_path_blocking(path); - keys = kmalloc_array(nitems, sizeof(struct btrfs_key), GFP_NOFS); + keys = kmalloc_array(nitems, sizeof(*keys), GFP_NOFS); if (!keys) { ret = -ENOMEM; goto out; } - data_size = kmalloc_array(nitems, sizeof(u32), GFP_NOFS); + data_size = kmalloc_array(nitems, sizeof(*data_size), GFP_NOFS); if (!data_size) { ret = -ENOMEM; goto error; diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 208638384cd2..c85f0f534532 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -1798,7 +1798,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio) int err; int i; - pointers = kcalloc(rbio->real_stripes, sizeof(void *), GFP_NOFS); + pointers = kcalloc(rbio->real_stripes, sizeof(*pointers), GFP_NOFS); if (!pointers) { err = -ENOMEM; goto cleanup_io; diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 0b7a1d8cd08b..cd2ba5e3b2d0 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1571,7 +1571,7 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags, * it for searching for existing supers, so this lets us do that and * then open_ctree will properly initialize everything later. */ - fs_info = kzalloc(sizeof(struct btrfs_fs_info), GFP_KERNEL); + fs_info = kzalloc(sizeof(*fs_info), GFP_KERNEL); if (!fs_info) { error = -ENOMEM; goto error_sec_opts;