staging: xgifb: Initialize uninitialized variables
PATCH 3/3 staging: xgifb: Initialize uninitialized variables
Current patch solves compilation warnings in staging/xgifb for using possibly uninitialized variables.
--- drivers/staging/xgifb/vb_setmode.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/xgifb/vb_setmode.c +2 -2
@@ -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 ;
@@ -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;
Signature · 1 line
1.7.0.4
Quoted 12 lines · Javier Martinez Canillas
Current patch solves compilation warnings in staging/xgifb for using possibly uninitialized variables.
Signed-off-by Javier Martinez Canillas <[email protected]>--- drivers/staging/xgifb/vb_setmode.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/staging/xgifb/vb_setmode.c +0
-0
drivers/staging/xgifb/vb_setmode.c void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) · line 382
Quoted 8 lines
drivers/staging/xgifb/vb_setmode.c +1
-1@@ -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.
drivers/staging/xgifb/vb_setmode.c unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, · line 3840
Quoted 9 lines
drivers/staging/xgifb/vb_setmode.c +1
-1@@ -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,
Signature · 1 line
js
Quoted 30 lines · Jiri Slaby
Quoted 12 lines · Javier Martinez Canillas
Current patch solves compilation warnings in staging/xgifb for using possibly uninitialized variables.
Signed-off-by Javier Martinez Canillas <[email protected]>--- drivers/staging/xgifb/vb_setmode.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/staging/xgifb/vb_setmode.c +0
-0drivers/staging/xgifb/vb_setmode.c void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) · line 382
Quoted 8 lines
drivers/staging/xgifb/vb_setmode.c +1
-1@@ -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 )++ )
Quoted 7 lines
... } else { for( *ModeIdIndex = 0 ; ; ( *ModeIdIndex )++ ) ... }So your compiler is foolish if that emits a warning.
No, I don't see a way that the compiler could really figure that type of logic out. It doesn't know that XGI_SearchModeID() always will set that field. Heck, at first glance I couldn't even figure it out :)
So I don't mind applying this patch, as I'll just constantly keep getting people sending me the same change, when they could be off working on other things that this driver needs.
thanks,
greg k-h
Quoted 37 lines · Greg KH
Quoted 36 lines · Jiri Slaby
Quoted 12 lines · Javier Martinez Canillas
Current patch solves compilation warnings in staging/xgifb for using possibly uninitialized variables.
Signed-off-by Javier Martinez Canillas <[email protected]>--- drivers/staging/xgifb/vb_setmode.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/staging/xgifb/vb_setmode.c +0
-0drivers/staging/xgifb/vb_setmode.c void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) · line 382
Quoted 8 lines
drivers/staging/xgifb/vb_setmode.c +1
-1@@ -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 )++ ) ... }
Quoted 5 lines
Quoted 1 line
So your compiler is foolish if that emits a warning.
No, I don't see a way that the compiler could really figure that type of logic out. It doesn't know that
XGI_SearchModeID()always will set that field. Heck, at first glance I couldn't even figure it out :)
No, the compiler could. Trust me :). Actually you've just hidden a bug in XGI_SearchModeID. There is #ifdef LINUX and LINUX is defined in main.h. But that file is not included in vb_setmode.c. Hence the uninitialized warnings...
Quoted 3 lines
So I don't mind applying this patch, as I'll just constantly keep getting people sending me the same change, when they could be off working on other things that this driver needs.
So instead of hiding bugs, please fix the right ones.
thanks,
Signature · 1 line
js
Quoted 40 lines · Jiri Slaby
Quoted 39 lines · Greg KH
Quoted 37 lines · Jiri Slaby
Quoted 12 lines · Javier Martinez Canillas
Current patch solves compilation warnings in staging/xgifb for using possibly uninitialized variables.
Signed-off-by Javier Martinez Canillas <[email protected]>--- drivers/staging/xgifb/vb_setmode.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/staging/xgifb/vb_setmode.c +0
-0drivers/staging/xgifb/vb_setmode.c void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) · line 382
Quoted 8 lines
drivers/staging/xgifb/vb_setmode.c +1
-1@@ -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.
Quoted 8 lines
Quoted 3 lines
No, I don't see a way that the compiler could really figure that type of logic out. It doesn't know that
XGI_SearchModeID()always will set that field. Heck, at first glance I couldn't even figure it out :)No, the compiler could. Trust me :). Actually you've just hidden a bug in
XGI_SearchModeID. There is #ifdef LINUX and LINUX is defined inmain.h. But that file is not included invb_setmode.c. Hence the uninitialized warnings...
Doh, you are right.
Quoted 5 lines
Quoted 3 lines
So I don't mind applying this patch, as I'll just constantly keep getting people sending me the same change, when they could be off working on other things that this driver needs.
So instead of hiding bugs, please fix the right ones.
Good point, I'll go do that right now.
thanks,
greg k-h