Skip to contentSkip to conversation

eliminate errors about unused results in block/vpc.c

PATCH In review Nathan Froyd 2 participants 2 messages Aug 3, 2009 – Aug 10, 2009 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eliminate errors about unused results in block/vpc.c

These errors come up when compiling with gcc-4.3.3 and some older headers:

/scratch/froydnj/qemu.git/block/vpc.c: In function 'vpc_create':
/scratch/froydnj/qemu.git/block/vpc.c:514: error: value computed is not used /scratch/froydnj/qemu.git/block/vpc.c:516: error: value computed is not used /scratch/froydnj/qemu.git/block/vpc.c:517: error: value computed is not used /scratch/froydnj/qemu.git/block/vpc.c:566: error: value computed is not used

Just add void casts to silence the compiler.

---
 block/vpc.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

v2: resent, including Signed-off-by this time.

block/vpc.c +4 -4
index ba482e9..b67e9ce 100644
@@ -511,10 +511,10 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options)
     // Prepare the Hard Disk Footer
     memset(buf, 0, 1024);
 
-    strncpy(footer->creator, "conectix", 8);
+    (void) strncpy(footer->creator, "conectix", 8);
     // TODO Check if "qemu" creator_app is ok for VPC
-    strncpy(footer->creator_app, "qemu", 4);
-    strncpy(footer->creator_os, "Wi2k", 4);
+    (void) strncpy(footer->creator_app, "qemu", 4);
+    (void) strncpy(footer->creator_os, "Wi2k", 4);
 
     footer->features = be32_to_cpu(0x02);
     footer->version = be32_to_cpu(0x00010000);
@@ -563,7 +563,7 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options)
     // Prepare the Dynamic Disk Header
     memset(buf, 0, 1024);
 
-    strncpy(dyndisk_header->magic, "cxsparse", 8);
+    (void) strncpy(dyndisk_header->magic, "cxsparse", 8);
 
     dyndisk_header->data_offset = be64_to_cpu(0xFFFFFFFF);
     dyndisk_header->table_offset = be64_to_cpu(3 * 512);
Signature · 1 line
1.6.3.2
#1 lore raw
Quoted 8 lines · Nathan Froyd

These errors come up when compiling with gcc-4.3.3 and some older headers:

/scratch/froydnj/qemu.git/block/vpc.c: In function 'vpc_create':
/scratch/froydnj/qemu.git/block/vpc.c:514: error: value computed is not used /scratch/froydnj/qemu.git/block/vpc.c:516: error: value computed is not used /scratch/froydnj/qemu.git/block/vpc.c:517: error: value computed is not used /scratch/froydnj/qemu.git/block/vpc.c:566: error: value computed is not used

Quoted 4 lines

Just add void casts to silence the compiler.

Adding code to silence warnings is never the right approach. In this case, strncpy is the wrong function to use. We should just be using memcpy.

Regards,

Anthony Liguori