[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 4/8] libxl: const-ify libxl_uuid_*() API



Add const to parameters of libxl_uuid_*() calls where it does not
change the API.

Add libxl_uuid_byte_array_const() to return a const array.

Signed-off-by: David Vrabel <david.vrabel@xxxxxxxxxx>
---
 tools/libxl/libxl_uuid.c |   18 ++++++++++++++----
 tools/libxl/libxl_uuid.h |    5 +++--
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/tools/libxl/libxl_uuid.c b/tools/libxl/libxl_uuid.c
index ecc29c7..6591cb7 100644
--- a/tools/libxl/libxl_uuid.c
+++ b/tools/libxl/libxl_uuid.c
@@ -20,7 +20,7 @@
 
 #if defined(__linux__)
 
-int libxl_uuid_is_nil(libxl_uuid *uuid)
+int libxl_uuid_is_nil(const libxl_uuid *uuid)
 {
      return uuid_is_null(uuid->uuid);
 }
@@ -45,11 +45,16 @@ void libxl_uuid_clear(libxl_uuid *uuid)
      uuid_clear(uuid->uuid);
 }
 
-int libxl_uuid_compare(libxl_uuid *uuid1, libxl_uuid *uuid2)
+int libxl_uuid_compare(const libxl_uuid *uuid1, const libxl_uuid *uuid2)
 {
      return uuid_compare(uuid1->uuid, uuid2->uuid);
 }
 
+const uint8_t *libxl_uuid_bytearray_const(const libxl_uuid *uuid)
+{
+    return uuid->uuid;
+}
+
 uint8_t *libxl_uuid_bytearray(libxl_uuid *uuid)
 {
     return uuid->uuid;
@@ -57,7 +62,7 @@ uint8_t *libxl_uuid_bytearray(libxl_uuid *uuid)
 
 #elif defined(__NetBSD__)
 
-int libxl_uuid_is_nil(libxl_uuid *uuid)
+int libxl_uuid_is_nil(const libxl_uuid *uuid)
 {
     uint32_t status;
     return uuid_is_nil((uuid_t *)uuid->uuid, &status);
@@ -92,11 +97,16 @@ void libxl_uuid_clear(libxl_uuid *uuid)
      memset(uuid->uuid, 0, sizeof(uuid->uuid));
 }
 
-int libxl_uuid_compare(libxl_uuid *uuid1, libxl_uuid *uuid2)
+int libxl_uuid_compare(const libxl_uuid *uuid1, const libxl_uuid *uuid2)
 {
      return memcmp(uuid1->uuid, uuid2->uuid, sizeof(uuid1->uuid));
 }
 
+const uint8_t *libxl_uuid_bytearray_const(const libxl_uuid *uuid)
+{
+    return uuid->uuid;
+}
+
 uint8_t *libxl_uuid_bytearray(libxl_uuid *uuid)
 {
     return uuid->uuid;
diff --git a/tools/libxl/libxl_uuid.h b/tools/libxl/libxl_uuid.h
index 93c65a7..fbde7b6 100644
--- a/tools/libxl/libxl_uuid.h
+++ b/tools/libxl/libxl_uuid.h
@@ -53,12 +53,13 @@ typedef struct {
 
 #endif
 
-int libxl_uuid_is_nil(libxl_uuid *uuid);
+int libxl_uuid_is_nil(const libxl_uuid *uuid);
 void libxl_uuid_generate(libxl_uuid *uuid);
 int libxl_uuid_from_string(libxl_uuid *uuid, const char *in);
 void libxl_uuid_copy(libxl_uuid *dst, const libxl_uuid *src);
 void libxl_uuid_clear(libxl_uuid *uuid);
-int libxl_uuid_compare(libxl_uuid *uuid1, libxl_uuid *uuid2);
+int libxl_uuid_compare(const libxl_uuid *uuid1, const libxl_uuid *uuid2);
+const uint8_t *libxl_uuid_bytearray_const(const libxl_uuid *uuid);
 uint8_t *libxl_uuid_bytearray(libxl_uuid *uuid);
 
 #endif /* __LIBXL_UUID_H__ */
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.