* [Qemu-devel] [PATCH] eliminate errors about unused results in block/vpc.c
@ 2009-07-21 14:15 Nathan Froyd
2009-07-22 15:05 ` Anthony Liguori
0 siblings, 1 reply; 6+ messages in thread
From: Nathan Froyd @ 2009-07-21 14:15 UTC (permalink / raw)
To: qemu-devel
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(-)
diff --git a/block/vpc.c b/block/vpc.c
index ba482e9..b67e9ce 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -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);
--
1.6.2.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] eliminate errors about unused results in block/vpc.c
2009-07-21 14:15 [Qemu-devel] [PATCH] eliminate errors about unused results in block/vpc.c Nathan Froyd
@ 2009-07-22 15:05 ` Anthony Liguori
2009-07-22 15:50 ` Nathan Froyd
0 siblings, 1 reply; 6+ messages in thread
From: Anthony Liguori @ 2009-07-22 15:05 UTC (permalink / raw)
To: Nathan Froyd; +Cc: qemu-devel
Nathan Froyd wrote:
> 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.
Needs a Signed-off-by
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] eliminate errors about unused results in block/vpc.c
2009-07-22 15:05 ` Anthony Liguori
@ 2009-07-22 15:50 ` Nathan Froyd
0 siblings, 0 replies; 6+ messages in thread
From: Nathan Froyd @ 2009-07-22 15:50 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel
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.
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
---
block/vpc.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
[...thought format.signoff would work in all cases, but apparently not...]
diff --git a/block/vpc.c b/block/vpc.c
index ba482e9..b67e9ce 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -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);
--
1.6.2.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH] eliminate errors about unused results in block/vpc.c
@ 2009-08-03 14:32 Nathan Froyd
2009-08-10 14:39 ` Anthony Liguori
0 siblings, 1 reply; 6+ messages in thread
From: Nathan Froyd @ 2009-08-03 14:32 UTC (permalink / raw)
To: qemu-devel
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.
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
---
block/vpc.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
v2: resent, including Signed-off-by this time.
diff --git a/block/vpc.c b/block/vpc.c
index ba482e9..b67e9ce 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -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);
--
1.6.3.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] eliminate errors about unused results in block/vpc.c
2009-08-03 14:32 Nathan Froyd
@ 2009-08-10 14:39 ` Anthony Liguori
0 siblings, 0 replies; 6+ messages in thread
From: Anthony Liguori @ 2009-08-10 14:39 UTC (permalink / raw)
To: Nathan Froyd; +Cc: qemu-devel
Nathan Froyd wrote:
> 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.
>
> Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
>
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH] eliminate errors about unused results in block/vpc.c
@ 2009-08-11 19:47 Nathan Froyd
0 siblings, 0 replies; 6+ messages in thread
From: Nathan Froyd @ 2009-08-11 19:47 UTC (permalink / raw)
To: qemu-devel
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
Use memcpy to copy the strings instead of strncpy.
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
---
block/vpc.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
v2: use memcpy instead of strncpy and casts to void*
diff --git a/block/vpc.c b/block/vpc.c
index ba482e9..6be24bf 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -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);
+ memcpy(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);
+ memcpy(footer->creator_app, "qemu", 4);
+ memcpy(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);
+ memcpy(dyndisk_header->magic, "cxsparse", 8);
dyndisk_header->data_offset = be64_to_cpu(0xFFFFFFFF);
dyndisk_header->table_offset = be64_to_cpu(3 * 512);
--
1.6.3.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-08-11 19:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-21 14:15 [Qemu-devel] [PATCH] eliminate errors about unused results in block/vpc.c Nathan Froyd
2009-07-22 15:05 ` Anthony Liguori
2009-07-22 15:50 ` Nathan Froyd
-- strict thread matches above, loose matches on Subject: below --
2009-08-03 14:32 Nathan Froyd
2009-08-10 14:39 ` Anthony Liguori
2009-08-11 19:47 Nathan Froyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).