mirror of
git://sourceware.org/git/lvm2.git
synced 2026-02-12 12:46:22 +03:00
Use dm_snprintf and improve error handling
Add standard error reporting with error logging. Use plain alloc instead of zalloc for string buffer. Use dm_snprintf with valid test for <0.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
Version 2.02.91 -
|
||||
===================================
|
||||
Fix error path handling in _build_desc()
|
||||
Add range test for device number in _scan_proc_dev().
|
||||
Use signed long for sysconf() call in cmirrord.
|
||||
Do not write in front of log buffer in print_log().
|
||||
|
||||
@@ -83,13 +83,16 @@ static char *_build_desc(struct dm_pool *mem, const char *line, int before)
|
||||
size_t len = strlen(line) + 32;
|
||||
char *buffer;
|
||||
|
||||
if (!(buffer = dm_pool_zalloc(mem, strlen(line) + 32)))
|
||||
return_NULL;
|
||||
if (!(buffer = dm_pool_alloc(mem, len))) {
|
||||
log_error("Failed to allocate desc.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (snprintf(buffer, len,
|
||||
"Created %s executing '%s'",
|
||||
before ? "*before*" : "*after*", line) < 0)
|
||||
return_NULL;
|
||||
if (dm_snprintf(buffer, len, "Created %s executing '%s'",
|
||||
before ? "*before*" : "*after*", line) < 0) {
|
||||
log_error("Failed to build desc.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user