Make opr_uuid_toString return a status
[openafs.git] / src / opr / uuid.c
index 433723c..493c660 100644 (file)
@@ -64,17 +64,23 @@ opr_uuid_hash(const opr_uuid_t *uuid)
 }
 
 #if !defined(KERNEL)
-void
+int
 opr_uuid_toString(const opr_uuid_t *uuid, char **string)
 {
    unsigned const char *p;
+   int r;
 
    p = uuid->data;
-   asprintf(string,
-           "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
-           "%02x%02x%02x%02x%02x%02x",
-           p[0], p[1], p[2],  p[3],  p[4],  p[5],  p[6],  p[7],
-           p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
+   r = asprintf(string,
+               "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
+               "%02x%02x%02x%02x%02x%02x",
+               p[0], p[1], p[2],  p[3],  p[4],  p[5],  p[6],  p[7],
+               p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
+   if (r < 0) {
+       *string = NULL;
+       return ENOMEM;
+   }
+   return 0;
 }
 
 void