From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753203AbdHRNgy (ORCPT ); Fri, 18 Aug 2017 09:36:54 -0400 Received: from mout.web.de ([212.227.15.14]:63653 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752541AbdHRNgu (ORCPT ); Fri, 18 Aug 2017 09:36:50 -0400 Subject: [PATCH 2/3] jfs: Improve size determinations in five functions From: SF Markus Elfring To: jfs-discussion@lists.sourceforge.net, Dave Kleikamp , Fabian Frederick , Jan Kara Cc: LKML , kernel-janitors@vger.kernel.org References: <3ce43084-11c3-6fc0-821b-7fa6e67c3e30@users.sourceforge.net> Message-ID: <8ac16f00-0995-86b6-7495-f8f7028f2138@users.sourceforge.net> Date: Fri, 18 Aug 2017 15:36:33 +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: <3ce43084-11c3-6fc0-821b-7fa6e67c3e30@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:BmeZot4T+Fxe0g0YpE0hEQ+CDruL3oUOkk+zp4OkoDidtTNnRTc 7nnR7CJvTjGc3dXaCsQrViw9vvtI0OHD31EGJXYkFcdOQCn38GCuS97TkFQBgZATu/h1dRr YMjUYgdXbzLhZu5BgnzS9TlS4eB+05Jl3Dw83veyCyLgaJ5TRd42i7/OcTiLgxYbZHp3WY0 6HgUAz7i+cU4dIYyb4i1Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:CYVOpWYSvO4=:jkJOaEuWwcVjvUkjf939c/ L0aCjO2wiFKeDW0vifj54ypn86miY3UB70XQgZtWbyd/H9EhDUqmuF1GYSron+HTX51LG9im5 cjTceBLM096okxSKQI4un0B1jMS+Q2SYBUdIjHsl/iolnzLkBl76LdLtADNuKw15TgfJcGYEd xZ2shETej8HFHur5SQ0TBzf91cs00DuClAh3S9Wo6V6oX94ZLGWILZrbd86yj3c4RBkJIOxVI ixNF0ZbYVTsKMnMj+5+8ZK4/hVMOGy9JtfjbZCkrgb9XIy3XnkbJ+Fb73kRNB+f7s7Ay1tv7N qQlhCrXVvgzzekUfN9bVehmnW8o+K6dB6ewxF+6AJ6nnjgHmrMU5kb/WAx8ya3byeORy0HD0+ 7uvb5geHDvQzwoMolnIhttzrXGT6RGKPTMNPys8Zi1IYxUz7Pwp46vxDPEhb2LZIBo2It+tZQ Z9yvQHNSww0mfiezvTr6Yq+uU4goQTEgOKxAkm04x7fVbRNN3pntiwmLNLyFx6Su71WjZ0TM8 BC5H/1cd5E7/a4XVXuI7bOIkFI5dxgL9KDCvgDHpghWy5j0tJpS3ElaahYwpa4OdgfGU00teH WdAZLr+FwScc65b+JlvSGyolXDpOiaGxx1zkqIub07IROpa7BOwuMYgov6G7sWGegjeL2esvy mQ5VUsjl3NAOgL+9V7loF4Qpui/NAJsPs0Bx9dSGhQnmH+pTloJkJP3d+Lw9M24vkdWo6OeBx r5IS/wHaVfkwf8CutJrKMjGPvfab+o3qTpulOBObGzFyPwgtWUN5tI9R3LOYO0nFHoZYsLczd 2GVvOFrpU54Kx/YLZkBabqUIHfv2FRdfGoZEzd8dvosQOXEe+I= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Fri, 18 Aug 2017 14:54:11 +0200 * Replace the specification of data structures 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. * The script "checkpatch.pl" pointed information out like the following. ERROR: do not use assignment in if condition Thus fix two affected source code places. Signed-off-by: Markus Elfring --- fs/jfs/jfs_imap.c | 2 +- fs/jfs/jfs_logmgr.c | 8 +++++--- fs/jfs/jfs_metapage.c | 2 +- fs/jfs/super.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index da8051299e47..a7e3a61187db 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c @@ -115,5 +115,5 @@ int diMount(struct inode *ipimap) * allocate/initialize the in-memory inode map control structure */ /* allocate the in-memory inode map control structure. */ - imap = kmalloc(sizeof(struct inomap), GFP_KERNEL); + imap = kmalloc(sizeof(*imap), GFP_KERNEL); if (!imap) diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c index a21f0e9eecd4..ed103c44bd52 100644 --- a/fs/jfs/jfs_logmgr.c +++ b/fs/jfs/jfs_logmgr.c @@ -1109,7 +1109,8 @@ int lmLogOpen(struct super_block *sb) } } - if (!(log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL))) { + log = kzalloc(sizeof(*log), GFP_KERNEL); + if (!log) { mutex_unlock(&jfs_log_mutex); return -ENOMEM; } @@ -1178,7 +1179,8 @@ static int open_inline_log(struct super_block *sb) struct jfs_log *log; int rc; - if (!(log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL))) + log = kzalloc(sizeof(*log), GFP_KERNEL); + if (!log) return -ENOMEM; INIT_LIST_HEAD(&log->sb_list); init_waitqueue_head(&log->syncwait); @@ -1839,7 +1841,7 @@ static int lbmLogInit(struct jfs_log * log) goto error; buffer = page_address(page); for (offset = 0; offset < PAGE_SIZE; offset += LOGPSIZE) { - lbuf = kmalloc(sizeof(struct lbuf), GFP_KERNEL); + lbuf = kmalloc(sizeof(*lbuf), GFP_KERNEL); if (lbuf == NULL) { if (offset == 0) __free_page(page); diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c index 65120a471729..6c75a7c87c0c 100644 --- a/fs/jfs/jfs_metapage.c +++ b/fs/jfs/jfs_metapage.c @@ -107,7 +107,7 @@ static inline int insert_metapage(struct page *page, struct metapage *mp) if (PagePrivate(page)) a = mp_anchor(page); else { - a = kzalloc(sizeof(struct meta_anchor), GFP_NOFS); + a = kzalloc(sizeof(*a), GFP_NOFS); if (!a) return -ENOMEM; set_page_private(page, (unsigned long)a); diff --git a/fs/jfs/super.c b/fs/jfs/super.c index 78b41e1d5c67..381476422e8d 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c @@ -526,7 +526,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) jfs_info("In jfs_read_super: s_flags=0x%lx", sb->s_flags); - sbi = kzalloc(sizeof(struct jfs_sb_info), GFP_KERNEL); + sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) return -ENOMEM; -- 2.14.0