Re: [OSS-Tools] [PATCH dt-utils 11/12] state: fix formatting of "off_t" variables

2019-02-05 Thread Ulrich Ölmann
On Mon, Feb 04 2019 at 10:06 +0100, Uwe Kleine-König 
 wrote:
> On Mon, Feb 04, 2019 at 08:54:29AM +0100, Juergen Borleis wrote:
>> On Sunday 03 February 2019 22:48:06 Ulrich Ölmann wrote:
>> > Explicitely casting an "off_t" variable to "long long" and formatting it
>> > via "%lld" or "%llx" respectively makes 32- as well as 64-bit compilers
>> > happy (tested with gcc-8.2.1 and clang-7.0.1).
>>
>> Könnte hier der Cast (intmax_t) und der Prefix 'j' vielleicht besser sein?
>>
>> off_t blub;
>>
>>  printf("Blub is: %jd\n", (intmax_t)blub);
>
> Note: the j length modifier exists only since glibc 2.1. Don't know
> about non-Linux (or alternative Linux) libc implementations. (Do we care
> about those?). Just checked the OpenSolaris state, printf there knows
> about 'j', but notes:
>
>   If  the j  length modifier is used, 32-bit applications that
>   were compiled using c89 on releases prior to Solaris 10 will
>   experience undefined behavior

Unfortunately using "%j" is not an option as this code is shared with
barebox' state implementation and barebox only supports a subset of the
formats that glibc offers which does not include "%j", see [1].

Best regards
Ulrich

[1] https://github.com/saschahauer/barebox/blob/master/lib/vsprintf.c#L364
--
Pengutronix e.K.   | Ulrich Ölmann   |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
OSS-Tools mailing list
OSS-Tools@pengutronix.de

Re: [OSS-Tools] [PATCH dt-utils 11/12] state: fix formatting of "off_t" variables

2019-02-04 Thread Uwe Kleine-König
On Mon, Feb 04, 2019 at 08:54:29AM +0100, Juergen Borleis wrote:
> On Sunday 03 February 2019 22:48:06 Ulrich Ölmann wrote:
> > Explicitely casting an "off_t" variable to "long long" and formatting it
> > via "%lld" or "%llx" respectively makes 32- as well as 64-bit compilers
> > happy (tested with gcc-8.2.1 and clang-7.0.1).
> 
> Könnte hier der Cast (intmax_t) und der Prefix 'j' vielleicht besser sein?
> 
> off_t blub;
> 
>  printf("Blub is: %jd\n", (intmax_t)blub);

Note: the j length modifier exists only since glibc 2.1. Don't know
about non-Linux (or alternative Linux) libc implementations. (Do we care
about those?). Just checked the OpenSolaris state, printf there knows
about 'j', but notes:

If  the j  length modifier is used, 32-bit applications that
were compiled using c89 on releases prior to Solaris 10 will
experience undefined behavior

Best regards
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |

___
OSS-Tools mailing list
OSS-Tools@pengutronix.de

Re: [OSS-Tools] [PATCH dt-utils 11/12] state: fix formatting of "off_t" variables

2019-02-03 Thread Juergen Borleis
On Sunday 03 February 2019 22:48:06 Ulrich Ölmann wrote:
> Explicitely casting an "off_t" variable to "long long" and formatting it
> via "%lld" or "%llx" respectively makes 32- as well as 64-bit compilers
> happy (tested with gcc-8.2.1 and clang-7.0.1).

Könnte hier der Cast (intmax_t) und der Prefix 'j' vielleicht besser sein?

off_t blub;

 printf("Blub is: %jd\n", (intmax_t)blub);

jb

___
OSS-Tools mailing list
OSS-Tools@pengutronix.de