2022-04-16 02:25:41

by Yihao Han

[permalink] [raw]
Subject: [PATCH v2] net: qlogic: qlcnic: simplify if-if to if-else

Replace `if (!pause->autoneg)` with `else` for simplification
according to the kernel coding style:

"Do not unnecessarily use braces where a single statement will do."

...

"This does not apply if only one branch of a conditional statement is
a single statement; in the latter case use braces in both branches"

Please refer to:
https://www.kernel.org/doc/html/v5.17-rc8/process/coding-style.html

Suggested-by: Benjamin Poirier <[email protected]>
Signed-off-by: Yihao Han <[email protected]>
---
v2:edit commit message
---
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
index bd0607680329..e3842eaf1532 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
@@ -3752,7 +3752,7 @@ int qlcnic_83xx_set_pauseparam(struct qlcnic_adapter *adapter,
if (ahw->port_type == QLCNIC_GBE) {
if (pause->autoneg)
ahw->port_config |= QLC_83XX_ENABLE_AUTONEG;
- if (!pause->autoneg)
+ else
ahw->port_config &= ~QLC_83XX_ENABLE_AUTONEG;
} else if ((ahw->port_type == QLCNIC_XGBE) && (pause->autoneg)) {
return -EOPNOTSUPP;
--
2.17.1


2022-04-16 02:50:38

by Benjamin Poirier

[permalink] [raw]
Subject: Re: [PATCH v2] net: qlogic: qlcnic: simplify if-if to if-else

On 2022-04-15 05:09 -0700, Yihao Han wrote:
> Replace `if (!pause->autoneg)` with `else` for simplification
> according to the kernel coding style:
>
> "Do not unnecessarily use braces where a single statement will do."
>
> ...
>
> "This does not apply if only one branch of a conditional statement is
> a single statement; in the latter case use braces in both branches"
>
> Please refer to:
> https://www.kernel.org/doc/html/v5.17-rc8/process/coding-style.html

This commit log is even more confusing than v1. Only the first line is
correct.

>
> Suggested-by: Benjamin Poirier <[email protected]>

I did not suggest this change. Please remove the tag.

> Signed-off-by: Yihao Han <[email protected]>
> ---
> v2:edit commit message
> ---
> drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
> index bd0607680329..e3842eaf1532 100644
> --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
> +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
> @@ -3752,7 +3752,7 @@ int qlcnic_83xx_set_pauseparam(struct qlcnic_adapter *adapter,
> if (ahw->port_type == QLCNIC_GBE) {
> if (pause->autoneg)
> ahw->port_config |= QLC_83XX_ENABLE_AUTONEG;
> - if (!pause->autoneg)
> + else
> ahw->port_config &= ~QLC_83XX_ENABLE_AUTONEG;
> } else if ((ahw->port_type == QLCNIC_XGBE) && (pause->autoneg)) {
> return -EOPNOTSUPP;
> --
> 2.17.1
>