diff mbox

[U-Boot,2/2] common/xyzModem.c: Do not use hard-coded address for debug buffer

Message ID 20170404174231.367-2-alex.g@adaptrum.com
State Accepted
Commit b09ece0836e0267b86f37defec267aa3806cb03a
Delegated to: Tom Rini
Headers show

Commit Message

Alexandru Gagniuc April 4, 2017, 5:42 p.m. UTC
Under the plethora of #ifdefs, the xyzModem code hid this pearl:
static char *zm_out = (char *) 0x00380000;
This was only enabled when DEBUG is defined, so it's probably why it
went unnoticed for so long. No idea what platform had memory at that
exact location, but the this approach is extremely hacky.
Use a static buffer instead.

Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
---
 common/xyzModem.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

Comments

Tom Rini April 9, 2017, 1:15 a.m. UTC | #1
On Tue, Apr 04, 2017 at 10:42:31AM -0700, Alexandru Gagniuc wrote:

> Under the plethora of #ifdefs, the xyzModem code hid this pearl:
> static char *zm_out = (char *) 0x00380000;
> This was only enabled when DEBUG is defined, so it's probably why it
> went unnoticed for so long. No idea what platform had memory at that
> exact location, but the this approach is extremely hacky.
> Use a static buffer instead.
> 
> Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/common/xyzModem.c b/common/xyzModem.c
index 6ded958..a0c5dfe 100644
--- a/common/xyzModem.c
+++ b/common/xyzModem.c
@@ -176,16 +176,10 @@  parse_num (char *s, unsigned long *val, char **es, char *delim)
 /*
  * Note: this debug setup works by storing the strings in a fixed buffer
  */
-#define FINAL
-#ifdef FINAL
-static char *zm_out = (char *) 0x00380000;
-static char *zm_out_start = (char *) 0x00380000;
-#else
-static char zm_buf[8192];
-static char *zm_out = zm_buf;
-static char *zm_out_start = zm_buf;
+static char zm_debug_buf[8192];
+static char *zm_out = zm_debug_buf;
+static char *zm_out_start = zm_debug_buf;
 
-#endif
 static int
 zm_dprintf (char *fmt, ...)
 {