powerpc/prom_init: Move custom isspace() to its own namespace
PATCH 1/1 powerpc/prom_init: Move custom isspace() to its own namespace
If by some reason any of the headers will include ctype.h we will have a name collision. Avoid this by moving isspace() to the dedicate namespace.
First appearance of the code is in the commit cf68787b68a2 ("powerpc/prom_init: Evaluate mem kernel parameter for early allocation").
--- arch/powerpc/kernel/prom_init.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
arch/powerpc/kernel/prom_init.c +9 -9
@@ -701,13 +701,13 @@ static int __init prom_setprop(phandle node, const char *nodename, }/* We can't use the standard versions because of relocation headaches. */ -#define isxdigit (c) (('0' <= (c) && (c) <= '9') \ - || ('a' <= (c) && (c) <= 'f') \ - || ('A' <= (c) && (c) <= 'F')) +#define prom_isxdigit (c) (('0' <= (c) && (c) <= '9') \ + || ('a' <= (c) && (c) <= 'f') \ + || ('A' <= (c) && (c) <= 'F')) -#define isdigit (c) ('0' <= (c) && (c) <= '9') -#define islower (c) ('a' <= (c) && (c) <= 'z') -#define toupper (c) (islower(c) ? ((c) - 'a' + 'A') : (c)) +#define prom_isdigit (c) ('0' <= (c) && (c) <= '9') +#define prom_islower (c) ('a' <= (c) && (c) <= 'z') +#define prom_toupper (c) (prom_islower(c) ? ((c) - 'a' + 'A') : (c))static unsigned long prom_strtoul (const char *cp,const char **endp) {
@@ -716,14 +716,14 @@ static unsigned long prom_strtoul(const char *cp, const char **endp)if (*cp =='0' ) { base =8 ; cp++; -if (toupper (*cp) =='X' ) { +if (prom_toupper (*cp) =='X' ) { cp++; base =16 ; } } -while (isxdigit (*cp) && - (value =isdigit (*cp) ? *cp -'0' :toupper (*cp) -'A' +10 ) < base) { +while (prom_isxdigit (*cp) && + (value =prom_isdigit (*cp) ? *cp -'0' :prom_toupper (*cp) -'A' +10 ) < base) { result = result * base + value; cp++; }
Signature · 1 line
2.30.2
Quoted 6 lines · Andy Shevchenko
If by some reason any of the headers will include
ctype.hwe will have a name collision. Avoid this by movingisspace()to the dedicate namespace.First appearance of the code is in the commit
cf68787b68a2("powerpc/prom_init: Evaluate mem kernel parameter for early allocation").
Any comments on this?
Quoted 51 lines
Reported-by kernel test robot <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- arch/powerpc/kernel/prom_init.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)arch/powerpc/kernel/prom_init.c +9
-9@@ -701,13 +701,13 @@ static int __init prom_setprop(phandle node, const char *nodename, }/* We can't use the standard versions because of relocation headaches. */ -#define isxdigit (c) (('0' <= (c) && (c) <= '9') \ - || ('a' <= (c) && (c) <= 'f') \ - || ('A' <= (c) && (c) <= 'F')) +#define prom_isxdigit (c) (('0' <= (c) && (c) <= '9') \ + || ('a' <= (c) && (c) <= 'f') \ + || ('A' <= (c) && (c) <= 'F')) -#define isdigit (c) ('0' <= (c) && (c) <= '9') -#define islower (c) ('a' <= (c) && (c) <= 'z') -#define toupper (c) (islower(c) ? ((c) - 'a' + 'A') : (c)) +#define prom_isdigit (c) ('0' <= (c) && (c) <= '9') +#define prom_islower (c) ('a' <= (c) && (c) <= 'z') +#define prom_toupper (c) (prom_islower(c) ? ((c) - 'a' + 'A') : (c))static unsigned long prom_strtoul (const char *cp,const char **endp) {@@ -716,14 +716,14 @@ static unsigned long prom_strtoul(const char *cp, const char **endp)if (*cp =='0' ) { base =8 ; cp++; -if (toupper (*cp) =='X' ) { +if (prom_toupper (*cp) =='X' ) { cp++; base =16 ; } } -while (isxdigit (*cp) && - (value =isdigit (*cp) ? *cp -'0' :toupper (*cp) -'A' +10 ) < base) { +while (prom_isxdigit (*cp) && + (value =prom_isdigit (*cp) ? *cp -'0' :prom_toupper (*cp) -'A' +10 ) < base) { result = result * base + value; cp++; }Signature · 1 line
2.30.2
Signature · 2 lines
With Best Regards, Andy Shevchenko
Michael Ellerman
reviewerQuoted 9 lines · Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
If by some reason any of the headers will include
ctype.hwe will have a name collision. Avoid this by movingisspace()to the dedicate namespace.First appearance of the code is in the commit
cf68787b68a2("powerpc/prom_init: Evaluate mem kernel parameter for early allocation").Any comments on this?
Looks fine. Thanks.
I just missed it because it came in a bit early, I tend not to pick things up until rc2.
I tweaked the formatting of prom_isxdigit() slightly now that we allow 100 column lines.
Have put it in my next-test now.
cheers
Quoted 49 lines
Quoted 45 lines
arch/powerpc/kernel/prom_init.c +9
-9@@ -701,13 +701,13 @@ static int __init prom_setprop(phandle node, const char *nodename, }/* We can't use the standard versions because of relocation headaches. */ -#define isxdigit (c) (('0' <= (c) && (c) <= '9') \ - || ('a' <= (c) && (c) <= 'f') \ - || ('A' <= (c) && (c) <= 'F')) +#define prom_isxdigit (c) (('0' <= (c) && (c) <= '9') \ + || ('a' <= (c) && (c) <= 'f') \ + || ('A' <= (c) && (c) <= 'F')) -#define isdigit (c) ('0' <= (c) && (c) <= '9') -#define islower (c) ('a' <= (c) && (c) <= 'z') -#define toupper (c) (islower(c) ? ((c) - 'a' + 'A') : (c)) +#define prom_isdigit (c) ('0' <= (c) && (c) <= '9') +#define prom_islower (c) ('a' <= (c) && (c) <= 'z') +#define prom_toupper (c) (prom_islower(c) ? ((c) - 'a' + 'A') : (c))static unsigned long prom_strtoul (const char *cp,const char **endp) {@@ -716,14 +716,14 @@ static unsigned long prom_strtoul(const char *cp, const char **endp)if (*cp =='0' ) { base =8 ; cp++; -if (toupper (*cp) =='X' ) { +if (prom_toupper (*cp) =='X' ) { cp++; base =16 ; } } -while (isxdigit (*cp) && - (value =isdigit (*cp) ? *cp -'0' :toupper (*cp) -'A' +10 ) < base) { +while (prom_isxdigit (*cp) && + (value =prom_isdigit (*cp) ? *cp -'0' :prom_toupper (*cp) -'A' +10 ) < base) { result = result * base + value; cp++; }Signature · 1 line
2.30.2Signature · 2 lines
With Best Regards, Andy Shevchenko
Michael Ellerman
AppliedQuoted 6 lines · Andy Shevchenko
If by some reason any of the headers will include
ctype.hwe will have a name collision. Avoid this by movingisspace()to the dedicate namespace.First appearance of the code is in the commit
cf68787b68a2("powerpc/prom_init: Evaluate mem kernel parameter for early allocation").
Applied to powerpc/next.
[1/1] powerpc/prom_init: Move custom isspace() to its own namespace
https://git.kernel.org/powerpc/c/4cfdd9201cfb85538975f5c8fb83941c3d463ed2
cheers