From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753514Ab0IGIqg (ORCPT ); Tue, 7 Sep 2010 04:46:36 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:49695 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751369Ab0IGIqb (ORCPT ); Tue, 7 Sep 2010 04:46:31 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=pIIS3tojRNCfb3rGQ5O1WytWHZckCAG57VfRS8At7ckEMlZYPWaFVmwh0tqFvaGHko ZSvMwmwPQqHfCgsEhPmaeQvIZb8+LjtRlhsCG59f5joPyWMfNGDnkN7qxRMibnqWtJzZ bIAZJ8YLn4IMx60QDWBkftHRvYQunZZfKyVxA= Message-ID: <4C85FBE3.4000605@gmail.com> Date: Tue, 07 Sep 2010 10:46:27 +0200 From: Jiri Slaby User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; cs-CZ; rv:1.9.2.8) Gecko/20100802 SUSE/3.1.2 Thunderbird/3.1.2 MIME-Version: 1.0 To: Javier Martinez Canillas CC: Greg Kroah-Hartman , Bill Pemberton , Arnaud Patard , Randy Dunlap , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] staging: xgifb: Initialize uninitialized variables References: <1283837645.6302.10.camel@lenovo> In-Reply-To: <1283837645.6302.10.camel@lenovo> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/07/2010 07:34 AM, Javier Martinez Canillas wrote: > Current patch solves compilation warnings in staging/xgifb for using possibly uninitialized variables. > > Signed-off-by: Javier Martinez Canillas > --- > drivers/staging/xgifb/vb_setmode.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c > index c4db2fc..720a592 100644 > --- a/drivers/staging/xgifb/vb_setmode.c > +++ b/drivers/staging/xgifb/vb_setmode.c > @@ -376,7 +376,7 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) > unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, > unsigned short ModeNo) > { > - unsigned short ModeIdIndex; > + unsigned short ModeIdIndex = 0; > /* unsigned char *pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; */ > struct vb_device_info VBINF; > struct vb_device_info *pVBInfo = &VBINF; No, please don't. This is a compiler bug. The first use in that function is: XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ); and that function contains: if (XYZ) { for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ ) ... } else { for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ ) ... } So your compiler is foolish if that emits a warning. > @@ -3834,7 +3834,7 @@ unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, > struct xgi_hw_device_info *HwDeviceExtension, > struct vb_device_info *pVBInfo) > { > - unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; > + unsigned short tempbx, ModeIdIndex = 0, RefreshRateTableIndex; > > tempbx = pVBInfo->VBInfo; > pVBInfo->SetFlag |= ProgrammingCRT2; The same here. regards, -- js