From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030297AbdJRK2j (ORCPT ); Wed, 18 Oct 2017 06:28:39 -0400 Received: from smtprelay0122.hostedemail.com ([216.40.44.122]:49686 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1030242AbdJRK2g (ORCPT ); Wed, 18 Oct 2017 06:28:36 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,::::::::::::::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:1963:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3354:3622:3743:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:4470:4605:5007:6119:6691:6742:7904:8526:10004:10400:10559:10848:11232:11658:11914:12043:12050:12740:12760:12895:13439:14181:14659:14721:21080:21433:21434:21451:21627:30012:30054:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:3,LUA_SUMMARY:none X-HE-Tag: peace46_4a7a77e417b5e X-Filterd-Recvd-Size: 4167 Message-ID: <1508322510.6806.3.camel@perches.com> Subject: Re: char-TPM: Adjustments for ten function implementations From: Joe Perches To: Julia Lawall , Alexander.Steffen@infineon.com Cc: elfring@users.sourceforge.net, linux-integrity@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, James.Bottomley@HansenPartnership.comg, dan.carpenter@oracle.com, jarkko.sakkinen@linux.intel.com, andriy.shevchenko@linux.intel.com, benh@kernel.crashing.org, clabbe.montjoie@gmail.com, jgunthorpe@obsidianresearch.com, jsnitsel@redhat.com, kgold@linux.vnet.ibm.com, mpe@ellerman.id.au, nayna@linux.vnet.ibm.com, paulus@samba.org, PeterHuewe@gmx.de, stefanb@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Date: Wed, 18 Oct 2017 03:28:30 -0700 In-Reply-To: References: <1d3516a2-a8e6-9e95-d438-f115fac84c7f@users.sourceforge.net> <20171016183139.otyh3m5c5yurtmow@linux.intel.com> <20171016183512.3bz6x4b6lbhpbkje@linux.intel.com> <20171017085124.pkrjzghcf5wmcydc@mwanda> <1508255833.3129.33.camel@HansenPartnership.com> <1508280210.6530.32.camel@perches.com> <1508318326.6806.1.camel@perches.com> <026d582729b849b780fbaa06fb8bc79e@infineon.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2017-10-18 at 12:00 +0200, Julia Lawall wrote: > > On Wed, 18 Oct 2017, Alexander.Steffen@infineon.com wrote: > > > > On Wed, 2017-10-18 at 11:00 +0200, SF Markus Elfring wrote: > > > > > The printk removals do change the objects. > > > > > > > > > > The value of that type of change is only for resource limited systems. > > > > > > > > I imagine that such small code adjustments are also useful for other > > > > > > systems. > > > > > > Your imagination and mine differ. > > > Where do you _think_ it matters? > > > > > > For instance, nothing about > > > > > > sizeof(type) > > > vs > > > sizeof(*ptr) > > > > > > makes it easier for a human to read the code. > > > > If it does not make it easier to read the code for you, then maybe you > > should consider that this might not be true for all humans. For me, it > > makes it much easier to see at a glance, that code like > > ptr=malloc(sizeof(*ptr)) is correct. > > I don't think there is a perfect solution. The type argument to sizeof > could have the wrong type. The expression argument to sizeof could be > missing the *. Yup. Today, even after all of Markus' patches for this style conversion, there is still only ~2:1 preference for ptr = k.alloc(sizeof(*ptr)) over ptr = k.alloc(sizeof(struct foo)) in the kernel tree Ugly grep follows: $ grep -rohP --include=*.[ch] "\w+\s*=\s*[kv].alloc\s*\(\s*sizeof.*," * | \ sed -r -e 's/(\w+)\s*=\s*[kv].alloc\s*\(\s*sizeof\s*\(\s*\*\s*\1\s*\)/foo = k.alloc(sizeof(*foo))/' \ -e 's/(\w+)\s*=\s*[kv].alloc\s*\(\s*sizeof\s*\(\s*struct\s+\w+\s*\)/foo = k.alloc(sizeof(struct foo))/' | \ sort | uniq -c | sort -rn | head -2 6123 foo = k.alloc(sizeof(*foo)), 3060 foo = k.alloc(sizeof(struct foo)), > Unpleasant consequences are possible in both cases. Yup. > Probably each maintainer has a style they prefer. Perhaps it could be > useful to adjust the code to follow the dominant strategy, in cases where > there are a inconsistencies. For example > > if (...) > x = foo1(sizeof(struct xtype)); > else > x = foo2(sizeof(*x)); > > might at least cause some unnecessary mental effort to process. Sure, but perhaps _only_ when there are inconsistencies in the same compilation unit.'