Skip to contentSkip to conversation

commit d354899 (Fix OpenBSD linker warning, 2010-02-23)

Qemu-devel Paolo Bonzini 2 participants 3 messages Feb 25, 2010

lore
Share & tools
lore
#0 lore raw

Review

Quoted 5 lines
(quoted diff) +3 -2
-                if (b)
-                    sprintf(b, "...");
+                if (b) {
+                    memcpy(b, "...", sizeof("..."));
+                }

What's wrong with strcpy? :-) (I doubt OpenBSD warns about that too).

Paolo

#1 lore raw
Quoted 8 lines · Paolo Bonzini

Review

Quoted 6 lines
(quoted diff) +3 -2
-                if (b)
-                    sprintf(b, "...");
+                if (b) {
+                    memcpy(b, "...", sizeof("..."));
+                }

What's wrong with strcpy? :-) (I doubt OpenBSD warns about that too).

But of course, with code containing strcpy() you get this:
LINK i386-softmmu/qemu
i386-dis.o(.text+0x3aac): In function `oappend':
/src/qemu/i386-dis.c:4656: warning: strcpy() is almost always misused, p lease use strlcpy()
/usr/X11R6/lib/libX11.so.11.2: warning: strcat() is almost always misuse d, please use strlcat()
/usr/X11R6/lib/libX11.so.11.2: warning: sprintf() is often misused, plea se use snprintf()

With clean code, the only warnings come from X11 libraries:
LINK sparc64-softmmu/qemu-system-sparc64
/usr/X11R6/lib/libX11.so.11.2: warning: strcpy() is almost always misuse d, please use strlcpy()
/usr/X11R6/lib/libX11.so.11.2: warning: strcat() is almost always misuse d, please use strlcat()
/usr/X11R6/lib/libX11.so.11.2: warning: sprintf() is often misused, plea se use snprintf()

#2 lore raw
Quoted 9 lines · Blue Swirl
Quoted 2 lines
Quoted 2 lines

What's wrong with strcpy?:-) (I doubt OpenBSD warns about that too).

But of course, with code containing strcpy() you get this:
LINK i386-softmmu/qemu
i386-dis.o(.text+0x3aac): In function `oappend':
/src/qemu/i386-dis.c:4656: warning: strcpy() is almost always misused, p lease use strlcpy()
/usr/X11R6/lib/libX11.so.11.2: warning: strcat() is almost always misuse d, please use strlcat()

That's debatable to say the least, but anyway thanks for correcting me. :-)