brl: don't use conversion to float for offset and count

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Jun 3 07:41:07 MDT 2014


On Sun, Jun 01, 2014 at 08:37:18PM +0200, Ralph Böhme wrote:
> Hi
> 
> attached is a small fix, that deals with wrong results by printf()
> conversion from integer to float when printing lock offsets and
> sizes. For large values such a conversion may produce wrong results,
> instead use one of the standard conversion specifiers for integers.
> 
> Example: The integer
> 
>   9223372036854775798 (= 0x7FFFFFFFFFFFFFF6)
> 
> is printed as
> 
>   9223372036854775808 (= 0x7FFFFFFFFFFFFFFF)
> 
> when using a cast to float (double) and a double conversion specifier.
> 
> Review appreciated.

Thanks, good catch!

https://en.wikipedia.org/wiki/Inttypes.h

has PRIu64 as the format specifier for a uint64_t. If you
look deep inside

http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf

it seems that this is C99 standard these days. Samba does
already use this in various places.

I could not find a reference to "j" in C99, only in susv4.
Both are probably possible, but for orthogonality reasons I
would argue to settle on one of both.

Any opinions?

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list