Handle xlat styles when printing rlimit

Dmitry V. Levin ldv at altlinux.org
Sun Feb 17 23:48:25 UTC 2019


On Sun, Feb 17, 2019 at 03:37:08PM -0800, shankarapailoor wrote:
> Hi,
> 
> >setrlimit.c:49:24: error: format '%lx' expects argument of type 'long
> unsigned int', but argument 2 has type '
> uint64_t' {aka 'const long long unsigned int'} [-Werror=format=]
> 
> My compiler (gcc 9.0) says uint64_t is const long unsigned int and
> complains when I use %llx. I am not too sure what the right thing to do
> here is my apologies.

It depends on the target architecture.

[...]
> > > diff --git a/tests/setrlimit.c b/tests/setrlimit.c
> > > index f199abe1..084e7beb 100644
> > > --- a/tests/setrlimit.c
> > > +++ b/tests/setrlimit.c
> > > @@ -23,7 +23,14 @@ main(void)
> > >       for (xlat = resources; xlat->str; ++xlat) {
> > >               unsigned long res = 0xfacefeed00000000ULL | xlat->val;

This means that ...

> > >               long rc = syscall(__NR_setrlimit, res, 0);
> > > +#if XLAT_RAW
> > > +             printf("setrlimit(%#lx, NULL) = %s\n", xlat->val,

... you can cast xlat->val to unsigned int and print it as %#x.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20190218/ef2a4857/attachment.bin>


More information about the Strace-devel mailing list