From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757401Ab3KITCf (ORCPT ); Sat, 9 Nov 2013 14:02:35 -0500 Received: from mail-ea0-f182.google.com ([209.85.215.182]:42837 "EHLO mail-ea0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756750Ab3KITCU (ORCPT ); Sat, 9 Nov 2013 14:02:20 -0500 Message-ID: <527E86B9.2050306@linux.com> Date: Sat, 09 Nov 2013 20:02:17 +0100 From: Levente Kurusa Reply-To: levex@linux.com User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Mark Brown , Caizhiyong CC: Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" , "Wanglin (Albert)" Subject: Re: [PATCH] regmap: Fix compile warning with value uninitialized References: <20131109151626.GT2493@sirena.org.uk> <527E55EF.5080504@linux.com> <20131109185741.GW2493@sirena.org.uk> In-Reply-To: <20131109185741.GW2493@sirena.org.uk> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2013-11-09 19:57 keltezéssel, Mark Brown írta: > On Sat, Nov 09, 2013 at 04:34:07PM +0100, Levente Kurusa wrote: >> 2013-11-09 16:16 keltezéssel, Mark Brown írta: > >>>> - int i, ret; >>>> + int i; >>>> + int ret = 0; >>>> bool bypass; > >> Wouldn't the following be better? > >> int i, ret = 0; > >> I think it is more readable. > > No, that's not the kernel coding style. Alright. > >>> This sort of fix isn't ideal, it just silences the warning but if the >>> compiler has spotted a genuine oversight in the function it won't >>> address it. It's better to include some analysis of why this is a good >>> fix. > >> The only condition when 'ret' is not set is when the num_regs parameter is zero >> and krealloc doesn't fail. If the above two conditions apply, then >> the code would return an uninitialized value. However, calling this function with >> num_regs == 0, would be a waste as it essentially does nothing. > > OK, so that should be in the changelog - or there should be an error > check for num_regs == 0 which might be more helpful. Adding an explanation into the changelog and editing the patch in a way so that it adds a check would be the best choice I think. Cai, can you please do this as part of the patch? -- Regards, Levente Kurusa