RE: [PATCH v8 net-next 1/3] filter: add Extended BPF interpreter and converter

From: David Laight
Date: Tue Mar 11 2014 - 05:52:35 EST


From: David Miller
> From: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Date: Mon, 10 Mar 2014 19:02:18 -0700
>
> > I would generally suggest that people only use "bool" for function
> > return types, and absolutely nothing else. Seriously.
>
> I think it makes sense for function arguments too.

'bool' doesn't necessarily even make sense for function arguments
and results.
It might require the same additional masking of high bits that
are required for 'short' and 'char' parameters.

Also, IIRC, one of the arm ABIs used 32bit 'bool'.

Even the extra code that gets added to ensure that the 'bool'
values are either 0 or 1 can be a problem.
I don't know whether the recent compilers (or standards) say
whether the reader or writer is expected to enforce the domain.
But if the compiler uses a bit-wise AND for bool_a & bool_b there
is definitely scope for unexpected behaviour, and if the compiler
does anything else you get unwanted instructions and possibly branches.
Some old versions of gcc made a 'pigs breakfast' of bool_a |= bool_b.

David



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/