1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

Replace snprintf with dm_snprintf

snprintf testing for negative is replaced with dm_snprintf where this
test really works.
Add missing test for result of dm_snprintf().
This commit is contained in:
Zdenek Kabelac 2012-02-08 11:40:02 +00:00
parent a6292f2a6d
commit d75c5f06f0
3 changed files with 7 additions and 5 deletions

View File

@ -60,7 +60,7 @@ static int get_sysfs_get_major_minor(const char *sysfs_dir, const char *kname, i
{ {
char path[PATH_MAX], buffer[64]; char path[PATH_MAX], buffer[64];
if (snprintf(path, sizeof(path), "%s/block/%s/dev", sysfs_dir, kname) < 0) if (dm_snprintf(path, sizeof(path), "%s/block/%s/dev", sysfs_dir, kname) < 0)
return_0; return_0;
if (!get_sysfs_string(path, buffer, sizeof(buffer))) if (!get_sysfs_string(path, buffer, sizeof(buffer)))

View File

@ -696,9 +696,11 @@ static int _split_mirror_images(struct logical_volume *lv,
dm_list_iterate_items(lvl, &split_images) { dm_list_iterate_items(lvl, &split_images) {
sub_lv = lvl->lv; sub_lv = lvl->lv;
dm_snprintf(format, len, "%s_mimage_%%d", if (dm_snprintf(format, len, "%s_mimage_%%d",
new_lv->name); new_lv->name) < 0) {
log_error("Failed to build new image name.");
return 0;
}
layer_name = dm_pool_alloc(lv->vg->vgmem, len); layer_name = dm_pool_alloc(lv->vg->vgmem, len);
if (!layer_name) { if (!layer_name) {
log_error("Unable to allocate memory"); log_error("Unable to allocate memory");

View File

@ -28,7 +28,7 @@ static char *_expand_filename(const char *template, const char *vg_name,
return NULL; return NULL;
} }
if (snprintf(filename, PATH_MAX, template, vg_name) < 0) { if (dm_snprintf(filename, PATH_MAX, template, vg_name) < 0) {
log_error("Error processing filename template %s", log_error("Error processing filename template %s",
template); template);
dm_free(filename); dm_free(filename);