From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E628C433E0 for ; Thu, 18 Jun 2020 05:42:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DAD22100A for ; Thu, 18 Jun 2020 05:42:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726982AbgFRFmv (ORCPT ); Thu, 18 Jun 2020 01:42:51 -0400 Received: from smtprelay0152.hostedemail.com ([216.40.44.152]:46308 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725837AbgFRFmv (ORCPT ); Thu, 18 Jun 2020 01:42:51 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 1A107181D3025; Thu, 18 Jun 2020 05:42:50 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: snow48_1f0962826e0d X-Filterd-Recvd-Size: 2844 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf02.hostedemail.com (Postfix) with ESMTPA; Thu, 18 Jun 2020 05:42:48 +0000 (UTC) Message-ID: <48589b2a3ec33a6504d23d166a32e7820d2e0b70.camel@perches.com> Subject: Re: [PATCH][next] bcache: Use struct_size() in kzalloc() From: Joe Perches To: Coly Li , "Gustavo A. R. Silva" Cc: Kent Overstreet , linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Date: Wed, 17 Jun 2020 22:42:47 -0700 In-Reply-To: <1c6adee3-bbad-dc88-3dd2-af823f279271@suse.de> References: <20200617222733.GA24156@embeddedor> <1c6adee3-bbad-dc88-3dd2-af823f279271@suse.de> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.2-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-06-18 at 13:38 +0800, Coly Li wrote: > On 2020/6/18 06:27, Gustavo A. R. Silva wrote: > > Make use of the struct_size() helper instead of an open-coded version > > in order to avoid any potential type mistakes. [] > > diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c [] > > - io = kzalloc(sizeof(struct dirty_io) + > > - sizeof(struct bio_vec) * > > - DIV_ROUND_UP(KEY_SIZE(&w->key), > > - PAGE_SECTORS), > > + io = kzalloc(struct_size(io, bio.bi_inline_vecs, > ^^^^^^^^^^^^^^^^^^ > I like this :-) > > > + DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS)), > > The above line seems too long for 80 characters limitation. Does > checkpatch.pl complain for this ? No. checkpatch has changed: >From bdc48fa11e46f867ea4d75fa59ee87a7f48be144 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 29 May 2020 16:12:21 -0700 Subject: [PATCH] checkpatch/coding-style: deprecate 80-column warning Yes, staying withing 80 columns is certainly still _preferred_. But it's not the hard limit that the checkpatch warnings imply, and other concerns can most certainly dominate. Increase the default limit to 100 characters. Not because 100 characters is some hard limit either, but that's certainly a "what are you doing" kind of value and less likely to be about the occasional slightly longer lines. Miscellanea: - to avoid unnecessary whitespace changes in files, checkpatch will no longer emit a warning about line length when scanning files unless --strict is also used - Add a bit to coding-style about alignment to open parenthesis Signed-off-by: Joe Perches Signed-off-by: Linus Torvalds >