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

cleanup: use code in place

Pass const strings to printf(),
and use  struct names directly instead of creating unused vars on stack.
This commit is contained in:
Zdenek Kabelac 2015-11-09 09:33:56 +01:00
parent 22e19cb354
commit 846adadbcc

View File

@ -1228,20 +1228,19 @@ static struct dm_task *_stats_print_region(struct dm_stats *dms,
unsigned num_lines, unsigned clear) unsigned num_lines, unsigned clear)
{ {
/* @stats_print[_clear] <region_id> [<start_line> <num_lines>] */ /* @stats_print[_clear] <region_id> [<start_line> <num_lines>] */
const char *clear_str = "_clear", *lines_fmt = "%u %u";
const char *msg_fmt = "@stats_print%s " FMTu64 " %s";
const char *err_fmt = "Could not prepare @stats_print %s."; const char *err_fmt = "Could not prepare @stats_print %s.";
struct dm_task *dmt = NULL; struct dm_task *dmt = NULL;
char msg[1024], lines[64]; char msg[1024], lines[64];
if (start_line || num_lines) if (start_line || num_lines)
if (!dm_snprintf(lines, sizeof(lines), if (!dm_snprintf(lines, sizeof(lines),
lines_fmt, start_line, num_lines)) { "%u %u", start_line, num_lines)) {
log_error(err_fmt, "row specification"); log_error(err_fmt, "row specification");
return NULL; return NULL;
} }
if (!dm_snprintf(msg, sizeof(msg), msg_fmt, (clear) ? clear_str : "", if (!dm_snprintf(msg, sizeof(msg), "@stats_print%s " FMTu64 " %s",
(clear) ? "_clear" : "",
region_id, (start_line || num_lines) ? lines : "")) { region_id, (start_line || num_lines) ? lines : "")) {
log_error(err_fmt, "message"); log_error(err_fmt, "message");
return NULL; return NULL;
@ -1981,10 +1980,9 @@ dm_percent_t dm_histogram_get_bin_percent(const struct dm_histogram *dmh,
*/ */
static struct dm_histogram *_alloc_dm_histogram(int nr_bins) static struct dm_histogram *_alloc_dm_histogram(int nr_bins)
{ {
struct dm_histogram *dmh = NULL;
struct dm_histogram_bin *cur = NULL;
/* Allocate space for dm_histogram + nr_entries. */ /* Allocate space for dm_histogram + nr_entries. */
size_t size = sizeof(*dmh) + (unsigned) nr_bins * sizeof(*cur); size_t size = sizeof(struct dm_histogram) +
(unsigned) nr_bins * sizeof(struct dm_histogram_bin);
return dm_zalloc(size); return dm_zalloc(size);
} }