1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +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:
Zdenek Kabelac 2012-02-08 12:50:10 +00:00
parent 7ffca95bb6
commit 33dea28e23
2 changed files with 10 additions and 6 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.91 - Version 2.02.91 -
=================================== ===================================
Fix error path handling in _build_desc()
Add range test for device number in _scan_proc_dev(). Add range test for device number in _scan_proc_dev().
Use signed long for sysconf() call in cmirrord. Use signed long for sysconf() call in cmirrord.
Do not write in front of log buffer in print_log(). Do not write in front of log buffer in print_log().

View File

@ -83,13 +83,16 @@ static char *_build_desc(struct dm_pool *mem, const char *line, int before)
size_t len = strlen(line) + 32; size_t len = strlen(line) + 32;
char *buffer; char *buffer;
if (!(buffer = dm_pool_zalloc(mem, strlen(line) + 32))) if (!(buffer = dm_pool_alloc(mem, len))) {
return_NULL; log_error("Failed to allocate desc.");
return NULL;
}
if (snprintf(buffer, len, if (dm_snprintf(buffer, len, "Created %s executing '%s'",
"Created %s executing '%s'", before ? "*before*" : "*after*", line) < 0) {
before ? "*before*" : "*after*", line) < 0) log_error("Failed to build desc.");
return_NULL; return NULL;
}
return buffer; return buffer;
} }