Re: What's the best way to fix warnings from unused result

2019-04-07 Thread Hal Murray via devel


> Does a simple void cast work?  E.g.:
>   (void) strerror_r(...)

I haven't found the magic using that approach.

../../ntpd/nts.c:214:16: warning: ignoring return value of ‘strerror_r’, 
declared with attribute warn_unused_result [-Wunused-result]
 (void) strerror_r(errno, errbuf, sizeof(errbuf));
^


-- 
These are my opinions.  I hate spam.



___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel


Re: What's the best way to fix warnings from unused result

2019-04-07 Thread Fred Wright via devel



On Sun, 7 Apr 2019, Hal Murray wrote:


Does a simple void cast work?  E.g.:
(void) strerror_r(...)


I haven't found the magic using that approach.

../../ntpd/nts.c:214:16: warning: ignoring return value of ???strerror_r???,
declared with attribute warn_unused_result [-Wunused-result]
(void) strerror_r(errno, errbuf, sizeof(errbuf));
   ^


That's too bad; so you need to fix it the "hard way" after all.

It seems like a compiler bug to warn in that case.  Presumably the intent 
of the warning is to let you know that you're *unintentionally* ignoring

a result.  The void cast makes it clear that it's intentional.

Fred Wright
___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel


✘switch missing default case

2019-04-07 Thread Gary E. Miller via devel
Yo All!

New warning on arm64:

[ 99/144] Compiling ntpd/ntp_loopfilter.c
In file included from ../../ntpd/refclock_gpsd.c:78:
../../ntpd/../libjsmn/jsmn.c: In function ‘jsmn_parse_primitive’:
../../ntpd/../libjsmn/jsmn.c:43:3: warning: switch missing default case 
[-Wswitch-default]
   switch (js[parser->pos]) {
   ^~

[100/144] Compiling ntpd/ntp_packetstamp.c
[101/144] Compiling ntpd/ntp_peer.c



RGDS
GARY
---
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
g...@rellim.com  Tel:+1 541 382 8588

Veritas liberabit vos. -- Quid est veritas?
"If you can’t measure it, you can’t improve it." - Lord Kelvin


pgpVgUqX4uGcT.pgp
Description: OpenPGP digital signature
___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel


Re: switch missing default case

2019-04-07 Thread Hal Murray via devel
> New warning on arm64:

Also happens on Fedora, both 64 and 32 bit.


Is it reasonable to fix the CI system to complain about warnings except for a 
(hopefully short) list of known ones that we can't fix?


-- 
These are my opinions.  I hate spam.



___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel


Re: switch missing default case

2019-04-07 Thread Gary E. Miller via devel
Yo Hal!

On Sun, 07 Apr 2019 16:29:48 -0700
Hal Murray via devel  wrote:

> > New warning on arm64:  
> 
> Also happens on Fedora, both 64 and 32 bit.

Easy to fix.  If no one beats me to it I'll fix Monday.

> Is it reasonable to fix the CI system to complain about warnings
> except for a (hopefully short) list of known ones that we can't fix?

I'm unaware of any we can't fix, except the bison one.

RGDS
GARY
---
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
g...@rellim.com  Tel:+1 541 382 8588

Veritas liberabit vos. -- Quid est veritas?
"If you can’t measure it, you can’t improve it." - Lord Kelvin


pgpZ640oQ0b7x.pgp
Description: OpenPGP digital signature
___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel


Re: switch missing default case

2019-04-07 Thread Hal Murray via devel
> I'm unaware of any we can't fix, except the bison one.

There are several others.

>From old CentOS:
> ntp_parser.tab.c:389:6: warning: "YYENABLE_NLS" is not defined
> ntp_parser.tab.c:1323:6: warning: "YYLTYPE_IS_TRIVIAL" is not defined 

>From NetBSD on a Raspbery Pi:
> /usr/pkg/lib/libpython2.7.so: warning: warning: tmpnam()
> possibly used unsafely, use mkstemp() or mkdtemp()
> /usr/pkg/lib/libpython2.7.so: warning: warning: tempnam()
> possibly used unsafely, use mkstemp() or mkdtemp() 

>From old (but still supported) NetBSD:
> ../../ntpd/ntp_control.c:1305:17: warning: array subscript
> has type 'char' [-Wchar-subscripts]





-- 
These are my opinions.  I hate spam.



___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel


Re: What's the best way to fix warnings from unused result

2019-04-07 Thread Eric S. Raymond via devel
Hal Murray via devel :
> ../../ntpd/nts.c:213:9: warning: ignoring return value of ‘strerror_r’, 
> declared with attribute warn_unused_result [-Wunused-result]
> 
> I'm only getting this on Ubuntu, so a secondary question is why isn't that 
> check happening on other systems?

Probablty compiler version. As GCC has evolved it has gotten stricter
about this sort of thing.

> >From the man page:
>int strerror_r(int errnum, char *buf, size_t buflen);
>/* XSI-compliant */
> 
>char *strerror_r(int errnum, char *buf, size_t buflen);
>/* GNU-specific */
> 
> I don't know or care which version we get.  It's different on different 
> systems, so to save the result then say UNUSED_LOCAL gets slightly 
> complicated.

This is probably what you want:

./include/ntp_stdlib.h:162:#define IGNORE(r) do{if(r){}}while(0)
-- 
http://www.catb.org/~esr/";>Eric S. Raymond


___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel


Re: What's the best way to fix warnings from unused result

2019-04-07 Thread Achim Gratz via devel
Hal Murray via devel writes:
> I don't know or care which version we get.  It's different on different 
> systems, so to save the result then say UNUSED_LOCAL gets slightly 
> complicated.

--8<---cut here---start->8---
  Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

   strerror_r():
   The XSI-compliant version is provided if:
   (_POSIX_C_SOURCE >= 200112L) && !  _GNU_SOURCE
   Otherwise, the GNU-specific version is provided.
--8<---cut here---end--->8---

I think ntpsec strives for POSIX compliance, so if you get the GNU
version on a system  that has the XSI version that'd be an error with
how the feature test macros are supplied.

Similarly, if there are supported versions that only provide the GNU
signature, you'd need to encapsulate the type in something that depends
on the result of the configuration tests.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel


I think NTS is thread safe now

2019-04-07 Thread Hal Murray via devel



It gets 23 warnings on Ubuntu:
../../ntpd/nts_client.c:436:5: warning: ignoring return value of 
‘strerror_r’, declared with attribute warn_unused_result [-Wunused-result]

---

There is a trap in libntp/lib_strbuf.c that should log a message if 
lib_getbuf() is called from other than the main thread.
msyslog(LOG_ERR, "ERR: lib_getbuf() called from non-main thread.");
Please keep an eye out for them and if you see one, please send me a few lines 
from the log file around that one.

-- 
These are my opinions.  I hate spam.



___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel


Re: What's the best way to fix warnings from unused result

2019-04-07 Thread Hal Murray via devel


e...@thyrsus.com said:
> Probablty compiler version. As GCC has evolved it has gotten stricter about
> this sort of thing. 

Fedora 29, no warnings:
gcc (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2)

Ubuntu 18.10, warnings
gcc (Ubuntu 8.2.0-7ubuntu1) 8.2.0

Ubuntu 18.04.2 LTS, warnings
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

-

> This is probably what you want:
> ./include/ntp_stdlib.h:162:#define IGNORE(r) do{if(r){}}while(0)

Thanks.  Seems to be working.

While does that need the do/while around the if?  Doesn't the if alone do what 
we want?


-- 
These are my opinions.  I hate spam.



___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel


Re: What's the best way to fix warnings from unused result

2019-04-07 Thread Eric S. Raymond via devel
Hal Murray :
> 
> e...@thyrsus.com said:
> > Probablty compiler version. As GCC has evolved it has gotten stricter about
> > this sort of thing. 
> 
> Fedora 29, no warnings:
> gcc (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2)
> 
> Ubuntu 18.10, warnings
> gcc (Ubuntu 8.2.0-7ubuntu1) 8.2.0
> 
> Ubuntu 18.04.2 LTS, warnings
> gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

Huh.  OK, it's weirder than I knew then. I don't know where the variation is 
coming
from. 

> > This is probably what you want:
> > ./include/ntp_stdlib.h:162:#define IGNORE(r) do{if(r){}}while(0)
> 
> Thanks.  Seems to be working.
> 
> While does that need the do/while around the if?  Doesn't the if alone do 
> what 
> we want?

The do/while is a weird trick to make the macro statement-like so that you can
(and in fact must) follow it with a ;.
-- 
http://www.catb.org/~esr/";>Eric S. Raymond


___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel


Re: What's the best way to fix warnings from unused result

2019-04-07 Thread Fred Wright via devel



On Sun, 7 Apr 2019, Eric S. Raymond via devel wrote:

Hal Murray via devel :

../../ntpd/nts.c:213:9: warning: ignoring return value of ???strerror_r???,
declared with attribute warn_unused_result [-Wunused-result]

I'm only getting this on Ubuntu, so a secondary question is why isn't that
check happening on other systems?


Probablty compiler version. As GCC has evolved it has gotten stricter
about this sort of thing.


From the man page:

   int strerror_r(int errnum, char *buf, size_t buflen);
   /* XSI-compliant */

   char *strerror_r(int errnum, char *buf, size_t buflen);
   /* GNU-specific */

I don't know or care which version we get.  It's different on different
systems, so to save the result then say UNUSED_LOCAL gets slightly complicated.


This is probably what you want:

./include/ntp_stdlib.h:162:#define IGNORE(r) do{if(r){}}while(0)


Does a simple void cast work?  E.g.:

(void) strerror_r(...)

It certainly works for unused function arguments, and it's an actual 
official language feature for explicitly discarding results.  Granted, I 
know of one compiler that doesn't like it, but it's an oddball.


Fred Wright
___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel


Getting a serial port automatically set up at boot

2019-04-07 Thread Achim Gratz via devel


I have a few refclocks that are connected via a serial port (either USB
or a real one) and here's what needs to be set up for udev and systemd setting
those up correctly at boot, so you don't have to remember to run the
respective commands by hand.  The udev part is easy to find, it took me
a while to get systemd to set up the PPS.


A DCF77 receiver connected to the first serial port on a plain vanilla
(old) PC:

/etc/udev/rules.d/77-dcf77.rules 
--8<---cut here---start->8---
KERNEL=="ttyS0" SYMLINK+="refclock-0" GROUP="ntp"
KERNEL=="pps0"  SYMLINK+="refclockpps-0" GROUP="ntp"
KERNEL=="ttyS0" RUN+="/bin/setserial /dev/%k low_latency"
--8<---cut here---end--->8---

Now, you cannot do anything from a udev rule that runs for longer than
about three seconds (it'll get killed).  So for PPS via ldattach, you
need to ask systemd to do that:

/etc/systemd/system/pps0.service 
--8<---cut here---start->8---
[Unit]
Description=PPS activation
BindsTo=dev-ttyS0.device
After=dev-ttyS0.device

[Service]
Type=forking
ExecStart=/usr/sbin/ldattach PPS /dev/ttyS0
--8<---cut here---end--->8---


A GPS connected to an FTDI USB serial (which can relay PPS via DCD) on a
rasPi. There is already a /dev/pps0 running via PPS-GPIO, so /dev/pps1
is used for this GPS (which is the second one on this system, so
/dev/gps1):

/etc/udev/rules.d/99-navspark.rules 
--8<---cut here---start->8---
KERNEL=="pps1" SYMLINK+="gpspps1" GROUP="ntp"
KERNEL=="ttyUSB0" RUN+="/bin/setserial /dev/%k low_latency" RUN+="/bin/stty -F 
/dev/%k 115200" SYMLINK+="navspark-%n" SYMLINK+="gps1" GROUP="ntp"
--8<---cut here---end--->8---

/etc/systemd/system/pps1.service
--8<---cut here---start->8---
[Unit]
Description=PPS activation
BindsTo=dev-ttyUSB0.device
After=dev-ttyUSB0.device

[Service]
Type=forking
ExecStart=/usr/sbin/ldattach PPS /dev/ttyUSB0
--8<---cut here---end--->8---


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

___
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel