Re: [PATCH] string lib redundancy and whitespace clarity fixes

From: Chris Wright
Date: Wed Feb 09 2005 - 19:46:53 EST


* Jonathan Ho (jonathanho15@xxxxxxxxx) wrote:
> Fixed some weird whitespace, solved redundancies (applies to v2.6.10).
>
> Signed-off-by: Jonathan Ho <jonathanho15@xxxxxxxxx>
>
> --- lib/string.c Fri Dec 24 13:35:25 2004
> +++ \documents and settings\jonathan\desktop/string.c Wed Feb 09

This won't apply nicely with -p1. Nor will it apply against
current -bk (which no longer has bcopy in it, for example).

> 16:21:28 2005
> @@ -38,7 +38,7 @@ int strnicmp(const char *s1, const char
> /* Yes, Virginia, it had better be unsigned */
> unsigned char c1, c2;
>
> - c1 = 0; c2 = 0;
> + c1 = c2 = 0;
> if (len) {
> do {
> c1 = *s1; c2 = *s2;
> @@ -253,12 +253,12 @@ EXPORT_SYMBOL(strncmp);
> * @s: The string to be searched
> * @c: The character to search for
> */
> -char * strchr(const char * s, int c)
> +char *strchr(const char * s, int c)
> {
> - for(; *s != (char) c; ++s)
> + for( ; *s != (char) c; s++)
> if (*s == '\0')
> return NULL;
> - return (char *) s;
> + return (char *)s;

For this kind of CodingStyle cleanup, I think it's probably not worth it.
Unless you have other changes and fixes planned in the area.

> }
> EXPORT_SYMBOL(strchr);
> #endif
> @@ -390,14 +390,14 @@ EXPORT_SYMBOL(strcspn);
> * @cs: The string to be searched
> * @ct: The characters to search for
> */
> -char * strpbrk(const char * cs,const char * ct)
> +char * strpbrk(const char *cs, const char *ct)
> {
> - const char *sc1,*sc2;
> + const char *sc1, *sc2;
>
> - for( sc1 = cs; *sc1 != '\0'; ++sc1) {
> - for( sc2 = ct; *sc2 != '\0'; ++sc2) {
> + for(sc1 = cs; *sc1 != '\0'; sc1++) {
> + for(sc2 = ct; *sc2 != '\0'; sc2++) {

Neither of these is CodingStyle compliant ;-) Take a look at what
Lindent does (not perfect, but good rule of thumb).

thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/