Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH 1/3] hwclock: fix signed/unsigned comparison warning on alpha
@ 2015-08-21 14:13 Andreas Henriksson
  2015-08-21 14:13 ` [PATCH 2/3] hwclock: fix fgets unchecked return value " Andreas Henriksson
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andreas Henriksson @ 2015-08-21 14:13 UTC (permalink / raw)
  To: util-linux; +Cc: Andreas Henriksson

Fixes the following warning:
sys-utils/hwclock.c: In function 'manipulate_epoch':
sys-utils/hwclock.c:1465:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (epoch_opt == -1)

Full build log available on:
https://buildd.debian.org/status/fetch.php?pkg=util-linux&arch=alpha&ver=2.26.2-9&stamp=1440078034

Detected by/via:
https://qa.debian.org/bls/packages/u/util-linux.html

Please note that this has never actually been (build-)tested on alpha,
but should hopefully resolve the warning. Note also that limits.h is
already included.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
---
 sys-utils/hwclock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
index f04cf2b..bdb98e2 100644
--- a/sys-utils/hwclock.c
+++ b/sys-utils/hwclock.c
@@ -137,7 +137,7 @@ int debug;
 bool badyear;
 
 /* User-specified epoch, used when rtc fails to return epoch. */
-unsigned long epoch_option = -1;
+unsigned long epoch_option = ULONG_MAX;
 
 /*
  * Almost all Award BIOS's made between 04/26/94 and 05/31/95 have a nasty
@@ -1452,7 +1452,7 @@ manipulate_epoch(const bool getepoch,
 			printf(_("Kernel is assuming an epoch value of %lu\n"),
 			       epoch);
 	} else if (setepoch) {
-		if (epoch_opt == -1)
+		if (epoch_opt == ULONG_MAX)
 			warnx(_
 			      ("To set the epoch value, you must use the 'epoch' "
 			       "option to tell to what value to set it."));
-- 
2.1.4


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

* [PATCH 2/3] hwclock: fix fgets unchecked return value warning on alpha
  2015-08-21 14:13 [PATCH 1/3] hwclock: fix signed/unsigned comparison warning on alpha Andreas Henriksson
@ 2015-08-21 14:13 ` Andreas Henriksson
  2015-08-21 14:13 ` [PATCH 3/3] hwclock: fix iopl implicit declaration " Andreas Henriksson
  2015-08-24  8:58 ` [PATCH 1/3] hwclock: fix signed/unsigned comparison " Karel Zak
  2 siblings, 0 replies; 6+ messages in thread
From: Andreas Henriksson @ 2015-08-21 14:13 UTC (permalink / raw)
  To: util-linux; +Cc: Andreas Henriksson

Build warning:
sys-utils/hwclock-cmos.c: In function 'is_in_cpuinfo':
sys-utils/hwclock-cmos.c:162:4: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result [-Wunused-result]
    fgets(field, 256, cpuinfo);

Full build log:
https://buildd.debian.org/status/fetch.php?pkg=util-linux&arch=alpha&ver=2.26.2-9&stamp=1440078034

Detected by/via:
https://qa.debian.org/bls/packages/u/util-linux.html

This change has never actually been (build-)tested on alpha, but
hopefully the change should fix the warning.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
---
 sys-utils/hwclock-cmos.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys-utils/hwclock-cmos.c b/sys-utils/hwclock-cmos.c
index 8d68808..de678ab 100644
--- a/sys-utils/hwclock-cmos.c
+++ b/sys-utils/hwclock-cmos.c
@@ -152,15 +152,15 @@ static int is_in_cpuinfo(char *fmt, char *str)
 
 	sprintf(format, "%s : %s", fmt, "%255s");
 
-	if ((cpuinfo = fopen("/proc/cpuinfo", "r")) != NULL) {
-		while (!feof(cpuinfo)) {
+	cpuinfo = fopen("/proc/cpuinfo", "r");
+	if (cpuinfo) {
+		do {
 			if (fscanf(cpuinfo, format, field) == 1) {
 				if (strncmp(field, str, strlen(str)) == 0)
 					found = 1;
 				break;
 			}
-			fgets(field, 256, cpuinfo);
-		}
+		} while (fgets(field, 256, cpuinfo));
 		fclose(cpuinfo);
 	}
 	return found;
-- 
2.1.4


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

* [PATCH 3/3] hwclock: fix iopl implicit declaration warning on alpha
  2015-08-21 14:13 [PATCH 1/3] hwclock: fix signed/unsigned comparison warning on alpha Andreas Henriksson
  2015-08-21 14:13 ` [PATCH 2/3] hwclock: fix fgets unchecked return value " Andreas Henriksson
@ 2015-08-21 14:13 ` Andreas Henriksson
  2015-08-24  8:58 ` [PATCH 1/3] hwclock: fix signed/unsigned comparison " Karel Zak
  2 siblings, 0 replies; 6+ messages in thread
From: Andreas Henriksson @ 2015-08-21 14:13 UTC (permalink / raw)
  To: util-linux; +Cc: Andreas Henriksson

Build warning:
sys-utils/hwclock-cmos.c: In function 'i386_iopl':
sys-utils/hwclock-cmos.c:611:9: warning: implicit declaration of function 'iopl' [-Wimplicit-function-declaration]
  return iopl(level);
         ^
sys-utils/hwclock-cmos.c:611:2: warning: nested extern declaration of 'iopl' [-Wnested-externs]
  return iopl(level);
  ^

Also:
checking sys/io.h usability... yes
checking sys/io.h presence... yes
checking for sys/io.h... yes

Full build log:
https://buildd.debian.org/status/fetch.php?pkg=util-linux&arch=alpha&ver=2.26.2-9&stamp=1440078034

Detected by/via:
https://qa.debian.org/bls/packages/u/util-linux.html

Please note that this has never been (build-)tested, but should hopefully
resolve the warning.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
---
 sys-utils/hwclock-cmos.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sys-utils/hwclock-cmos.c b/sys-utils/hwclock-cmos.c
index de678ab..7f564e7 100644
--- a/sys-utils/hwclock-cmos.c
+++ b/sys-utils/hwclock-cmos.c
@@ -79,9 +79,14 @@ int inb(int c __attribute__ ((__unused__)))
 #endif				/* __i386__ __x86_64__ */
 
 #elif defined(__alpha__)
+# ifdef HAVE_SYS_IO_H
+#  include <sys/io.h>
+# else
 /* <asm/io.h> fails to compile, probably because of u8 etc */
 extern unsigned int inb(unsigned long port);
 extern void outb(unsigned char b, unsigned long port);
+extern int iopl(int level);
+# endif
 #else
 static void outb(int a __attribute__ ((__unused__)),
 	  int b __attribute__ ((__unused__)))
-- 
2.1.4


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

* Re: [PATCH 1/3] hwclock: fix signed/unsigned comparison warning on alpha
  2015-08-21 14:13 [PATCH 1/3] hwclock: fix signed/unsigned comparison warning on alpha Andreas Henriksson
  2015-08-21 14:13 ` [PATCH 2/3] hwclock: fix fgets unchecked return value " Andreas Henriksson
  2015-08-21 14:13 ` [PATCH 3/3] hwclock: fix iopl implicit declaration " Andreas Henriksson
@ 2015-08-24  8:58 ` Karel Zak
  2015-09-01 14:13   ` Andreas Henriksson
  2 siblings, 1 reply; 6+ messages in thread
From: Karel Zak @ 2015-08-24  8:58 UTC (permalink / raw)
  To: Andreas Henriksson; +Cc: util-linux

On Fri, Aug 21, 2015 at 04:13:27PM +0200, Andreas Henriksson wrote:
>  sys-utils/hwclock.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied all three patches. It would be nice to test it on alphas.
Thanks.

    Karel

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

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

* Re: [PATCH 1/3] hwclock: fix signed/unsigned comparison warning on alpha
  2015-08-24  8:58 ` [PATCH 1/3] hwclock: fix signed/unsigned comparison " Karel Zak
@ 2015-09-01 14:13   ` Andreas Henriksson
  2015-09-07  6:52     ` Karel Zak
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Henriksson @ 2015-09-01 14:13 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

[-- Attachment #1: Type: text/plain, Size: 7968 bytes --]

Hello!

On Mon, Aug 24, 2015 at 10:58:35AM +0200, Karel Zak wrote:
> On Fri, Aug 21, 2015 at 04:13:27PM +0200, Andreas Henriksson wrote:
> >  sys-utils/hwclock.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Applied all three patches. It would be nice to test it on alphas.
> Thanks.

The alpha buildds has now caught up and a full build log of 2.27-rc2
is available here:
https://buildd.debian.org/status/fetch.php?pkg=util-linux&arch=alpha&ver=2.27~rc2-2&stamp=1441074407

(Other architectures build logs available by clicking "Installed" on this page:
https://buildd.debian.org/status/package.php?p=util-linux&suite=experimental )

The committed patches seems to have had the desired effect and fixed
the compiler warnings they where aiming at.

Remaining warnings for alpha arch specific code in hwclock:

gcc -DHAVE_CONFIG_H -I.  -include config.h -I./include -DLOCALEDIR=\"/usr/share/locale\" -D_PATH_LOCALSTATEDIR=\"/run\" -D_FORTIFY_SOURCE=2 -fsigned-char -fno-common -Wall -Werror=sequence-point -Wextra -Wmissing-declarations -Wmissing-parameter-type -Wmissing-prototypes -Wno-missing-field-initializers -Wredundant-decls -Wsign-compare -Wtype-limits -Wuninitialized -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-parameter -Wunused-result -Wunused-variable -Wnested-externs -Wpointer-arith -Wstrict-prototypes -Wimplicit-function-declaration -g -O2 -Wformat -Werror=format-security -c -o sys-utils/hwclock.o sys-utils/hwclock.c
In file included from ./include/nls.h:24:0,
                 from ./include/closestream.h:11,
                 from sys-utils/hwclock.c:77:
sys-utils/hwclock.c: In function 'manipulate_epoch':
sys-utils/hwclock.c:1471:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
           ("Not setting the epoch to %d - testing only.\n"),
            ^
sys-utils/hwclock.c:1470:11: note: in expansion of macro '_'
    printf(_
           ^
gcc -DHAVE_CONFIG_H -I.  -include config.h -I./include -DLOCALEDIR=\"/usr/share/locale\" -D_PATH_LOCALSTATEDIR=\"/run\" -D_FORTIFY_SOURCE=2 -fsigned-char -fno-common -Wall -Werror=sequence-point -Wextra -Wmissing-declarations -Wmissing-parameter-type -Wmissing-prototypes -Wno-missing-field-initializers -Wredundant-decls -Wsign-compare -Wtype-limits -Wuninitialized -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-parameter -Wunused-result -Wunused-variable -Wnested-externs -Wpointer-arith -Wstrict-prototypes -Wimplicit-function-declaration -g -O2 -Wformat -Werror=format-security -c -o sys-utils/hwclock-cmos.o sys-utils/hwclock-cmos.c
sys-utils/hwclock-cmos.c: In function 'set_cmos_epoch':
sys-utils/hwclock-cmos.c:183:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (epoch_option != -1) {
                   ^
sys-utils/hwclock-cmos.c: In function 'atomic':
sys-utils/hwclock-cmos.c:290:3: warning: output constraint '=' for operand 0 is not at the beginning
   asm volatile ("rpcc %0":"r=" (ts1));
   ^
sys-utils/hwclock-cmos.c:292:3: warning: output constraint '=' for operand 0 is not at the beginning
   asm volatile ("rpcc %0":"r=" (ts2));
   ^
sys-utils/hwclock-cmos.c:290:3: warning: output constraint '=' for operand 0 is not at the beginning
   asm volatile ("rpcc %0":"r=" (ts1));
   ^
sys-utils/hwclock-cmos.c:292:3: warning: output constraint '=' for operand 0 is not at the beginning
   asm volatile ("rpcc %0":"r=" (ts2));
   ^
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
 atomic(const char *name, unsigned long (*op) (unsigned long), unsigned long arg)
 ^
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
 }
 ^
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:678:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
 atomic(const char *name, unsigned long (*op) (unsigned long), unsigned long arg)
 ^
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:285:1: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:290:3: warning: output constraint '=' for operand 0 is not at the beginning
   asm volatile ("rpcc %0":"r=" (ts1));
   ^
sys-utils/hwclock-cmos.c:290:3: warning: output constraint '=' for operand 0 is not at the beginning
sys-utils/hwclock-cmos.c:292:3: warning: output constraint '=' for operand 0 is not at the beginning
   asm volatile ("rpcc %0":"r=" (ts2));
   ^
sys-utils/hwclock-cmos.c:292:3: warning: output constraint '=' for operand 0 is not at the beginning


The first warning should be trivially fixed by the attached patch,
changing a %d to %lu for printing epoch_opt.
The hwclock-cmos.c sign/unsigned comparison could be fixed by
including limits.h and using ULONG_MAX instead of -1 in epoch_option
comparison, similar to what was done in hwclock.c already.
Not sure how to deal with the assembler warnings....

Regards,
Andreas Henriksson

[-- Attachment #2: ul-alpha-hwclock-fix-format-warning.patch --]
[-- Type: text/x-diff, Size: 636 bytes --]

From: Andreas Henriksson <andreas@fatal.se>
Subject: hwclock: fix format warning in alpha code

Signed-off-by: Andreas Henriksson <andreas@fatal.se>

diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
index bdb98e2..4b201d7 100644
--- a/sys-utils/hwclock.c
+++ b/sys-utils/hwclock.c
@@ -1458,7 +1458,7 @@ manipulate_epoch(const bool getepoch,
 			       "option to tell to what value to set it."));
 		else if (testing)
 			printf(_
-			       ("Not setting the epoch to %d - testing only.\n"),
+			       ("Not setting the epoch to %lu - testing only.\n"),
 			       epoch_opt);
 		else if (set_epoch_rtc(epoch_opt))
 			printf(_

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

* Re: [PATCH 1/3] hwclock: fix signed/unsigned comparison warning on alpha
  2015-09-01 14:13   ` Andreas Henriksson
@ 2015-09-07  6:52     ` Karel Zak
  0 siblings, 0 replies; 6+ messages in thread
From: Karel Zak @ 2015-09-07  6:52 UTC (permalink / raw)
  To: Andreas Henriksson; +Cc: util-linux

On Tue, Sep 01, 2015 at 04:13:27PM +0200, Andreas Henriksson wrote:
> The first warning should be trivially fixed by the attached patch,

 Applied, thanks.

> Not sure how to deal with the assembler warnings....

 Me too :-)

    Karel

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

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

end of thread, other threads:[~2015-09-07  6:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-21 14:13 [PATCH 1/3] hwclock: fix signed/unsigned comparison warning on alpha Andreas Henriksson
2015-08-21 14:13 ` [PATCH 2/3] hwclock: fix fgets unchecked return value " Andreas Henriksson
2015-08-21 14:13 ` [PATCH 3/3] hwclock: fix iopl implicit declaration " Andreas Henriksson
2015-08-24  8:58 ` [PATCH 1/3] hwclock: fix signed/unsigned comparison " Karel Zak
2015-09-01 14:13   ` Andreas Henriksson
2015-09-07  6:52     ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox