Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933303AbbEEQkd (ORCPT ); Tue, 5 May 2015 12:40:33 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:46340 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756013AbbEEQka (ORCPT ); Tue, 5 May 2015 12:40:30 -0400 Date: Tue, 5 May 2015 19:40:11 +0300 From: Dan Carpenter To: Jose Rivera Cc: "devel@driverdev.osuosl.org" , Stuart Yoder , "bhamciu1@freescale.com" , "arnd@arndb.de" , "bhupesh.sharma@freescale.com" , "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "agraf@suse.de" , "nir.erez@freescale.com" , "itai.katz@freescale.com" , Scott Wood , "R89243@freescale.com" , Richard Schmitt Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support Message-ID: <20150505164011.GT14154@mwanda> References: <1430242750-17745-1-git-send-email-German.Rivera@freescale.com> <1430242750-17745-2-git-send-email-German.Rivera@freescale.com> <20150430114957.GW14154@mwanda> <20150505084830.GL16501@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2693 Lines: 64 On Tue, May 05, 2015 at 04:08:49PM +0000, Jose Rivera wrote: > > Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support > > > > On Mon, May 04, 2015 at 10:09:08PM +0000, Jose Rivera wrote: > > > > > + WARN_ON((int16_t)irq_count < 0); > > > > > > > > This code is doing "WARN_ON(test_bit(15, (unsigned long > > *)&irq_count));". > > > > That seems like nonsense. Anyway, just delete the WARN_ON(). > > > > > > > I disagree. This WARN_ON is checking that irq_count is in the expected > > > range (it fits in int16_t as a positive number). The > > > dprc_scan_objects() function expects irq_count to be of type "unsigned > > > int" (which is 32-bit unsigned) > > > > > > > You're not allowed to disagree because it's a testable thing and not an > > opinion about style or something. :P What you want is: > > > > WARN_ON(irq_count > SHRT_MAX); > > > I see your point now. The check "(int16_t)irq_count < 0)" will not be able > to catch 0x10000 > 0x7fff, but "irq_count > SHRT_MAX) will. So I'll > make the suggested change, but I would prefer to use S16_MAX rather than > SHRT_MAX. > Huh? I didn't even know about the S16_MAX definition. There are literally no users of it in the kernel. It's not very fair because there are few users of SHRT_MAX. But there are literally no users of S32_MAX in the kernel and 358 users of INT_MAX. Don't insist that you must be special and different from everyone else. > > > > to read what "goto error;" does. The error handling here calls > > > > devm_kfree() which is not needed... devm_ functions automatically > > > > clean up after themselves. This seems a pattern throughout. Do a > > > > search for > > > > devm_free() and see which ones are really needed or not. > > > > > > > I know that memory allocated with devm_kzalloc() is freed at the end > > > of the lifetime of the device it is attached to. However, in error > > > paths, why wait until the device is destroyed? Why not free the memory > > > earlier so that it can be used for other purposes? > > > Why then do the devm_kfree() function exist? > > I will not remove the devm_free() calls unless the upstream maintainer > requires me to do so. I'm not saying remove them all. I'm saying: 1) I am concerned that you seem to thing devm_ is garbage collection. 2) Remove the ones which are not needed, because it is a lot of work for me to figure this out so I was hoping you could do it. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/