mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] get rid of bcopy warning
@ 2003-08-13 18:36 Stephen Hemminger
  2003-08-13 19:20 ` Richard B. Johnson
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2003-08-13 18:36 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel

Get rid of warning because internal definition of bcopy
conflicts with builtin.  The warning is probably a bogus
bug of GCC 3.2.3, but the workaround is simple.

Almost no driver really uses bcopy anyway, and no code
uses the return value.

diff -Nru a/lib/string.c b/lib/string.c
--- a/lib/string.c	Wed Aug 13 11:31:13 2003
+++ b/lib/string.c	Wed Aug 13 11:31:13 2003
@@ -432,14 +432,13 @@
  * You should not use this function to access IO space, use memcpy_toio()
  * or memcpy_fromio() instead.
  */
-char * bcopy(const char * src, char * dest, int count)
+void bcopy(const void * src, void * dest, size_t count)
 {
+ 	const char *s = src;
 	char *tmp = dest;
 
 	while (count--)
-		*tmp++ = *src++;
-
-	return dest;
+		*tmp++ = *s++;
 }
 #endif
 

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

* Re: [PATCH] get rid of bcopy warning
  2003-08-13 18:36 [PATCH] get rid of bcopy warning Stephen Hemminger
@ 2003-08-13 19:20 ` Richard B. Johnson
  0 siblings, 0 replies; 2+ messages in thread
From: Richard B. Johnson @ 2003-08-13 19:20 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Linus Torvalds, linux-kernel

On Wed, 13 Aug 2003, Stephen Hemminger wrote:

> Get rid of warning because internal definition of bcopy
> conflicts with builtin.  The warning is probably a bogus
> bug of GCC 3.2.3, but the workaround is simple.
>
> Almost no driver really uses bcopy anyway, and no code
> uses the return value.

There should never have been a return value from a function
called bcopy() anyway.

>
> diff -Nru a/lib/string.c b/lib/string.c
> --- a/lib/string.c	Wed Aug 13 11:31:13 2003
> +++ b/lib/string.c	Wed Aug 13 11:31:13 2003
> @@ -432,14 +432,13 @@
>   * You should not use this function to access IO space, use memcpy_toio()
>   * or memcpy_fromio() instead.
>   */
> -char * bcopy(const char * src, char * dest, int count)
> +void bcopy(const void * src, void * dest, size_t count)
>  {
> + 	const char *s = src;
>  	char *tmp = dest;
>
>  	while (count--)
> -		*tmp++ = *src++;
> -
> -	return dest;
> +		*tmp++ = *s++;
>  }
>  #endif
>

This whole thing is bogus. bcopy() is supposed to handle
copies of overlapping buffers (IEEE Std 1003.1-2001).

This means that if destination is at a greater offset than the
source, the data has to be copied backwards. The code above
is broken.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
            Note 96.31% of all statistics are fiction.


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

end of thread, other threads:[~2003-08-13 19:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-13 18:36 [PATCH] get rid of bcopy warning Stephen Hemminger
2003-08-13 19:20 ` Richard B. Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®