verify: put all header verification in one place
authorJens Axboe <axboe@kernel.dk>
Thu, 23 Feb 2012 09:31:07 +0000 (10:31 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 23 Feb 2012 09:31:07 +0000 (10:31 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
verify.c

index f21ad6e1a3af73ec535a5c47d181b95a326d189b..662196678646d954cbb775246d9f582365c17ee5 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -646,11 +646,14 @@ static int verify_trimmed_io_u(struct thread_data *td, struct io_u *io_u)
        return ret;
 }
 
        return ret;
 }
 
-static int verify_hdr_crc(struct verify_header *hdr)
+static int verify_header(struct verify_header *hdr)
 {
        void *p = hdr;
        uint32_t crc;
 
 {
        void *p = hdr;
        uint32_t crc;
 
+       if (hdr->magic != FIO_HDR_MAGIC)
+               return 0;
+
        crc = crc32c(p, sizeof(*hdr) - sizeof(hdr->crc32));
        if (crc == hdr->crc32)
                return 1;
        crc = crc32c(p, sizeof(*hdr) - sizeof(hdr->crc32));
        if (crc == hdr->crc32)
                return 1;
@@ -692,8 +695,9 @@ int verify_io_u(struct thread_data *td, struct io_u *io_u)
                        memswp(p, p + td->o.verify_offset, header_size);
                hdr = p;
 
                        memswp(p, p + td->o.verify_offset, header_size);
                hdr = p;
 
-               if (hdr->magic != FIO_HDR_MAGIC || !verify_hdr_crc(hdr)) {
-                       log_err("verify: bad magic header %x, wanted %x at file %s offset %llu, length %u\n",
+               if (!verify_header(hdr)) {
+                       log_err("verify: bad magic header %x, wanted %x at "
+                               "file %s offset %llu, length %u\n",
                                hdr->magic, FIO_HDR_MAGIC,
                                io_u->file->file_name,
                                io_u->offset + hdr_num * hdr->len, hdr->len);
                                hdr->magic, FIO_HDR_MAGIC,
                                io_u->file->file_name,
                                io_u->offset + hdr_num * hdr->len, hdr->len);