[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250621082321.724b65dd@kernel.org>
Date: Sat, 21 Jun 2025 08:23:21 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Tony Nguyen <anthony.l.nguyen@...el.com>
Cc: davem@...emloft.net, pabeni@...hat.com, edumazet@...gle.com,
andrew+netdev@...n.ch, netdev@...r.kernel.org, Karol Kolacinski
<karol.kolacinski@...el.com>, jacob.e.keller@...el.com,
przemyslaw.kitszel@...el.com, richardcochran@...il.com, Michal Kubiak
<michal.kubiak@...el.com>, Milena Olech <milena.olech@...el.com>, Rinitha S
<sx.rinitha@...el.com>
Subject: Re: [PATCH net-next 07/15] ice: add ICE_READ/WRITE_CGU_REG_OR_DIE
helpers
On Wed, 18 Jun 2025 10:42:19 -0700 Tony Nguyen wrote:
> +#define ICE_READ_CGU_REG_OR_DIE(hw, addr, val) \
> + do { \
> + int __err = ice_read_cgu_reg((hw), (addr), (val)); \
> + \
> + if (__err) \
> + return __err; \
> + } while (0)
> int ice_write_cgu_reg(struct ice_hw *hw, u32 addr, u32 val);
> +#define ICE_WRITE_CGU_REG_OR_DIE(hw, addr, val) \
> + do { \
> + int __err = ice_write_cgu_reg((hw), (addr), (val)); \
> + \
> + if (__err) \
> + return __err; \
> + } while (0)
Quoting documentation:
12) Macros, Enums and RTL
-------------------------
[...]
Things to avoid when using macros:
1) macros that affect control flow:
.. code-block:: c
#define FOO(x) \
do { \
if (blah(x) < 0) \
return -EBUGGERED; \
} while (0)
is a **very** bad idea. It looks like a function call but exits the ``calling``
function; don't break the internal parsers of those who will read the code.
See: https://www.kernel.org/doc/html/next/process/coding-style.html#macros-enums-and-rtl
Powered by blists - more mailing lists