Remove the goto statement from _rtw_init_recv_priv(). In this function goto
can be replace by return statement. As on goto label exit, function
only return it is not performing any cleanup. Avoiding goto will
improve the function readability.
Signed-off-by: Saurav Girepunje <[email protected]>
---
drivers/staging/r8188eu/core/rtw_recv.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
index 51a13262a226..b38af76f3a67 100644
--- a/drivers/staging/r8188eu/core/rtw_recv.c
+++ b/drivers/staging/r8188eu/core/rtw_recv.c
@@ -58,10 +58,8 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ);
- if (!precvpriv->pallocated_frame_buf) {
- res = _FAIL;
- goto exit;
- }
+ if (!precvpriv->pallocated_frame_buf)
+ return _FAIL;
precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ);
@@ -89,7 +87,6 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
precvpriv->signal_stat_sampling_interval = 1000; /* ms */
rtw_set_signal_stat_timer(precvpriv);
-exit:
return res;
}
--
2.33.0
On Wed, Nov 10, 2021 at 11:47:15PM +0530, Saurav Girepunje wrote:
> Remove the goto statement from _rtw_init_recv_priv(). In this function goto
> can be replace by return statement. As on goto label exit, function
> only return it is not performing any cleanup. Avoiding goto will
> improve the function readability.
>
> Signed-off-by: Saurav Girepunje <[email protected]>
> ---
> drivers/staging/r8188eu/core/rtw_recv.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
> index 51a13262a226..b38af76f3a67 100644
> --- a/drivers/staging/r8188eu/core/rtw_recv.c
> +++ b/drivers/staging/r8188eu/core/rtw_recv.c
> @@ -58,10 +58,8 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
>
> precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ);
>
> - if (!precvpriv->pallocated_frame_buf) {
> - res = _FAIL;
> - goto exit;
> - }
> + if (!precvpriv->pallocated_frame_buf)
> + return _FAIL;
I hate pointless "goto exit;" labels, but there isn't a rule against
them and I feel like this is not a good enough patch on its own. There
is so much other stuff wrong with this function. It probably *should*
have some error handling for example.
I don't think this patch really adds enough value. Take a look at the
function and almost every line can be improved...
regards,
dan carpenter
On 11/11/21 12:15 am, Dan Carpenter wrote:
> On Wed, Nov 10, 2021 at 11:47:15PM +0530, Saurav Girepunje wrote:
>> Remove the goto statement from _rtw_init_recv_priv(). In this function goto
>> can be replace by return statement. As on goto label exit, function
>> only return it is not performing any cleanup. Avoiding goto will
>> improve the function readability.
>>
>> Signed-off-by: Saurav Girepunje <[email protected]>
>> ---
>> drivers/staging/r8188eu/core/rtw_recv.c | 7 ++-----
>> 1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
>> index 51a13262a226..b38af76f3a67 100644
>> --- a/drivers/staging/r8188eu/core/rtw_recv.c
>> +++ b/drivers/staging/r8188eu/core/rtw_recv.c
>> @@ -58,10 +58,8 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
>>
>> precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ);
>>
>> - if (!precvpriv->pallocated_frame_buf) {
>> - res = _FAIL;
>> - goto exit;
>> - }
>> + if (!precvpriv->pallocated_frame_buf)
>> + return _FAIL;
>
>
> I hate pointless "goto exit;" labels, but there isn't a rule against
> them and I feel like this is not a good enough patch on its own. There
> is so much other stuff wrong with this function. It probably *should*
> have some error handling for example.
>
> I don't think this patch really adds enough value. Take a look at the
> function and almost every line can be improved...
>
> regards,
> dan carpenter
>
OK, I will send the other patch to improve this function,
Thanks Dan for review.
Regards,
Saurav