public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] memmove_wd: Allow overlapping memory area
@ 2010-07-21  8:43 Alexander Stein
  2010-08-08 22:18 ` Wolfgang Denk
  2010-08-08 22:20 ` Wolfgang Denk
  0 siblings, 2 replies; 9+ messages in thread
From: Alexander Stein @ 2010-07-21  8:43 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
---
 common/image.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/common/image.c b/common/image.c
index 6d8833e..da0fdd5 100644
--- a/common/image.c
+++ b/common/image.c
@@ -456,9 +456,14 @@ void memmove_wd (void *to, void *from, size_t len, ulong chunksz)
 	while (len > 0) {
 		size_t tail = (len > chunksz) ? chunksz : len;
 		WATCHDOG_RESET ();
-		memmove (to, from, tail);
-		to += tail;
-		from += tail;
+		if (to <= from)
+		{
+			memmove (to, from, tail);
+			to += tail;
+			from += tail;
+		} else {
+			memmove (to + len - tail, from + len - tail, tail);
+		}
 		len -= tail;
 	}
 #else	/* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-08-09 12:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-21  8:43 [U-Boot] [PATCH] memmove_wd: Allow overlapping memory area Alexander Stein
2010-08-08 22:18 ` Wolfgang Denk
2010-08-09  6:57   ` Alexander Stein
2010-08-09  9:26     ` Wolfgang Denk
2010-08-09 11:10       ` Alexander Stein
2010-08-09 11:43         ` Wolfgang Denk
2010-08-09 11:51           ` Alexander Stein
2010-08-09 12:27             ` Wolfgang Denk
2010-08-08 22:20 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox