From 852a2b98be2c83a3ddb31396f49854a3d14cf6ed Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 19 Mar 2014 00:19:01 +0100 Subject: [PATCH] pvscan: cleanup updates Simplify code: remove unneeded assignments use unsigned values for length --- tools/pvscan.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/tools/pvscan.c b/tools/pvscan.c index cb2f3f97a..6a74ac0df 100644 --- a/tools/pvscan.c +++ b/tools/pvscan.c @@ -18,8 +18,8 @@ #include "lvmetad.h" #include "lvmcache.h" -int pv_max_name_len = 0; -int vg_max_name_len = 0; +unsigned pv_max_name_len = 0; +unsigned vg_max_name_len = 0; static void _pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv, @@ -34,7 +34,7 @@ static void _pvscan_display_single(struct cmd_context *cmd, /* short listing? */ if (arg_count(cmd, short_ARG) > 0) { - log_print_unless_silent("%s", pv_dev_name(pv)); + log_print_unless_silent("%s", pvdevname); return; } @@ -331,10 +331,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv) uint64_t size_total = 0; uint64_t size_new = 0; - - int len = 0; - pv_max_name_len = 0; - vg_max_name_len = 0; + unsigned len; if (arg_count(cmd, cache_ARG)) return _pvscan_lvmetad(cmd, argc, argv); @@ -429,18 +426,15 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv) free_pv_fid(pvl->pv); } - if (!pvs_found) { + if (!pvs_found) log_print_unless_silent("No matching physical volumes found"); - unlock_vg(cmd, VG_GLOBAL); - return ECMD_PROCESSED; - } - - log_print_unless_silent("Total: %d [%s] / in use: %d [%s] / in no VG: %d [%s]", - pvs_found, - display_size(cmd, size_total), - pvs_found - new_pvs_found, - display_size(cmd, (size_total - size_new)), - new_pvs_found, display_size(cmd, size_new)); + else + log_print_unless_silent("Total: %d [%s] / in use: %d [%s] / in no VG: %d [%s]", + pvs_found, + display_size(cmd, size_total), + pvs_found - new_pvs_found, + display_size(cmd, (size_total - size_new)), + new_pvs_found, display_size(cmd, size_new)); unlock_vg(cmd, VG_GLOBAL);