mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Add id_format_and_copy() common function and call from _uuid_disp.
Add supporting uuid function to allocate memory and call id_write_format. Call id_format_and_copy from _uuid_disp.
This commit is contained in:
parent
4bbadbe1cf
commit
f4fd41552d
@ -677,12 +677,7 @@ static int _uuid_disp(struct dm_report *rh __attribute__((unused)), struct dm_po
|
|||||||
{
|
{
|
||||||
char *repstr = NULL;
|
char *repstr = NULL;
|
||||||
|
|
||||||
if (!(repstr = dm_pool_alloc(mem, 40))) {
|
if (!(repstr = id_format_and_copy(mem, (struct id *)data)))
|
||||||
log_error("dm_pool_alloc failed");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!id_write_format((const struct id *) data, repstr, 40))
|
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
dm_report_field_set_value(field, repstr, NULL);
|
dm_report_field_set_value(field, repstr, NULL);
|
||||||
|
@ -206,3 +206,18 @@ int id_read_format(struct id *id, const char *buffer)
|
|||||||
|
|
||||||
return id_valid(id);
|
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;
|
||||||
|
}
|
||||||
|
@ -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);
|
int id_read_format(struct id *id, const char *buffer);
|
||||||
|
|
||||||
|
char *id_format_and_copy(struct dm_pool *mem, const struct id *id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user