linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	Lu Fengqi <lufq.fnst@cn.fujitsu.com>,
	linux-btrfs@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	David Sterba <dsterba@suse.cz>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 1/2] uuid: Add a glue layer macros for raw buffers
Date: Fri, 29 Mar 2019 23:26:43 +0300	[thread overview]
Message-ID: <20190329202644.40058-1-andriy.shevchenko@linux.intel.com> (raw)

When the ID comes from or we would like to pass it to a raw buffer,
the casting is needed.

Instead of doing it each time, provide a helpful set of macros.

Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/uuid.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/uuid.h b/include/linux/uuid.h
index d9c4a6cce3c2..917f1d4e5d44 100644
--- a/include/linux/uuid.h
+++ b/include/linux/uuid.h
@@ -51,11 +51,16 @@ static inline void guid_copy(guid_t *dst, const guid_t *src)
 	memcpy(dst, src, sizeof(guid_t));
 }
 
+#define guid_copy_from_raw(dst, src)	guid_copy(dst, (const guid_t *)src)
+#define guid_copy_to_raw(dst, src)	guid_copy((void *)dst, src)
+
 static inline bool guid_is_null(const guid_t *guid)
 {
 	return guid_equal(guid, &guid_null);
 }
 
+#define guid_is_null_raw(guid)		guid_is_null((const guid_t *)guid)
+
 static inline bool uuid_equal(const uuid_t *u1, const uuid_t *u2)
 {
 	return memcmp(u1, u2, sizeof(uuid_t)) == 0;
@@ -66,16 +71,24 @@ static inline void uuid_copy(uuid_t *dst, const uuid_t *src)
 	memcpy(dst, src, sizeof(uuid_t));
 }
 
+#define uuid_copy_from_raw(dst, src)	uuid_copy(dst, (const uuid_t *)src)
+#define uuid_copy_to_raw(dst, src)	uuid_copy((void *)dst, src)
+
 static inline bool uuid_is_null(const uuid_t *uuid)
 {
 	return uuid_equal(uuid, &uuid_null);
 }
 
+#define uuid_is_null_raw(uuid)		uuid_is_null((const uuid_t *)uuid)
+
 void generate_random_uuid(unsigned char uuid[16]);
 
 extern void guid_gen(guid_t *u);
 extern void uuid_gen(uuid_t *u);
 
+#define guid_gen_raw(guid)		guid_gen((guid_t *)guid)
+#define uuid_gen_raw(uuid)		uuid_gen((uuid_t *)uuid)
+
 bool __must_check uuid_is_valid(const char *uuid);
 
 extern const u8 guid_index[16];
-- 
2.20.1


             reply	other threads:[~2019-03-29 20:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-29 20:26 Andy Shevchenko [this message]
2019-04-03 18:09 ` [PATCH v2 1/2] uuid: Add a glue layer macros for raw buffers Christoph Hellwig
2019-04-04  8:45   ` Andy Shevchenko
2019-04-09 10:25     ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190329202644.40058-1-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=hch@lst.de \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lufq.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).