mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Use dm_asprintf to simplify code
This commit is contained in:
parent
9278655de1
commit
d707e133d3
@ -1,5 +1,6 @@
|
||||
Version 1.02.70 -
|
||||
===================================
|
||||
Simplify dm_task_set_geometry() and use dm_asprintf().
|
||||
Set all parameters to 0 for dm_get_next_target() for NULL return.
|
||||
Fix fd resource leak in error path for _udev_notify_sem_create().
|
||||
Leave space for '\0' for readline() call in _sysfs_get_kernel_name().
|
||||
|
@ -769,16 +769,11 @@ int dm_task_set_sector(struct dm_task *dmt, uint64_t sector)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dm_task_set_geometry(struct dm_task *dmt, const char *cylinders, const char *heads, const char *sectors, const char *start)
|
||||
int dm_task_set_geometry(struct dm_task *dmt, const char *cylinders, const char *heads,
|
||||
const char *sectors, const char *start)
|
||||
{
|
||||
size_t len = strlen(cylinders) + 1 + strlen(heads) + 1 + strlen(sectors) + 1 + strlen(start) + 1;
|
||||
|
||||
if (!(dmt->geometry = dm_malloc(len))) {
|
||||
log_error("dm_task_set_geometry: dm_malloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sprintf(dmt->geometry, "%s %s %s %s", cylinders, heads, sectors, start) < 0) {
|
||||
if (dm_asprintf(&(dmt->geometry), "%s %s %s %s",
|
||||
cylinders, heads, sectors, start) < 0) {
|
||||
log_error("dm_task_set_geometry: sprintf failed");
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user