hwclock: define cmos_interface only if necessary
PATCH v2 1/1 hwclock: define cmos_interface only if necessary
From: Carlos Santos <[email protected]>
Make the static declaration of the cmos_interface struct and related functions conditional to i386/x86_64, preventing several "defined but not used" compiler warnings.
--- sys-utils/hwclock-cmos.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-)
sys-utils/hwclock-cmos.c +4 -18
@@ -75,17 +75,6 @@ static int inb(int c __attribute__((__unused__)))return 0 ; }# endif /* __i386__ __x86_64__ */ -#else -# warning "disable cmos access - not i386 or x86_64" -static void outb (int a __attribute__((__unused__)), -int b __attribute__((__unused__))) -{ -} - -static int inb (int c __attribute__((__unused__))) -{ -return 0 ; -}#endif /* for inb, outb */ #include "hwclock.h"
@@ -100,6 +89,8 @@ static int inb(int c __attribute__((__unused__)))*/ #define TM_EPOCH 1900 +#if defined(__i386__) || defined(__x86_64__) +static unsigned short clock_ctl_addr =0x70 ;static unsigned short clock_data_addr =0x71 ;
@@ -360,7 +351,6 @@ static int set_hardware_clock_cmos(const struct hwclock_control *ctlreturn 0 ; } -#if defined(__i386__) || defined(__x86_64__)# if defined(HAVE_IOPL )static int i386_iopl (const int level) {
@@ -373,12 +363,6 @@ static int i386_iopl(const int level __attribute__ ((__unused__))) return ioperm(clock_ctl_addr, 2, 1); }# endif -#else -static int i386_iopl (const int level __attribute__ ((__unused__))) -{ -return IOPL_NOT_IMPLEMENTED ; -} -#endif static int get_permissions_cmos (void ) {
@@ -407,6 +391,8 @@ static struct clock_ops cmos_interface = { get_device_path, }; +#endif +/* * return &cmos if cmos clock present, NULL otherwise. */
Signature · 1 line
2.18.1
Karel Zak
maintainerQuoted 3 lines · On Sun, Jun 23, 2019 at 07:30:52PM -0300, [email protected] wrote:
Make the static declaration of the
cmos_interfacestruct and related functions conditional to i386/x86_64, preventing several "defined but not used" compiler warnings.
I think we have to be more aggressive :-) It would be better to:
./configure.ac:
* add --disable-hwclock-cmos
* add USE_HWCLOCK_CMOS (enabled by default for i386/x86_64)
* add define(USE_HWCLOCK_CMOS)
sys-utils/Makemodule.am:
* compile hwclock-cmos.c only "if USE_HWCLOCK_CMOS"
hwclock:
* remove all unnecessary #ifdefs from hwclock-cmos.c
* add #ifdef USE_HWCLOCK_CMOS to hwclock.c:determine_clock_access_method()
Note that we already use the same for RTC (which is linux only).
The result will be more readable hwclock-cmos.c and only optional cmos code compilation.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 21 lines · Karel Zak
Quoted 3 lines · On Sun, Jun 23, 2019 at 07:30:52PM -0300, [email protected] wrote:
Make the static declaration of the
cmos_interfacestruct and related functions conditional to i386/x86_64, preventing several "defined but not used" compiler warnings.I think we have to be more aggressive :-) It would be better to:
./configure.ac:
* add --disable-hwclock-cmos
* addUSE_HWCLOCK_CMOS(enabled by default for i386/x86_64)
* adddefine(USE_HWCLOCK_CMOS)sys-utils/Makemodule.am:
* compilehwclock-cmos.conly "ifUSE_HWCLOCK_CMOS"hwclock:
* remove all unnecessary #ifdefs fromhwclock-cmos.c
* add #ifdefUSE_HWCLOCK_CMOSto hwclock.c:determine_clock_access_method()
Quoted 6 lines
Note that we already use the same for RTC (which is linux only).
The result will be more readable
hwclock-cmos.cand only optional cmos code compilation.Karel
OK, I will give it a try over the weekend.
Signature · 1 line
Carlos Santos <[email protected]>
Quoted 11 lines · Karel Zak
Quoted 3 lines · On Sun, Jun 23, 2019 at 07:30:52PM -0300, [email protected] wrote:
Make the static declaration of the
cmos_interfacestruct and related functions conditional to i386/x86_64, preventing several "defined but not used" compiler warnings.I think we have to be more aggressive :-) It would be better to:
./configure.ac:
* add --disable-hwclock-cmos
* addUSE_HWCLOCK_CMOS(enabled by default for i386/x86_64)
I don't know much about autoconf. How can I test the target architecture in config.ac.
Quoted 10 lines
* add
define(USE_HWCLOCK_CMOS)sys-utils/Makemodule.am:
* compilehwclock-cmos.conly "ifUSE_HWCLOCK_CMOS"hwclock:
* remove all unnecessary #ifdefs fromhwclock-cmos.c
* add #ifdefUSE_HWCLOCK_CMOSto hwclock.c:determine_clock_access_method()
Quoted 4 lines
Note that we already use the same for RTC (which is linux only).
The result will be more readable
hwclock-cmos.cand only optional cmos code compilation.
I just sent a third version of the patch comprising all these changes except for the i386/x86_64 test.
Signature · 1 line
Carlos Santos <[email protected]>
Karel Zak
maintainerQuoted 26 lines · Carlos Santos
Quoted 11 lines · Karel Zak
Quoted 3 lines · On Sun, Jun 23, 2019 at 07:30:52PM -0300, [email protected] wrote:
Make the static declaration of the
cmos_interfacestruct and related functions conditional to i386/x86_64, preventing several "defined but not used" compiler warnings.I think we have to be more aggressive :-) It would be better to:
./configure.ac:
* add --disable-hwclock-cmos
* addUSE_HWCLOCK_CMOS(enabled by default for i386/x86_64)I don't know much about autoconf. How can I test the target architecture in config.ac.
Quoted 10 lines
* add
define(USE_HWCLOCK_CMOS)sys-utils/Makemodule.am:
* compilehwclock-cmos.conly "ifUSE_HWCLOCK_CMOS"hwclock:
* remove all unnecessary #ifdefs fromhwclock-cmos.c
* add #ifdefUSE_HWCLOCK_CMOSto hwclock.c:determine_clock_access_method()
Quoted 7 lines
Quoted 4 lines
Note that we already use the same for RTC (which is linux only).
The result will be more readable
hwclock-cmos.cand only optional cmos code compilation.I just sent a third version of the patch comprising all these changes except for the i386/x86_64 test.
I have applied the patch and extended the ./confiugure stuff.
https://github.com/karelzak/util-linux/commit/c7eca69d6d89262c71b6d412f6b3a469fad07d7d
https://github.com/karelzak/util-linux/commit/b1062292066e0568adbbdbb104b7afdcc5dac25f
Thanks!
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com