Util-Linux Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] hwclock: define cmos_interface only if necessary
@ 2019-06-23 22:30 unixmania
  2019-06-24  7:41 ` Karel Zak
  0 siblings, 1 reply; 5+ messages in thread
From: unixmania @ 2019-06-23 22:30 UTC (permalink / raw)
  To: util-linux; +Cc: Carlos Santos

From: Carlos Santos <unixmania@gmail.com>

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.

Signed-off-by: Carlos Santos <unixmania@gmail.com>
---
 sys-utils/hwclock-cmos.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/sys-utils/hwclock-cmos.c b/sys-utils/hwclock-cmos.c
index a11f676b8..51a405f42 100644
--- a/sys-utils/hwclock-cmos.c
+++ b/sys-utils/hwclock-cmos.c
@@ -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 *ctl
 	return 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.
  */
-- 
2.18.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] hwclock: define cmos_interface only if necessary
  2019-06-23 22:30 [PATCH v2] hwclock: define cmos_interface only if necessary unixmania
@ 2019-06-24  7:41 ` Karel Zak
  2019-06-27 13:59   ` Carlos Santos
  2019-07-03 16:37   ` Carlos Santos
  0 siblings, 2 replies; 5+ messages in thread
From: Karel Zak @ 2019-06-24  7:41 UTC (permalink / raw)
  To: unixmania; +Cc: util-linux

On Sun, Jun 23, 2019 at 07:30:52PM -0300, unixmania@gmail.com wrote:
> 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.

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


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] hwclock: define cmos_interface only if necessary
  2019-06-24  7:41 ` Karel Zak
@ 2019-06-27 13:59   ` Carlos Santos
  2019-07-03 16:37   ` Carlos Santos
  1 sibling, 0 replies; 5+ messages in thread
From: Carlos Santos @ 2019-06-27 13:59 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Mon, Jun 24, 2019 at 4:41 AM Karel Zak <kzak@redhat.com> wrote:
>
> On Sun, Jun 23, 2019 at 07:30:52PM -0300, unixmania@gmail.com wrote:
> > 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.
>
> 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

OK, I will give it a try over the weekend.

-- 
Carlos Santos <unixmania@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] hwclock: define cmos_interface only if necessary
  2019-06-24  7:41 ` Karel Zak
  2019-06-27 13:59   ` Carlos Santos
@ 2019-07-03 16:37   ` Carlos Santos
  2019-07-15 13:39     ` Karel Zak
  1 sibling, 1 reply; 5+ messages in thread
From: Carlos Santos @ 2019-07-03 16:37 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Mon, Jun 24, 2019 at 4:41 AM Karel Zak <kzak@redhat.com> wrote:
>
> On Sun, Jun 23, 2019 at 07:30:52PM -0300, unixmania@gmail.com wrote:
> > 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.
>
> 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)

I don't know much about autoconf. How can I test the target
architecture in config.ac.

>  * 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.

I just sent a third version of the patch comprising all these changes
except for the i386/x86_64 test.

-- 
Carlos Santos <unixmania@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] hwclock: define cmos_interface only if necessary
  2019-07-03 16:37   ` Carlos Santos
@ 2019-07-15 13:39     ` Karel Zak
  0 siblings, 0 replies; 5+ messages in thread
From: Karel Zak @ 2019-07-15 13:39 UTC (permalink / raw)
  To: Carlos Santos; +Cc: util-linux

On Wed, Jul 03, 2019 at 01:37:31PM -0300, Carlos Santos wrote:
> On Mon, Jun 24, 2019 at 4:41 AM Karel Zak <kzak@redhat.com> wrote:
> >
> > On Sun, Jun 23, 2019 at 07:30:52PM -0300, unixmania@gmail.com wrote:
> > > 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.
> >
> > 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)
> 
> I don't know much about autoconf. How can I test the target
> architecture in config.ac.
> 
> >  * 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.
> 
> 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

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-23 22:30 [PATCH v2] hwclock: define cmos_interface only if necessary unixmania
2019-06-24  7:41 ` Karel Zak
2019-06-27 13:59   ` Carlos Santos
2019-07-03 16:37   ` Carlos Santos
2019-07-15 13:39     ` Karel Zak

Util-Linux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/util-linux/0 util-linux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 util-linux util-linux/ https://lore.kernel.org/util-linux \
		util-linux@vger.kernel.org util-linux@archiver.kernel.org
	public-inbox-index util-linux


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.util-linux


AGPL code for this site: git clone https://public-inbox.org/ public-inbox