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: <Yoaiy1lc+MCMZFTQ@smile.fi.intel.com>
Date:   Thu, 19 May 2022 23:04:27 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Kent Overstreet <kent.overstreet@...il.com>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...r.kernel.org,
        pmladek@...e.com, rostedt@...dmis.org, senozhatsky@...omium.org,
        willy@...radead.org
Subject: Re: [PATCH v2 22/28] Input/joystick/analog: Convert from seq_buf ->
 printbuf

On Thu, May 19, 2022 at 01:24:15PM -0400, Kent Overstreet wrote:
> seq_buf is being deprecated, this converts to printbuf which is similar
> but heap allocates the string buffer.
> 
> This means we have to consider memory allocation context & failure: Here
> we're in device initialization so GFP_KERNEL should be fine, and also as
> we're in device initialization returning -ENOMEM is fine.

...

> +       int ret = 0;

Redundant assignment.

...

> -		seq_buf_printf(&s, " %d-hat",
> -			       hweight16(analog->mask & ANALOG_HATS_ALL));
> +		pr_buf(&buf, " %d-hat",
> +		       hweight16(analog->mask & ANALOG_HATS_ALL));

Now you may put it on one line here and in similar cases.

...

> +	ret = buf.allocation_failure ? -ENOMEM : 0;
> +	if (!ret)
> +		strlcpy(analog->name, buf.buf, sizeof(analog->name));
> +	printbuf_exit(&buf);
> +	return ret;

Looks like anti-pattern. On top a bit twisted error code manipulation before
checking for error codes, but what about

static int printbuf_export(*buf, *out, size)
{
	...
}

	ret = printbuf_export(&buf, analog->name, sizeof(analog->name));
	printbuf_exit(&buf);
	return ret;

?

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ