Thread (3 messages) flat view 3 messages, 2 authors, 2021-11-22

Re: [PATCH] drivers/net/ethernet/sfc/: Simplify code

From: Alejandro Colomar (man-pages) <hidden>
Date: 2021-11-22 17:19:23

Hi Edward,

On 11/22/21 17:17, Edward Cree wrote:
On 20/11/2021 20:14, Alejandro Colomar wrote:
quoted
That ternary operator has
the same exact code in both of the branches.

Unless there's some hidden magic in the condition,
there's no reason for it to be,
and it can be replaced
by the code in one of the branches.

That code has been untouched since it was added,
so there's no information in git about
why it was written that way.

Signed-off-by: Alejandro Colomar <redacted>
Cc: Edward Cree <ecree.xilinx@gmail.com>
Cc: Martin Habets <redacted>
Cc: netdev@vger.kernel.org
I guess it's there for type-checking — essentially as an assert that
  field_type == typeof(efx_##source_name.field).  Probably when it was
  added there was no standard way to do this; now we could probably
  use <linux/typecheck.h> or some such.
The comment just above the macro does mention "with type-checking".
Yes, that's why I suggested there was probably some black magic 
involved.  But I couldn't read it, though.

I suggest replacing it with a static_assert(__same_type()) thingy.

Cheers,
Alex


-- 
Alejandro Colomar
Linux man-pages comaintainer; http://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help