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: <xubjmxig4luag27ifnmqmv3x3bvzhwczwvw34kw6tssaa2d24t@ysnqh5e3g7sz>
Date: Sun, 10 Nov 2024 16:34:30 -0500
From: Aren <aren@...cevolution.org>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, 
	Jonathan Cameron <jic23@...nel.org>, Lars-Peter Clausen <lars@...afoo.de>, 
	Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, 
	Conor Dooley <conor+dt@...nel.org>, Chen-Yu Tsai <wens@...e.org>, 
	Jernej Skrabec <jernej.skrabec@...il.com>, Samuel Holland <samuel@...lland.org>, 
	Kaustabh Chakraborty <kauschluss@...root.org>, Barnabás Czémán <trabarni@...il.com>, 
	Ondrej Jirman <megi@....cz>, 
	Uwe Kleine-König <u.kleine-koenig@...gutronix.de>, linux-iio@...r.kernel.org, devicetree@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org, 
	linux-sunxi@...ts.linux.dev, Dragan Simic <dsimic@...jaro.org>, phone-devel@...r.kernel.org
Subject: Re: [PATCH v4 4/6] iio: light: stk3310: use dev_err_probe where
 possible

On Sun, Nov 10, 2024 at 09:52:32PM +0200, Andy Shevchenko wrote:
> Sun, Nov 10, 2024 at 02:14:24PM -0500, Aren kirjoitti:
> > On Mon, Nov 04, 2024 at 10:40:16AM +0200, Andy Shevchenko wrote:
> > > On Sat, Nov 02, 2024 at 03:50:41PM -0400, Aren Moynihan wrote:
> 
> ...
> 
> > > >  #define STK3310_REGFIELD(name)						    \
> > > >  	do {								    \
> > > >  		data->reg_##name =					    \
> > > > -			devm_regmap_field_alloc(&client->dev, regmap,	    \
> > > > +			devm_regmap_field_alloc(dev, regmap,		    \
> > > >  				stk3310_reg_field_##name);		    \
> > > > -		if (IS_ERR(data->reg_##name)) {				    \
> > > > -			dev_err(&client->dev, "reg field alloc failed.\n"); \
> > > > -			return PTR_ERR(data->reg_##name);		    \
> > > > -		}							    \
> > > > +		if (IS_ERR(data->reg_##name))				    \
> > > 
> > > > +			return dev_err_probe(dev,			    \
> > > > +				PTR_ERR(data->reg_##name),		    \
> > > 
> > > AFAICS these two can be put on one.
> > 
> > This doesn't leave room for whitespace between the end of line and "\",
> 
> Is it a problem?

It feels a bit camped and not as readable to me:

#define STK3310_REGFIELD(name)						    \
	do {								    \
		data->reg_##name =					    \
			devm_regmap_field_alloc(dev, regmap,		    \
				stk3310_reg_field_##name);		    \
		if (IS_ERR(data->reg_##name))				    \
			return dev_err_probe(dev, PTR_ERR(data->reg_##name),\
					     "reg field alloc failed.\n");  \
	} while (0)

Removing a level of indentation makes it much better

#define STK3310_REGFIELD(name) ({						\
	data->reg_##name = devm_regmap_field_alloc(dev, regmap,			\
						   stk3310_reg_field_##name);   \
	if (IS_ERR(data->reg_##name))						\
		return dev_err_probe(dev, PTR_ERR(data->reg_##name),		\
				     "reg field alloc failed\n");		\
})

> > replacing "do { } while (0)" with "({ })" and deindenting could make
> > enough room to clean this up the formatting of this macro though.
> 
> do {} while (0) is C standard, ({}) is not.

({ }) is used throughout the kernel, and is documented as such[1]. I
don't see a reason to avoid it, if it helps readability.

1: the "GNU Extensions" section of Documentation/kernel-hacking/hacking.rst

 - Aren

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ