1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cleanup: shorten dump output code

Save couple lines on code with simpler code.
This commit is contained in:
Zdenek Kabelac 2017-07-16 18:22:52 +02:00
parent f6c2ee57fa
commit 55f9e2f399

View File

@ -2578,14 +2578,12 @@ static void _dump_pairs(struct buffer *buf, struct dm_hash_table *ht, const char
dm_hash_iterate(n, ht) { dm_hash_iterate(n, ht) {
const char *key = dm_hash_get_key(ht, n), const char *key = dm_hash_get_key(ht, n),
*val = dm_hash_get_data(ht, n); *val = dm_hash_get_data(ht, n);
buffer_append(buf, " ");
if (int_key) if (int_key)
(void) dm_asprintf(&append, "%d = \"%s\"", *(const int*)key, val); (void) dm_asprintf(&append, " %d = \"%s\"\n", *(const int*)key, val);
else else
(void) dm_asprintf(&append, "%s = \"%s\"", key, val); (void) dm_asprintf(&append, " %s = \"%s\"\n", key, val);
if (append) if (append)
buffer_append(buf, append); buffer_append(buf, append);
buffer_append(buf, "\n");
dm_free(append); dm_free(append);
} }
buffer_append(buf, "}\n"); buffer_append(buf, "}\n");
@ -2603,11 +2601,9 @@ static void _dump_info_version(struct buffer *buf, struct dm_hash_table *ht, con
while (n) { while (n) {
const char *key = dm_hash_get_key(ht, n); const char *key = dm_hash_get_key(ht, n);
info = dm_hash_get_data(ht, n); info = dm_hash_get_data(ht, n);
buffer_append(buf, " "); (void) dm_asprintf(&append, " %s = %lld\n", key, (long long)info->external_version);
(void) dm_asprintf(&append, "%s = %lld", key, (long long)info->external_version);
if (append) if (append)
buffer_append(buf, append); buffer_append(buf, append);
buffer_append(buf, "\n");
dm_free(append); dm_free(append);
n = dm_hash_get_next(ht, n); n = dm_hash_get_next(ht, n);
} }
@ -2626,11 +2622,9 @@ static void _dump_info_flags(struct buffer *buf, struct dm_hash_table *ht, const
while (n) { while (n) {
const char *key = dm_hash_get_key(ht, n); const char *key = dm_hash_get_key(ht, n);
info = dm_hash_get_data(ht, n); info = dm_hash_get_data(ht, n);
buffer_append(buf, " "); (void) dm_asprintf(&append, " %s = %llx\n", key, (long long)info->flags);
(void) dm_asprintf(&append, "%s = %llx", key, (long long)info->flags);
if (append) if (append)
buffer_append(buf, append); buffer_append(buf, append);
buffer_append(buf, "\n");
dm_free(append); dm_free(append);
n = dm_hash_get_next(ht, n); n = dm_hash_get_next(ht, n);
} }