Skip to contentSkip to conversation

get rid of bcopy warning

PATCH In review Stephen Hemminger 2 participants 2 messages Aug 13, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 get rid of bcopy warning

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.

lib/string.c +3 -4
diff -Nru a/lib/string.c b/lib/string.c
@@ -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
 
#1 lore raw
Quoted 6 lines · Stephen Hemminger

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.

Quoted 12 lines

diff -Nru a/lib/string.c b/lib/string.c

lib/string.c +2 -1
@@ -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;

lib/string.c line 444

Quoted 10 lines
lib/string.c +1 -3
 	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.