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]
Date:   Mon, 05 Sep 2016 11:27:28 +0200
From:   Arnd Bergmann <arnd@...db.de>
To:     linux-arm-kernel@...ts.infradead.org
Cc:     Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
        Stephen Boyd <sboyd@...eaurora.org>, mark.rutland@....com,
        devicetree@...r.kernel.org, catalin.marinas@....com,
        alexandre.torgue@...com, manabian@...il.com, khilman@...libre.com,
        mturquette@...libre.com, will.deacon@....com, robh+dt@...nel.org,
        peppe.cavallaro@...com, carlo@...one.org,
        linux-amlogic@...ts.infradead.org, netdev@...r.kernel.org
Subject: Re: [PATCH v3 4/5] net: stmmac: add a glue driver for the Amlogic Meson 8b / GXBB DWMAC

On Sunday, September 4, 2016 8:20:15 PM CEST Martin Blumenstingl wrote:
> 
> >> +     dwmac->m25_div_clk = devm_clk_register(dev, &dwmac->m25_div.hw);
> >> +     if (WARN_ON(PTR_ERR_OR_ZERO(dwmac->m25_div_clk)))
> >> +             return PTR_ERR(dwmac->m25_div_clk);
> >> +
> >> +     return 0;
> >
> > This could be return WARN_ON(PTR_ERR_OR_ZERO(...))
> This would work as well but I prefer the way it is right now (as one
> could easily extend the code without having to touch any existing code
> apart from the last return).
> However, as it's always the case with personal preference: if
> coding-style requires me to change it then I'll do so, just let me
> know.
> 
> I have addressed all other issues you found (thanks for that!) in v4
> (which I am about to send in the next few minutes).


Both of these are fairly unusual. The most common way to write it is

	if (WARN_ON(IS_ERR(dwmac->m25_div_clk)))
		return PTR_ERR(dwmac->m25_div_clk);
   return 0;

However, I now tend to prefer

	ret = PTR_ERR_OR_ZERO(dwmac->m25_div_clk);
	WARN_ON(ret);
	return ret;

which is less likely to cause false-positive warnings when building
with -Wmaybe-uninitialized than any of the other ones.

Please don't use PTR_ERR_OR_ZERO() as a condition, that is what
IS_ERR() is meant for.

	Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ