uuid: hoist uuid_is_null() helper from libnvdimm

Hoist the libnvdimm helper as an inline helper to linux/uuid.h
using an auxiliary const variable uuid_null in lib/uuid.c.

[hch: also add the guid variant.  Both do the same but I'd like
to keep casts to a minimum]

The common helper uses the new abstract type uuid_t * instead of
u8 *.

Suggested-by: Christoph Hellwig <[email protected]>
Signed-off-by: Amir Goldstein <[email protected]>
[hch: added guid_is_null]
Signed-off-by: Christoph Hellwig <[email protected]>
Acked-by: Dan Williams <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
This commit is contained in:
Christoph Hellwig 2017-05-11 09:01:42 +02:00
commit ef40dda5bb
3 changed files with 19 additions and 8 deletions

View file

@ -222,13 +222,6 @@ struct device *nd_btt_create(struct nd_region *nd_region)
return dev;
}
static bool uuid_is_null(u8 *uuid)
{
static const u8 null_uuid[16];
return (memcmp(uuid, null_uuid, 16) == 0);
}
/**
* nd_btt_arena_is_valid - check if the metadata layout is valid
* @nd_btt: device with BTT geometry and backing device info
@ -249,7 +242,7 @@ bool nd_btt_arena_is_valid(struct nd_btt *nd_btt, struct btt_sb *super)
if (memcmp(super->signature, BTT_SIG, BTT_SIG_LEN) != 0)
return false;
if (!uuid_is_null(super->parent_uuid))
if (!guid_is_null((guid_t *)&super->parent_uuid))
if (memcmp(super->parent_uuid, parent_uuid, 16) != 0)
return false;