All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] string lib redundancy and whitespace clarity fixes
@ 2005-02-10  0:32 Jonathan Ho
  2005-02-10  0:46 ` Chris Wright
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Ho @ 2005-02-10  0:32 UTC (permalink / raw)
  To: linux-kernel

Fixed some weird whitespace, solved redundancies (applies to v2.6.10).


Signed-off-by: Jonathan Ho <jonathanho15@gmail.com>


--- lib/string.c    Fri Dec 24 13:35:25 2004
+++ \documents and settings\jonathan\desktop/string.c    Wed Feb 09 
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;
 }
 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++) {
             if (*sc1 == *sc2)
-                return (char *) sc1;
+                return (char *)sc1;
         }
     }
     return NULL;
@@ -417,7 +417,7 @@ EXPORT_SYMBOL(strpbrk);
  * of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
  * Same semantics, slimmer shape. ;)
  */
-char * strsep(char **s, const char *ct)
+char *strsep(char **s, const char *ct)
 {
     char *sbegin = *s, *end;
 
@@ -444,9 +444,9 @@ EXPORT_SYMBOL(strsep);
  *
  * Do not use memset() to access IO space, use memset_io() instead.
  */
-void * memset(void * s,int c,size_t count)
+void *memset(void *s, int c, size_t count)
 {
-    char *xs = (char *) s;
+    char *xs = (char *)s;
 
     while (count--)
         *xs++ = c;
@@ -469,7 +469,7 @@ EXPORT_SYMBOL(memset);
  * You should not use this function to access IO space, use memcpy_toio()
  * or memcpy_fromio() instead.
  */
-void bcopy(const void * srcp, void * destp, size_t count)
+void bcopy(const void *srcp, void *destp, size_t count)
 {
     const char *src = srcp;
     char *dest = destp;
@@ -490,7 +490,7 @@ EXPORT_SYMBOL(bcopy);
  * You should not use this function to access IO space, use memcpy_toio()
  * or memcpy_fromio() instead.
  */
-void * memcpy(void * dest,const void *src,size_t count)
+void *memcpy(void *dest, const void *src, size_t count)
 {
     char *tmp = (char *) dest, *s = (char *) src;
 
@@ -563,17 +563,17 @@ EXPORT_SYMBOL(memcmp);
  * returns the address of the first occurrence of @c, or 1 byte past
  * the area if @c is not found
  */
-void * memscan(void * addr, int c, size_t size)
+void *memscan(void *addr, int c, size_t size)
 {
-    unsigned char * p = (unsigned char *) addr;
+    unsigned char *p = (unsigned char *)addr;
 
     while (size) {
         if (*p == c)
-            return (void *) p;
+            return (void *)p;
         p++;
         size--;
     }
-      return (void *) p;
+      return (void *)p;
 }
 EXPORT_SYMBOL(memscan);
 #endif
@@ -584,18 +584,18 @@ EXPORT_SYMBOL(memscan);
  * @s1: The string to be searched
  * @s2: The string to search for
  */
-char * strstr(const char * s1,const char * s2)
+char *strstr(const char *s1, const char *s2)
 {
     int l1, l2;
 
     l2 = strlen(s2);
     if (!l2)
-        return (char *) s1;
+        return (char *)s1;
     l1 = strlen(s1);
     while (l1 >= l2) {
         l1--;
-        if (!memcmp(s1,s2,l2))
-            return (char *) s1;
+        if (!memcmp(s1, s2, l2))
+            return (char *)s1;
         s1++;
     }
     return NULL;
@@ -618,7 +618,7 @@ void *memchr(const void *s, int c, size_
     const unsigned char *p = s;
     while (n-- != 0) {
             if ((unsigned char)c == *p++) {
-            return (void *)(p-1);
+            return (void *)(p - 1);
         }
     }
     return NULL;


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

* Re: [PATCH] string lib redundancy and whitespace clarity fixes
  2005-02-10  0:32 [PATCH] string lib redundancy and whitespace clarity fixes Jonathan Ho
@ 2005-02-10  0:46 ` Chris Wright
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Wright @ 2005-02-10  0:46 UTC (permalink / raw)
  To: Jonathan Ho; +Cc: linux-kernel

* Jonathan Ho (jonathanho15@gmail.com) wrote:
> Fixed some weird whitespace, solved redundancies (applies to v2.6.10).
> 
> Signed-off-by: Jonathan Ho <jonathanho15@gmail.com>
> 
> --- 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

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

end of thread, other threads:[~2005-02-10  0:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-10  0:32 [PATCH] string lib redundancy and whitespace clarity fixes Jonathan Ho
2005-02-10  0:46 ` Chris Wright

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.