Skip to contentSkip to conversation

board/purple/flash.c: removed unneded test

PATCH New Frans Meulenbroeks 3 participants 7 messages Jul 31, 2010 – Aug 8, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 board/purple/flash.c: removed unneded test

removed part of a test which tested for a var that did not change within the loop and hence was superfluous

---
 board/purple/flash.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
board/purple/flash.c +1 -1
index 37c7bec..299171d 100644
@@ -490,7 +490,7 @@ int	flash_erase (flash_info_t *info, int s_first, int s_last)
 	last  = get_timer(0);
 
 	/* Start erase on unprotected sectors */
-	for (sect = s_first; sect<=s_last && rcode == 0; sect++) {
+	for (sect = s_first; sect<=s_last; sect++) {
 
 		if (info->protect[sect] != 0)	/* protected, skip it */
 			continue;
Signature · 1 line
1.6.4.2
#1 lore raw

PATCH 1/1 board/purple/flash.c: removed unneded test

Dear Frans Meulenbroeks,

Quoted 2 lines · In message <[email protected]> you…

removed part of a test which tested for a var that did not change within the loop and hence was superfluous

Hm... if you check the code, you see that the other "references" to this variable are not exactly making much sense either. And the function does not return any useful error codes.

Looks as if this never was really thought to an end...

If you touch this file, we should throw out rcode completely.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
In accord with UNIX philosophy, Perl gives you enough  rope  to  hang
yourself.              - L. Wall & R. L. Schwartz, _Programming Perl_
#2 lore raw

PATCH 1/1 board/purple/flash.c: removed unneded test

2010/7/31 Wolfgang Denk <[email protected]>

Quoted 7 lines

Dear Frans Meulenbroeks,

In message <[email protected]>

Quoted 2 lines · you

removed part of a test which tested for a var that did not change within the loop and hence was superfluous

Quoted 8 lines

Hm... if you check the code, you see that the other "references" to this variable are not exactly making much sense either. And the function does not return any useful error codes.

Looks as if this never was really thought to an end...

If you touch this file, we should throw out rcode completely.

I can do that, no problem.
Actually I noticed that the rest of the code didn't make much sense but at least it does not add to the footprint or execution time. (thinking of it, maybe the code I removed was optimised away anyway).

And as I was unware whether the coding style demanded a return variable. That is why I left it untouched.

Frans.

PS: I have no particular binding with this code. I don't happen to have this hardware.
Just saw an optimisation/cleanup opportunity and decided to fix it.

#3 lore raw

PATCH 1/1 board/purple/flash.c: removed unneded variable

removed a variable that was not used

---

This supersedes 0001-board-purple-flash.c-removed-unneded-test.patch submitted yesterday

 board/purple/flash.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
board/purple/flash.c +2 -3
index 37c7bec..5cee35e 100644
@@ -448,7 +448,6 @@ int	flash_erase (flash_info_t *info, int s_first, int s_last)
 	FPWV *addr;
 	int flag, prot, sect;
 	ulong start, now, last;
-	int rcode = 0;
 	FUNCPTR_WR absEntry;
 
 	load_cmd(IN_RAM_CMD_WRITE);
@@ -490,7 +489,7 @@ int	flash_erase (flash_info_t *info, int s_first, int s_last)
 	last  = get_timer(0);
 
 	/* Start erase on unprotected sectors */
-	for (sect = s_first; sect<=s_last && rcode == 0; sect++) {
+	for (sect = s_first; sect<=s_last; sect++) {
 
 		if (info->protect[sect] != 0)	/* protected, skip it */
 			continue;
@@ -523,7 +522,7 @@ int	flash_erase (flash_info_t *info, int s_first, int s_last)
 	}
 
 	printf (" done\n");
-	return rcode;
+	return 0;
 }
 
 /*-----------------------------------------------------------------------
Signature · 1 line
1.6.4.2
#4 lore raw

PATCH 1/1 board/purple/flash.c: removed unneded variable

Hello.

Quoted 3 lines · Frans Meulenbroeks

removed a variable that was not used

[...]

Quoted 4 lines
board/purple/flash.c +0 -0
index 37c7bec..5cee35e 100644

[...]

board/purple/flash.c int flash_erase (flash_info_t *info, int s_first, int s_last) · line 492

Quoted 6 lines
board/purple/flash.c +1 -1
@@ -490,7 +489,7 @@ int	flash_erase (flash_info_t *info, int s_first, int s_last)
 	last  = get_timer(0);
 
 	/* Start erase on unprotected sectors */
-	for (sect = s_first; sect<=s_last && rcode == 0; sect++) {
+	for (sect = s_first; sect<=s_last; sect++) {

High time to insert space before and after <=...

WBR, Sergei

#5 lore raw

PATCH 1/1 board/purple/flash.c: removed unneded variable

2010/8/1 Sergei Shtylyov <[email protected]>

Quoted 29 lines

Hello.

Frans Meulenbroeks wrote:

removed a variable that was not used

Quoted 1 line
Quoted 1 line

[...]

diff --git a/board/purple/flash.c b/board/purple/flash.c

board/purple/flash.c

Quoted 4 lines

index 37c7bec..5cee35e 100644

board/purple/flash.c +0 -0

[...]

@@ -490,7 +489,7 @@ int flash_erase (flash_info_t *info, int s_first, int

board/purple/flash.c int flash_erase (flash_info_t *info, int s_first, int s_last) · line 492

Quoted 6 lines

s_last)

       last  = get_timer(0);
       /* Start erase on unprotected sectors */
board/purple/flash.c +1 -1
-       for (sect = s_first; sect<=s_last && rcode == 0; sect++) {
+       for (sect = s_first; sect<=s_last; sect++) {
Quoted 5 lines

High time to insert space before and after <=...

WBR, Sergei

Be my guest :-)
I happen to bump onto the variable issue and decided to fix it, but have no binding with this board (I don't even know what kind of board it is, and I have no desire or intention to clean this up)

BTW: if layout is deemed so important I suggest running the code through a prettyprinter/layout program/code beautifier.

Have fun! Frans

#6 lore raw

PATCH 1/1 board/purple/flash.c: removed unneded variable

In reply to Frans Meulenbroeks

Dear Frans Meulenbroeks,

Quoted 9 lines · In message <[email protected]> you…

removed a variable that was not used

---

This supersedes 0001-board-purple-flash.c-removed-unneded-test.patch submitted yesterday

 board/purple/flash.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Microsoft Compatibility:
     your old Windows 3.11 application crash exactly as the new ones.