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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <670c60e46ee3f_9710f294da@iweiny-mobl.notmuch>
Date: Sun, 13 Oct 2024 19:08:04 -0500
From: Ira Weiny <ira.weiny@...el.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, Rasmus Villemoes
	<linux@...musvillemoes.dk>
CC: Ira Weiny <ira.weiny@...el.com>, Dave Jiang <dave.jiang@...el.com>, Fan Ni
	<fan.ni@...sung.com>, Jonathan Cameron <Jonathan.Cameron@...wei.com>, Navneet
 Singh <navneet.singh@...el.com>, Jonathan Corbet <corbet@....net>, Andrew
 Morton <akpm@...ux-foundation.org>, Dan Williams <dan.j.williams@...el.com>,
	Davidlohr Bueso <dave@...olabs.net>, "Alison Schofield"
	<alison.schofield@...el.com>, Vishal Verma <vishal.l.verma@...el.com>,
	<linux-btrfs@...r.kernel.org>, <linux-cxl@...r.kernel.org>,
	<linux-doc@...r.kernel.org>, <nvdimm@...ts.linux.dev>,
	<linux-kernel@...r.kernel.org>, Petr Mladek <pmladek@...e.com>, Steven
 Rostedt <rostedt@...dmis.org>, "Sergey Senozhatsky"
	<senozhatsky@...omium.org>
Subject: Re: [PATCH v4 02/28] printk: Add print format (%pra) for struct range

Andy Shevchenko wrote:
> On Wed, Oct 09, 2024 at 03:30:14PM +0200, Rasmus Villemoes wrote:
> 
> ...
> 
> > Rather than the struct assignments, I think it's easier to read if you
> > just do
> > 
> >   struct range r;
> > 
> >   r.start = 0xc0ffee00ba5eba11;
> >   r.end   = r.start;
> >   ...
> > 
> >   r.start = 0xc0ffee;
> >   r.end   = 0xba5eba11;
> >   ...
> > 
> > which saves two lines per test and for the first one makes it more
> > obvious that the start and end values are identical.
> 
> With DEFINE_RANGE() it will save even more lines!

Yea I've added DEFINE_RANGE().  Thanks.

> 
> ..
> 
> > > +		if (buf < end)
> > > +			*buf++ = '-';
> > 
> > No. Either all your callers pass a (probably stack-allocated) buffer
> > which is guaranteed to be big enough, in which case you don't need the
> > "if (buf < end)", or if some callers may "print" directly to the buffer
> > passed to vsnprintf(), the buf++ must still be done unconditionally in
> > order that vsnprintf(NULL, 0, ...) [used by fx kasprintf] can accurately
> > determine how large the output string would be.
> 
> Ah, good catch, I would add...
> 
> > So, either
> > 
> >   *buf++ = '-'
> > 
> > or
> > 
> >   if (buf < end)
> >     *buf = '-';
> >   buf++;
> 
> ...that we use rather ++buf in such cases, but it doesn't really matter.

Done.
Ira

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ