From a18296a179ce4987d1d7edd9538f9ff24040fd95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 22 Dec 2022 11:47:08 +0100 Subject: [PATCH] module/disk-io: cleanup poll-interval MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * man page: spell out ‘milliseconds’ * use a ‘static const’ variable for min_poll_interval, instead of a macro --- doc/yambar-modules-disk-io.5.scd | 4 ++-- modules/disk-io.c | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/doc/yambar-modules-disk-io.5.scd b/doc/yambar-modules-disk-io.5.scd index 77220d9..6f6c7dc 100644 --- a/doc/yambar-modules-disk-io.5.scd +++ b/doc/yambar-modules-disk-io.5.scd @@ -38,8 +38,8 @@ currently present in the machine. | poll-interval : int : no -: Refresh interval of disk's stats in ms (default=500). - Cannot be less then 500 ms +: Refresh interval of disk's stats in milliseconds (default=500). + Cannot be less then 500ms. # EXAMPLES diff --git a/modules/disk-io.c b/modules/disk-io.c index 8609c44..2142b56 100644 --- a/modules/disk-io.c +++ b/modules/disk-io.c @@ -7,16 +7,17 @@ #include -#include "../particles/dynlist.h" +#define LOG_MODULE "disk-io" +#define LOG_ENABLE_DBG 0 +#include "../log.h" + #include "../bar/bar.h" #include "../config-verify.h" #include "../config.h" -#include "../log.h" +#include "../particles/dynlist.h" #include "../plugin.h" -#define LOG_MODULE "disk-io" -#define LOG_ENABLE_DBG 0 -#define SMALLEST_INTERVAL 500 +static const long min_poll_interval = 500; struct device_stats { char *name; @@ -314,20 +315,20 @@ from_conf(const struct yml_node *node, struct conf_inherit inherited) const struct yml_node *c = yml_get_value(node, "content"); return disk_io_new( - interval == NULL ? SMALLEST_INTERVAL : yml_value_as_int(interval), + interval == NULL ? min_poll_interval : yml_value_as_int(interval), conf_to_particle(c, inherited)); } static bool -conf_verify_interval(keychain_t *chain, const struct yml_node *node) +conf_verify_poll_interval(keychain_t *chain, const struct yml_node *node) { if (!conf_verify_unsigned(chain, node)) return false; - if (yml_value_as_int(node) < SMALLEST_INTERVAL) { + if (yml_value_as_int(node) < min_poll_interval) { LOG_ERR( - "%s: poll-interval value cannot be less than %d ms", - conf_err_prefix(chain, node), SMALLEST_INTERVAL); + "%s: poll-interval value cannot be less than %ldms", + conf_err_prefix(chain, node), min_poll_interval); return false; } @@ -338,7 +339,7 @@ static bool verify_conf(keychain_t *chain, const struct yml_node *node) { static const struct attr_info attrs[] = { - {"poll-interval", false, &conf_verify_interval}, + {"poll-interval", false, &conf_verify_poll_interval}, MODULE_COMMON_ATTRS, };