[PATCH 4/4] ARM: zImage: allow supplementing appended DTB with traditional ATAG data

From
Warner Losh <hidden>
Date
2011-06-21 23:22:40
Also in
linux-devicetree
On Jun 21, 2011, at 5:13 PM, David Brown wrote:
On Tue, Jun 21 2011, David Brown wrote:
quoted
On Mon, Jun 20 2011, Nicolas Pitre wrote:
quoted
+void *memmove(void *__dest, __const void *__src, size_t __n)
+{
+	unsigned char *d = __dest;
+	const unsigned char *s = __src;
+
+	if (__dest == __src)
+		return __dest;
+
+	if (__dest < __src)
+		return memcpy(__dest, __src, __n);
+
+	while (--__n >= 0)
+		d[__n] = s[__n];
+
+	return __dest;
+}
Ahh, found it.  size_t is unsigned, so the while loop never terminates.
Something like:

	for (; __n; __n--)
		d[__n] = s[__n];
Ugh.  How about if I don't replace a broken version with a different
broken version.

	while (__n) {
		__n--;
               d[__n] = s[__n];
	}

Now, I don't need any extra fields in my DTB, and it correctly inserts
the ATAG values.

while (__n--)
	d[__n] = s[__n];

does the same thing, and is more readable (and does the same thing as the original while())

Warner
Thread (1 message) 1 message, 1 author, last reply 2011-06-21
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help