[4/5] vmdk: change magic number to macro
diff mbox

Message ID 1366343325-5252-5-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng April 19, 2013, 3:48 a.m. UTC
From: Feiran Zheng <feiran.zheng@emc.com>

Two hard coded flag bits are changed to macros.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/vmdk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Stefan Hajnoczi April 19, 2013, 9:06 a.m. UTC | #1
On Fri, Apr 19, 2013 at 11:48:44AM +0800, Fam Zheng wrote:
> From: Feiran Zheng <feiran.zheng@emc.com>
> 
> Two hard coded flag bits are changed to macros.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  block/vmdk.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 827b35b..5daa9f2 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -32,6 +32,7 @@
>  #define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D')
>  #define VMDK4_MAGIC (('K' << 24) | ('D' << 16) | ('M' << 8) | 'V')
>  #define VMDK4_COMPRESSION_DEFLATE 1
> +#define VMDK4_FLAG_NL_DETECT (1 << 0)
>  #define VMDK4_FLAG_RGD (1 << 1)
>  /* Zeroed-grain enable bit */
>  #define VMDK4_FLAG_ZG   (1 << 2)
> @@ -1285,7 +1286,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
>      magic = cpu_to_be32(VMDK4_MAGIC);
>      memset(&header, 0, sizeof(header));
>      header.version = zeroed_grain ? 2 : 1;
> -    header.flags = 3
> +    header.flags = VMDK4_FLAG_RGD | VMDK4_FLAG_NL_DETECT

Nice :)

Patch
diff mbox

diff --git a/block/vmdk.c b/block/vmdk.c
index 827b35b..5daa9f2 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -32,6 +32,7 @@ 
 #define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D')
 #define VMDK4_MAGIC (('K' << 24) | ('D' << 16) | ('M' << 8) | 'V')
 #define VMDK4_COMPRESSION_DEFLATE 1
+#define VMDK4_FLAG_NL_DETECT (1 << 0)
 #define VMDK4_FLAG_RGD (1 << 1)
 /* Zeroed-grain enable bit */
 #define VMDK4_FLAG_ZG   (1 << 2)
@@ -1285,7 +1286,7 @@  static int vmdk_create_extent(const char *filename, int64_t filesize,
     magic = cpu_to_be32(VMDK4_MAGIC);
     memset(&header, 0, sizeof(header));
     header.version = zeroed_grain ? 2 : 1;
-    header.flags = 3
+    header.flags = VMDK4_FLAG_RGD | VMDK4_FLAG_NL_DETECT
                    | (compress ? VMDK4_FLAG_COMPRESS | VMDK4_FLAG_MARKER : 0)
                    | (zeroed_grain ? VMDK4_FLAG_ZG : 0);
     header.compressAlgorithm = compress ? VMDK4_COMPRESSION_DEFLATE : 0;