]> sourceware.org Git - lvm2.git/commitdiff
Add id_format_and_copy() common function and call from _uuid_disp.
authorDave Wysochanski <dwysocha@redhat.com>
Thu, 30 Sep 2010 14:07:33 +0000 (14:07 +0000)
committerDave Wysochanski <dwysocha@redhat.com>
Thu, 30 Sep 2010 14:07:33 +0000 (14:07 +0000)
Add supporting uuid function to allocate memory and call id_write_format.
Call id_format_and_copy from _uuid_disp.

lib/report/report.c
lib/uuid/uuid.c
lib/uuid/uuid.h

index d0901a5baf34d403a8751f39d71fe6996b0ed484..b8c5d1adc5b342cb08b2b917d336807237b38fca 100644 (file)
@@ -677,12 +677,7 @@ static int _uuid_disp(struct dm_report *rh __attribute__((unused)), struct dm_po
 {
        char *repstr = NULL;
 
-       if (!(repstr = dm_pool_alloc(mem, 40))) {
-               log_error("dm_pool_alloc failed");
-               return 0;
-       }
-
-       if (!id_write_format((const struct id *) data, repstr, 40))
+       if (!(repstr = id_format_and_copy(mem, (struct id *)data)))
                return_0;
 
        dm_report_field_set_value(field, repstr, NULL);
index de3f0cd015622d9cefe621afcce42d756b019eab..e85e852c4af48af83869ee6b7bed8f065f38da34 100644 (file)
@@ -206,3 +206,18 @@ int id_read_format(struct id *id, const char *buffer)
 
        return id_valid(id);
 }
+
+char *id_format_and_copy(struct dm_pool *mem, const struct id *id)
+{
+       char *repstr = NULL;
+
+       if (!(repstr = dm_pool_alloc(mem, 40))) {
+               log_error("dm_pool_alloc failed");
+               return NULL;
+       }
+
+       if (!id_write_format(id, repstr, 40))
+               return_NULL;
+
+       return repstr;
+}
index 00296393c9d53bcb70eeab3e056fbfa1cc9284bc..5c8382d75fabc598f532c4d2ce45e537091b258a 100644 (file)
@@ -54,4 +54,6 @@ int id_write_format(const struct id *id, char *buffer, size_t size);
  */
 int id_read_format(struct id *id, const char *buffer);
 
+char *id_format_and_copy(struct dm_pool *mem, const struct id *id);
+
 #endif
This page took 0.043208 seconds and 5 git commands to generate.