[PATCH] video: fbdev: sis: init.c: Cleaning up redundant condition is always true

Subsystems: framebuffer layer, sis framebuffer driver, the rest

STALE4486d

4 messages, 3 authors, 2014-07-07 · open the first message on its own page

[PATCH] video: fbdev: sis: init.c: Cleaning up redundant condition is always true

From: Rickard Strandqvist <hidden>
Date: 2014-07-03 21:14:10

Removal of a redundant condition that is always true

This was found using a static code analysis program called cppcheck

Signed-off-by: Rickard Strandqvist <redacted>
---
 drivers/video/fbdev/sis/init.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/video/fbdev/sis/init.c b/drivers/video/fbdev/sis/init.c
index bd40f5e..9e2dd96 100644
--- a/drivers/video/fbdev/sis/init.c
+++ b/drivers/video/fbdev/sis/init.c
@@ -355,12 +355,12 @@ SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay,
 		}
 		break;
 	case 400:
-		if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 800) && (LCDwidth >= 600))) {
+		if ((!(VBFlags & CRT1_LCDA)) || (LCDwidth >= 600)) {
 			if(VDisplay = 300) ModeIndex = ModeIndex_400x300[Depth];
 		}
 		break;
 	case 512:
-		if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 1024) && (LCDwidth >= 768))) {
+		if ((!(VBFlags & CRT1_LCDA)) || (LCDwidth >= 768)) {
 			if(VDisplay = 384) ModeIndex = ModeIndex_512x384[Depth];
 		}
 		break;
-- 
1.7.10.4

Re: [PATCH] video: fbdev: sis: init.c: Cleaning up redundant condition is always true

From: Dan Carpenter <hidden>
Date: 2014-07-07 07:57:31

On Thu, Jul 03, 2014 at 11:15:21PM +0200, Rickard Strandqvist wrote:
quoted hunk
diff --git a/drivers/video/fbdev/sis/init.c b/drivers/video/fbdev/sis/init.c
index bd40f5e..9e2dd96 100644
--- a/drivers/video/fbdev/sis/init.c
+++ b/drivers/video/fbdev/sis/init.c
@@ -355,12 +355,12 @@ SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay,
 		}
 		break;
 	case 400:
-		if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 800) && (LCDwidth >= 600))) {
+		if ((!(VBFlags & CRT1_LCDA)) || (LCDwidth >= 600)) {

It might be that this was supposed to be:

		if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth <= 800) && (LCDwidth >= 600))) {

But why would people write a range from high to low?  That's crazy
people who write backwards code...

The second condition was supposed to do *something* although it's
unclear what.  I would normally say that we should leave the static
checker warning here instead of guessing.  Perhaps add a comment like
/* fixme:  huh?  What's with this nonsense condition? */  But in this
case it's all dead code because LCDwidth is always zero and the code
hasn't changed since 2.6.12 so I don't care.

regards,
dan carpenter

Re: [PATCH] video: fbdev: sis: init.c: Cleaning up redundant condition is always true

From: Noralf Tronnes <hidden>
Date: 2014-07-07 09:28:47

Den 07.07.2014 09:57, skrev Dan Carpenter:
On Thu, Jul 03, 2014 at 11:15:21PM +0200, Rickard Strandqvist wrote:
quoted
diff --git a/drivers/video/fbdev/sis/init.c b/drivers/video/fbdev/sis/init.c
index bd40f5e..9e2dd96 100644
--- a/drivers/video/fbdev/sis/init.c
+++ b/drivers/video/fbdev/sis/init.c
@@ -355,12 +355,12 @@ SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay,
  		}
  		break;
  	case 400:
-		if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 800) && (LCDwidth >= 600))) {
+		if ((!(VBFlags & CRT1_LCDA)) || (LCDwidth >= 600)) {
It might be that this was supposed to be:

		if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth <= 800) && (LCDwidth >= 600))) {

But why would people write a range from high to low?  That's crazy
people who write backwards code...
The numbers 800x600 (1024x768) indicate that LCDheight is meant to be used:
                  if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 800) && 
(LCDheight >= 600))) {

regards,
Noralf Tronnes

Re: [PATCH] video: fbdev: sis: init.c: Cleaning up redundant condition is always true

From: Rickard Strandqvist <hidden>
Date: 2014-07-07 20:36:40

2014-07-07 11:23 GMT+02:00 Noralf Tronnes [off-list ref]:
Den 07.07.2014 09:57, skrev Dan Carpenter:
quoted
On Thu, Jul 03, 2014 at 11:15:21PM +0200, Rickard Strandqvist wrote:
quoted
diff --git a/drivers/video/fbdev/sis/init.c
b/drivers/video/fbdev/sis/init.c
index bd40f5e..9e2dd96 100644
--- a/drivers/video/fbdev/sis/init.c
+++ b/drivers/video/fbdev/sis/init.c
@@ -355,12 +355,12 @@ SiS_GetModeID(int VGAEngine, unsigned int VBFlags,
int HDisplay, int VDisplay,
                }
                break;
        case 400:
-               if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 800) &&
(LCDwidth >= 600))) {
+               if ((!(VBFlags & CRT1_LCDA)) || (LCDwidth >= 600)) {

It might be that this was supposed to be:

                if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth <= 800) &&
(LCDwidth >= 600))) {

But why would people write a range from high to low?  That's crazy
people who write backwards code...
The numbers 800x600 (1024x768) indicate that LCDheight is meant to be used:
                 if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 800) &&
(LCDheight >= 600))) {

regards,
Noralf Tronnes
Hi

Nice, this is what is the point of fix this type of minor errors.
Sometimes you can find something more serious :)

New patch on the way!

Kind regards
Rickard Strandqvist
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help