From: Karel Zak Date: Fri, 28 Jan 2022 11:15:39 +0000 (+0100) Subject: hwclock: cleanup hwclock_params[] use X-Git-Tag: v2.38-rc1~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=63d8183479e0ccfe5ed46033413ec52880aa2b39;p=thirdparty%2Futil-linux.git hwclock: cleanup hwclock_params[] use * remove it from header file * keep it 'static const' Signed-off-by: Karel Zak --- diff --git a/sys-utils/hwclock-rtc.c b/sys-utils/hwclock-rtc.c index becfc7b83f..e10f7bce01 100644 --- a/sys-utils/hwclock-rtc.c +++ b/sys-utils/hwclock-rtc.c @@ -86,6 +86,19 @@ struct linux_rtc_time { # define RTC_EPOCH_SET _IOW('p', 0x0e, unsigned long) /* Set epoch */ #endif +static const struct hwclock_param hwclock_params[] = +{ + { RTC_PARAM_FEATURES, "features", N_("supported features") }, + { RTC_PARAM_CORRECTION, "correction", N_("time correction") }, + { RTC_PARAM_BACKUP_SWITCH_MODE, "bsm", N_("backup switch mode") }, + { } +}; + +const struct hwclock_param *get_hwclock_params(void) +{ + return hwclock_params; +} + /* * /dev/rtc is conventionally chardev 10/135 * ia64 uses /dev/efirtc, chardev 10/136 @@ -454,6 +467,8 @@ int set_epoch_rtc(const struct hwclock_control *ctl) } #endif /* __alpha__ */ + + static int resolve_rtc_param_alias(const char *alias, uint64_t *value) { const struct hwclock_param *param = &hwclock_params[0]; diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index 520c64230c..61f684e389 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -1161,12 +1161,13 @@ manipulate_rtc_param(const struct hwclock_control *ctl) struct rtc_param param = {}; if (get_param_rtc(ctl, ¶m)) { - warnx(_("unable to read the RTC parameter 0x%llx."), param.param); + warnx(_("unable to read the RTC parameter 0x%jx."), + (uintmax_t) param.param); return 1; } - printf(_("The RTC parameter 0x%llx is set to 0x%llx.\n"), - param.param, param.uvalue); + printf(_("The RTC parameter 0x%jx is set to 0x%jx.\n"), + (uintmax_t) param.param, (uintmax_t) param.uvalue); } else if (ctl->param_set_option) { if (ctl->testing) @@ -1186,7 +1187,7 @@ static void out_version(void) static void __attribute__((__noreturn__)) usage(void) { - const struct hwclock_param *param = &hwclock_params[0]; + const struct hwclock_param *param = get_hwclock_params(); fputs(USAGE_HEADER, stdout); printf(_(" %s [function] [option...]\n"), program_invocation_short_name); diff --git a/sys-utils/hwclock.h b/sys-utils/hwclock.h index 8af7e3fdf6..9b553441c4 100644 --- a/sys-utils/hwclock.h +++ b/sys-utils/hwclock.h @@ -101,13 +101,7 @@ struct hwclock_param { const char *help; }; -static struct hwclock_param hwclock_params[] = { - { RTC_PARAM_FEATURES, "features", N_("supported features") }, - { RTC_PARAM_CORRECTION, "correction", N_("time correction") }, - { RTC_PARAM_BACKUP_SWITCH_MODE, "bsm", N_("backup switch mode") }, - { } -}; - +extern const struct hwclock_param *get_hwclock_params(void); extern int get_param_rtc(const struct hwclock_control *ctl, struct rtc_param *param); extern int set_param_rtc(const struct hwclock_control *ctl);