gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] featuretest macros


From: Greg Troxel
Subject: Re: [gpsd-dev] featuretest macros
Date: Fri, 21 Jun 2019 20:56:02 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (berkeley-unix)

"Gary E. Miller" <address@hidden> writes:

>> The ones I sent a few days ago were on netbsd-8.  By correct, I meant
>> that reading the source, I concur with the compiler that a warning is
>> in order.
>
> Which differs from the gpsd preference of "no warnings", if possible.
>
> These are the one you sent earlier this week?

Yes, the ones I sent, copied below.

Basically:

  a curses command with an extra argument, clearly a bug, and

  several instances of using printf %lu with uint32_t, also clearly a bug.

----------------------------------------
From: Greg Troxel <address@hidden>
Subject: [gpsd-dev] warnings on netbsd amd64 seem valid
To: address@hidden
Date: Wed, 19 Jun 2019 20:44:12 -0400 (2 days, 9 minutes, 50 seconds ago)

Greg Troxel <address@hidden> writes:

> gcc -o monitor_oncore.o -c -O2 -D_FORTIFY_SOURCE=2
> -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/python3.7
> -I/usr/X11R7/include -I/usr/X11R7/include/libdrm
> -I/usr/X11R7/include/freetype2 -pthread -Wall -Wcast-align -Wextra
> -Wmissing-declarations -Wmissing-prototypes
> -Wno-missing-field-initializers -Wno-uninitialized -Wpointer-arith
> -Wreturn-type -Wstrict-prototypes -Wvla -O2 -pthread
> -I/usr/pkg/include/libusb-1.0 monitor_oncore.c
> monitor_oncore.c: In function 'oncore_update':
> monitor_oncore.c:378:35: warning: too many arguments for format 
> [-Wformat-extra-args]
>       (void)mvwprintw(Bowin, 2, 2, "unknown", utc_offset);

This warning appears correct.  "unknown" does not contain a format
specifier and thus the utc_offset is extra.

> gcc -o monitor_sirf.o -c -O2 -D_FORTIFY_SOURCE=2 -I/usr/pkg/include
> -I/usr/include -I/usr/pkg/include/python3.7 -I/usr/X11R7/include
> -I/usr/X11R7/include/libdrm -I/usr/X11R7/include/freetype2 -pthread
> -Wall -Wcast-align -Wextra -Wmissing-declarations
> -Wmissing-prototypes -Wno-missing-field-initializers
> -Wno-uninitialized -Wpointer-arith -Wreturn-type -Wstrict-prototypes
> -Wvla -O2 -pthread -I/usr/pkg/include/libusb-1.0 monitor_sirf.c
> monitor_sirf.c: In function 'sirf_update':
> monitor_sirf.c:378:26: warning: format '%lu' expects argument of type 'long 
> unsigned int', but argument 5 has type 'unsigned int' [-Wformat=]
>   display(mid7win, 1, 16, "%lu", getbeu32(buf, 8)); /* Clock ppstimes */

getbeu32 is defined to uint32_t.  Which is semantically not "long",
ever, and on NetBSD/amd64 uint32_t is "unsigned int" while "long
unsigned int" is 64 bits.  I would expect the same on amd64 Linux and
other OSes (LP64).

Probably the right fix, while unpleasant, is to use PRIu32.  An
alternative is to use %ju and cast to intmax_t.   I am having to do that
in another program that prints a time_t -- which varies in size based on
OS, and for some OSes, by cpu.

> monitor_sirf.c:379:26: warning: format '%lu' expects argument of type 'long 
> unsigned int', but argument 5 has type 'unsigned int' [-Wformat=]
>   display(mid7win, 1, 29, "%lu", getbeu32(buf, 12)); /* Clock Bias */
>                           ^
> monitor_sirf.c:380:26: warning: format '%lu' expects argument of type 'long 
> unsigned int', but argument 5 has type 'unsigned int' [-Wformat=]
>   display(mid7win, 2, 11, "%lu", getbeu32(buf, 16)); /* Estimated Time */
>                           ^



reply via email to

[Prev in Thread] Current Thread [Next in Thread]