]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: cleanup hwclock_params[] use
authorKarel Zak <kzak@redhat.com>
Fri, 28 Jan 2022 11:15:39 +0000 (12:15 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 28 Jan 2022 11:15:39 +0000 (12:15 +0100)
* remove it from header file
* keep it 'static const'

Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/hwclock-rtc.c
sys-utils/hwclock.c
sys-utils/hwclock.h

index becfc7b83f281c3679cb85224d72e7af99449cfe..e10f7bce01ae9877ee1707681b74a93e9f6704b3 100644 (file)
@@ -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];
index 520c64230c68d5b40631388ec67135cff8d0a779..61f684e389b8cc489cde16176194963e72315e77 100644 (file)
@@ -1161,12 +1161,13 @@ manipulate_rtc_param(const struct hwclock_control *ctl)
                struct rtc_param param = {};
 
                if (get_param_rtc(ctl, &param)) {
-                       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);
index 8af7e3fdf600b749ff7205cf40860a2b8e2eadb5..9b553441c4b90f143b3b292be45934ae24a7f06a 100644 (file)
@@ -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);