MIPS: decompressor: fix build failure on memcpy() in decompress.c
PATCH 1/1 MIPS: decompressor: fix build failure on memcpy() in decompress.c
The decompress.c file includes linux/kernel.h which causes the following inclusion chain to be pulled:linux/kernel.h ->
linux/dynamic_debug.h -> linux/string.h -> asm/string.h
We end up having a the GCC builtin + architecture specific memcpy() expanding into this:
void *({ size_t __len = (size_t n); void *__ret; if (__builtin_constant_p(size_t n) && __len >= 64) __ret = memcpy((void *dest), (const void *src), __len); else __ret = __builtin_memcpy((void *dest), (const void *src), __len); __ret; })
{
[memcpy implementation in decompress.c starts here]
int i;
const char *s = src;
char *d = dest;
for (i = 0; i < n; i++)
d[i] = s[i];
return dest;
}
raising the following compilation error:arch/mips/boot/compressed/decompress.c:46:8: error: expected identifier or '(' before '{' token
There are at least three possibilities to fix this issue:
1) define _LINUX_STRING_H_ at the beginning of decompress.c to prevent further linux/string.h definitions and declarations from being used, and add an explicit strstr() declaration for linux/dynamic_debug.h
2) remove the inclusion of linux/kernel.h because we actually use no definition or declaration from this header file
3) undefine memcpy or re-define memcpy to memcpy thus resulting in picking up the local memcpy() implementation to this compilation unit
This patch uses the second option which is the less intrusive one.
--- arch/mips/boot/compressed/decompress.c | 2 -- 1 file changed, 2 deletions(-)
arch/mips/boot/compressed/decompress.c +0 -2
@@ -10,9 +10,7 @@* Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ -#include <linux/types.h> -#include <linux/kernel.h> #include <asm/addrspace.h>
Signature · 1 line
1.7.10.4
Quoted 7 lines · On Monday 12 November 2012 12:46:58 Florian Fainelli wrote:
The
decompress.cfile includeslinux/kernel.hwhich causes the following inclusion chain to be pulled:linux/kernel.h->linux/dynamic_debug.h -> linux/string.h -> asm/string.h
Quoted 7 lines
We end up having a the GCC builtin + architecture specific
memcpy()expanding into this:void *({
size_t__len= (size_tn); void*__ret; if (__builtin_constant_p(size_t n)&&__len>= 64)__ret=memcpy((void *dest), (const void *src), __len); else__ret=__builtin_memcpy((void *dest), (const void *src), __len);__ret; })
After some more debugging, this expansion "failure" actually comes from one of our OpenWrt patch which allows the use of GCC builtins for memcpy and friends. The fix remains valid anyway.
Quoted 51 lines
{
[memcpy implementation indecompress.cstarts here] int i;
const char *s = src;
char *d = dest;for (i = 0; i < n; i++)
d[i] = s[i];
return dest;
}raising the following compilation error:
arch/mips/boot/compressed/decompress.c:46:8: error: expected identifier or '(' before '{' tokenThere are at least three possibilities to fix this issue:
1) define _LINUX_STRING_H_ at the beginning of
decompress.cto prevent furtherlinux/string.hdefinitions and declarations from being used, and add an explicitstrstr()declaration forlinux/dynamic_debug.h2) remove the inclusion of
linux/kernel.hbecause we actually use no definition or declaration from this header file3) undefine memcpy or re-define memcpy to memcpy thus resulting in picking up the local
memcpy()implementation to this compilation unitThis patch uses the second option which is the less intrusive one.
Signed-off-by Florian Fainelli <[email protected]>--- arch/mips/boot/compressed/decompress.c | 2 -- 1 file changed, 2 deletions(-)arch/mips/boot/compressed/decompress.c +0
-2@@ -10,9 +10,7 @@* Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ -#include <linux/types.h> -#include <linux/kernel.h> #include <asm/addrspace.h> Signature · 1 line
1.7.10.4
PATCH v2 1/1 MIPS: decompressor: remove unused linux/kernel.h header
In reply to Florian FainelliThe decompress.c file includes linux/kernel.h which causes the following inclusion chain to be pulled:linux/kernel.h ->
linux/dynamic_debug.h -> linux/string.h -> asm/string.h
We might end up having a conflicting memcpy() and memset() pulled from asm/string.h, since we use no declaration from linux/kernel.h, just remove this include.
---
Changes since v1:
- removed the long story about the problem we are fixing
- only remove the linux/kernel.h line
arch/mips/boot/compressed/decompress.c | 1 - 1 file changed, 1 deletion(-)
arch/mips/boot/compressed/decompress.c +0 -1
@@ -12,7 +12,6 @@*/ #include <linux/types.h> -#include <linux/kernel.h> #include <asm/addrspace.h>
Signature · 1 line
1.7.10.4