lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 21 Jun 2022 11:11:11 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Rasmus Villemoes' <linux@...musvillemoes.dk>,
        Kent Overstreet <kent.overstreet@...il.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "pmladek@...e.com" <pmladek@...e.com>
CC:     "rostedt@...dmis.org" <rostedt@...dmis.org>,
        "enozhatsky@...omium.org" <enozhatsky@...omium.org>,
        "willy@...radead.org" <willy@...radead.org>
Subject: RE: [PATCH v4 05/34] vsprintf: %pf(%p)

...
> > +Calling a pretty printer function
> > +---------------------------------
> > +
> > +::
> > +
> > +        %pf(%p)     pretty printer function taking one argument
> > +        %pf(%p,%p)  pretty printer function taking two arguments
> > +
> > +For calling generic pretty printers. A pretty printer is a function that takes
> > +as its first argument a pointer to a printbuf, and then zero or more additional
> > +pointer arguments. For example:
> > +
> > +        void foo_to_text(struct printbuf *out, struct foo *foo)
> > +        {
> > +                pr_buf(out, "bar=%u baz=%u", foo->bar, foo->baz);
> > +        }
> > +
> > +        printf("%pf(%p)", foo_to_text, foo);
> > +
> > +Note that a pretty-printer may not sleep, if called from printk(). If called
> > +from pr_buf() or sprintf() there are no such restrictions.

I've lost the original email :-)

If you are going to implement this foo_to_text() needs to
be passed the field width, precision and flags.

Is there a real use for multiple arguments %pf(%p,%p) that can't
be implemented by requiring the caller use a relay structure?
That (sort of) solves the problem of people expecting to be
able to pass integers though.

An alternative would be using an array of a union type
to pass through the values extracted from the original va_list.

Or pass the first as a pointer (to get the possibility of compile
time format checking and any others as a union[].

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ