[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/3] block: vpc: introduce vpc_check_signature funct
From: |
Levente Kurusa |
Subject: |
[Qemu-devel] [PATCH 2/3] block: vpc: introduce vpc_check_signature function |
Date: |
Fri, 1 Aug 2014 15:40:00 +0200 |
Check the signature in a helper function instead of in plain
code in order to avoid code duplication
Reviewed-by: Andrew Jones <address@hidden>
Signed-off-by: Levente Kurusa <address@hidden>
---
block/vpc.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/block/vpc.c b/block/vpc.c
index 2ba8fc2..a6a7213 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -156,11 +156,15 @@ static uint32_t vpc_checksum(uint8_t* buf, size_t size)
return ~res;
}
+static int vpc_check_signature(const void *buf)
+{
+ return !strncmp((char *)buf, "conectix", 8);
+}
static int vpc_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
const char *filename)
{
- if (buf_size >= 8 && !strncmp((char *)buf, "conectix", 8))
+ if (buf_size >= 8 && vpc_check_signature(buf))
return 100;
return 0;
}
@@ -184,7 +188,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options,
int flags,
}
footer = (VHDFooter *) s->footer_buf;
- if (strncmp(footer->creator, "conectix", 8)) {
+ if (!vpc_check_signature(footer->creator)) {
int64_t offset = bdrv_getlength(bs->file);
if (offset < 0) {
ret = offset;
@@ -200,7 +204,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options,
int flags,
if (ret < 0) {
goto fail;
}
- if (strncmp(footer->creator, "conectix", 8)) {
+ if (!vpc_check_signature(footer->creator)) {
error_setg(errp, "invalid VPC image");
ret = -EINVAL;
goto fail;
--
1.9.3
- [Qemu-devel] [PATCH 0/3] vpc: support probing of fixed size images, Levente Kurusa, 2014/08/01
- [Qemu-devel] [PATCH 2/3] block: vpc: introduce vpc_check_signature function,
Levente Kurusa <=
- [Qemu-devel] [PATCH 3/3] block: vpc: handle fixed size images in probe function, Levente Kurusa, 2014/08/01
- [Qemu-devel] [PATCH 1/3] block: format: pass down the current state to the format's probe function, Levente Kurusa, 2014/08/01
- Re: [Qemu-devel] [PATCH 0/3] vpc: support probing of fixed size images, Stefan Hajnoczi, 2014/08/12
- Re: [Qemu-devel] [PATCH 0/3] vpc: support probing of fixed size images, Jeff Cody, 2014/08/12
- Re: [Qemu-devel] [PATCH 0/3] vpc: support probing of fixed size images, Levente Kurusa, 2014/08/14
- Re: [Qemu-devel] [PATCH 0/3] vpc: support probing of fixed size images, Jeff Cody, 2014/08/14
- Re: [Qemu-devel] [PATCH 0/3] vpc: support probing of fixed size images, Kevin Wolf, 2014/08/15
- Re: [Qemu-devel] [PATCH 0/3] vpc: support probing of fixed size images, Markus Armbruster, 2014/08/15
- Re: [Qemu-devel] [PATCH 0/3] vpc: support probing of fixed size images, Jeff Cody, 2014/08/15
- Re: [Qemu-devel] [PATCH 0/3] vpc: support probing of fixed size images, Markus Armbruster, 2014/08/15