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: <1382725918.2425.2.camel@joe-AO722>
Date:	Fri, 25 Oct 2013 11:31:58 -0700
From:	Joe Perches <joe@...ches.com>
To:	Arvid Brodin <arvid.brodin@...n.com>
Cc:	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	David Miller <davem@...emloft.net>,
	Stephen Hemminger <shemminger@...tta.com>,
	Javier Boticario <jboticario@...il.com>,
	"balferreira@...glemail.com" <balferreira@...glemail.com>,
	Elías Molina Muñoz 
	<elias.molina@....es>
Subject: Re: [PATCH v5] net/hsr: Add support for the High-availability
 Seamless Redundancy protocol (HSRv0)

On Fri, 2013-10-25 at 20:20 +0200, Arvid Brodin wrote:
> On 2013-10-23 18:52, Joe Perches wrote:
> > On Wed, 2013-10-23 at 18:09 +0200, Arvid Brodin wrote:
[]
> >> +/* above(a, b) - return 1 if a > b, 0 otherwise.
> >> + */
> >> +static bool above(u16 a, u16 b)
> >> +{
> >> +	/* Remove inconsistency where above(a, b) == below(a, b) */
> >> +	if ((int) b - a == 32768)
> >> +		return 0;
> >> +
> >> +	return (((s16) (b - a)) < 0);
> >> +}
> >> +#define below(a, b)		above((b), (a))
> >> +#define above_or_eq(a, b)	(!below((a), (b)))
> >> +#define below_or_eq(a, b)	(!above((a), (b)))
> > 
> > This looks odd. 
> 
> It relies on unsigned arithmetic to compare two values that may wrap. I.e.,
> it doesn't care about the absolute sizes, but only about the distance 
> between the numbers. 
> 
> It is inspired in part by the code in jiffies.h, but adapted to 16-bit
> types. The code you suggested (below) will not work in this case.
> 
> See e.g. http://en.wikipedia.org/wiki/Serial_number_arithmetic

No worries, I was just reading the comment as the
comment doesn't match the code.

Perhaps the comment should be updated to reflect the
wrapping test.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ