newfs_hammer(8): fix [-Wsizeof-pointer-memaccess]
authorJohn Marino <draco@marino.st>
Tue, 10 Feb 2015 20:57:32 +0000 (21:57 +0100)
committerJohn Marino <draco@marino.st>
Tue, 10 Feb 2015 20:57:32 +0000 (21:57 +0100)
The device type comparison only worked by accident on x86-64 and not
reliability on i386 because the sizeof function returned the size of
the address rather than the size of the vol->type string.  Fix by
specifying the size of "DEVICE" to strncmp instead.

sbin/newfs_hammer/newfs_hammer.c

index 80cb51b..f0a3920 100644 (file)
@@ -425,7 +425,7 @@ static
 void
 trim_volume(struct volume_info *vol)
 {
-       if (strncmp(vol->type, "DEVICE", sizeof(vol->type)) == 0) {
+       if (strncmp(vol->type, "DEVICE", sizeof("DEVICE")) == 0) {
                off_t ioarg[2];
                
                /* 1MB offset to prevent destroying disk-reserved area */