From 46669fe9e82ce640aa69b2010fa857fb8f384552 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 13 May 2024 00:04:28 +0200 Subject: [PATCH] cleanup: add static _ --- tools/lvmdiskscan.c | 34 +++++++++++++++++----------------- tools/pvck.c | 18 +++++++++--------- tools/toollib.c | 6 +++--- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tools/lvmdiskscan.c b/tools/lvmdiskscan.c index a504c3ad7..bd7d9cec1 100644 --- a/tools/lvmdiskscan.c +++ b/tools/lvmdiskscan.c @@ -21,11 +21,11 @@ #include "tools.h" -int disks_found; -int parts_found; -int pv_disks_found; -int pv_parts_found; -int max_len; +static int _disks_found; +static int _parts_found; +static int _pv_disks_found; +static int _pv_parts_found; +static int _max_len; static int _get_max_dev_name_len(struct cmd_context *cmd, struct dev_filter *filter) { @@ -63,7 +63,7 @@ static void _count(struct device *dev, int *disks, int *parts) static void _print(struct cmd_context *cmd, const struct device *dev, uint64_t size, const char *what) { - log_print("%-*s [%15s] %s", max_len, dev_name(dev), + log_print("%-*s [%15s] %s", _max_len, dev_name(dev), display_size(cmd, size), what ? : ""); } @@ -76,7 +76,7 @@ static int _check_device(struct cmd_context *cmd, struct device *dev) size = 0; } _print(cmd, dev, size, NULL); - _count(dev, &disks_found, &parts_found); + _count(dev, &_disks_found, &_parts_found); return 1; } @@ -89,10 +89,10 @@ int lvmdiskscan(struct cmd_context *cmd, int argc __attribute__((unused)), struct device *dev; /* initialise these here to avoid problems with the lvm shell */ - disks_found = 0; - parts_found = 0; - pv_disks_found = 0; - pv_parts_found = 0; + _disks_found = 0; + _parts_found = 0; + _pv_disks_found = 0; + _pv_parts_found = 0; if (arg_is_set(cmd, lvmpartition_ARG)) log_warn("WARNING: only considering LVM devices"); @@ -100,7 +100,7 @@ int lvmdiskscan(struct cmd_context *cmd, int argc __attribute__((unused)), /* Call before using dev_iter which uses filters which want bcache data. */ label_scan(cmd); - max_len = _get_max_dev_name_len(cmd, cmd->filter); + _max_len = _get_max_dev_name_len(cmd, cmd->filter); if (!(iter = dev_iter_create(cmd->filter, 0))) { log_error("dev_iter_create failed"); @@ -115,7 +115,7 @@ int lvmdiskscan(struct cmd_context *cmd, int argc __attribute__((unused)), continue; } _print(cmd, dev, size, "LVM physical volume"); - _count(dev, &pv_disks_found, &pv_parts_found); + _count(dev, &_pv_disks_found, &_pv_parts_found); continue; } /* If user just wants PVs we are done */ @@ -131,14 +131,14 @@ int lvmdiskscan(struct cmd_context *cmd, int argc __attribute__((unused)), /* Display totals */ if (!arg_is_set(cmd, lvmpartition_ARG)) { log_print("%d disk%s", - disks_found, disks_found == 1 ? "" : "s"); + _disks_found, _disks_found == 1 ? "" : "s"); log_print("%d partition%s", - parts_found, parts_found == 1 ? "" : "s"); + _parts_found, _parts_found == 1 ? "" : "s"); } log_print("%d LVM physical volume whole disk%s", - pv_disks_found, pv_disks_found == 1 ? "" : "s"); + _pv_disks_found, _pv_disks_found == 1 ? "" : "s"); log_print("%d LVM physical volume%s", - pv_parts_found, pv_parts_found == 1 ? "" : "s"); + _pv_parts_found, _pv_parts_found == 1 ? "" : "s"); return ECMD_PROCESSED; } diff --git a/tools/pvck.c b/tools/pvck.c index 79cf2d2f6..0e46e8c2b 100644 --- a/tools/pvck.c +++ b/tools/pvck.c @@ -284,7 +284,7 @@ static int _text_buf_parsable(char *text_buf, uint64_t text_size) #define MAX_LINE_CHECK 128 #define MAX_DESC 1024 -char desc_line[MAX_DESC]; +static char _desc_line[MAX_DESC]; static void _copy_line(char *in, char *out, int *len, int linesize) { @@ -603,18 +603,18 @@ static int _dump_all_text(struct cmd_context *cmd, struct settings *set, const c if (arg_is_set(cmd, verbose_ARG)) { char *str1, *str2; if ((str1 = strstr(text_buf, "description = "))) { - memset(desc_line, 0, sizeof(desc_line)); - _copy_line(str1, desc_line, &len, sizeof(desc_line)-1); - if ((p = strchr(desc_line, '\n'))) + memset(_desc_line, 0, sizeof(_desc_line)); + _copy_line(str1, _desc_line, &len, sizeof(_desc_line)-1); + if ((p = strchr(_desc_line, '\n'))) *p = '\0'; - log_print("%s", desc_line); + log_print("%s", _desc_line); } if (str1 && (str2 = strstr(str1, "creation_time = "))) { - memset(desc_line, 0, sizeof(desc_line)); - _copy_line(str2, desc_line, &len, sizeof(desc_line)-1); - if ((p = strchr(desc_line, '\n'))) + memset(_desc_line, 0, sizeof(_desc_line)); + _copy_line(str2, _desc_line, &len, sizeof(_desc_line)-1); + if ((p = strchr(_desc_line, '\n'))) *p = '\0'; - log_print("%s\n", desc_line); + log_print("%s\n", _desc_line); } } diff --git a/tools/toollib.c b/tools/toollib.c index 656fb7415..40fc3353a 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -46,7 +46,7 @@ static void _sigchld_handler(int sig __attribute__((unused))) */ int become_daemon(struct cmd_context *cmd, int skip_lvm) { - static const char devnull[] = "/dev/null"; + static const char _devnull[] = "/dev/null"; int null_fd; pid_t pid; struct sigaction act = { @@ -83,8 +83,8 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm) // #define DEBUG_CHILD #ifndef DEBUG_CHILD - if ((null_fd = open(devnull, O_RDWR)) == -1) { - log_sys_error("open", devnull); + if ((null_fd = open(_devnull, O_RDWR)) == -1) { + log_sys_error("open", _devnull); _exit(ECMD_FAILED); } -- 2.43.5