diff mbox series

[net] net: hns3: clean up a return in hclge_tm_bp_setup()

Message ID 20201023112212.GA282278@mwanda
State Accepted
Delegated to: David Miller
Headers show
Series [net] net: hns3: clean up a return in hclge_tm_bp_setup() | expand

Checks

Context Check Description
jkicinski/cover_letter success Link
jkicinski/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
jkicinski/patch_count success Link
jkicinski/tree_selection success Clearly marked for net
jkicinski/subject_prefix success Link
jkicinski/source_inline success Was 0 now: 0
jkicinski/verify_signedoff success Link
jkicinski/module_param success Was 0 now: 0
jkicinski/build_32bit success Errors and warnings before: 44 this patch: 44
jkicinski/kdoc success Errors and warnings before: 0 this patch: 0
jkicinski/verify_fixes success Link
jkicinski/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
jkicinski/build_allmodconfig_warn success Errors and warnings before: 48 this patch: 48
jkicinski/header_inline success Link
jkicinski/stable success Stable not CCed

Commit Message

Dan Carpenter Oct. 23, 2020, 11:22 a.m. UTC
Smatch complains that "ret" might be uninitialized if we don't enter
the loop.  We do always enter the loop so it's a false positive, but
it's cleaner to just return a literal zero and that silences the
warning as well.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Yunsheng Lin Oct. 26, 2020, 3:18 a.m. UTC | #1
On 2020/10/23 19:22, Dan Carpenter wrote:
> Smatch complains that "ret" might be uninitialized if we don't enter
> the loop.  We do always enter the loop so it's a false positive, but
> it's cleaner to just return a literal zero and that silences the
> warning as well.

Thanks for the clean up. Minor comment below:
Perhap it makes sense to limit ret scope within the for loop after
returning zero.

> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
> index 15f69fa86323..e8495f58a1a8 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
> @@ -1373,7 +1373,7 @@ static int hclge_tm_bp_setup(struct hclge_dev *hdev)
>  			return ret;
>  	}
>  
> -	return ret;
> +	return 0;
>  }
>  
>  int hclge_pause_setup_hw(struct hclge_dev *hdev, bool init)
>
Dan Carpenter Oct. 26, 2020, 6:52 a.m. UTC | #2
On Mon, Oct 26, 2020 at 11:18:16AM +0800, Yunsheng Lin wrote:
> On 2020/10/23 19:22, Dan Carpenter wrote:
> > Smatch complains that "ret" might be uninitialized if we don't enter
> > the loop.  We do always enter the loop so it's a false positive, but
> > it's cleaner to just return a literal zero and that silences the
> > warning as well.
> 
> Thanks for the clean up. Minor comment below:
> Perhap it makes sense to limit ret scope within the for loop after
> returning zero.
> 

It's not really normal to limit ret scope...  I think it's better to
leave it as-is.

regards,
dan carpenter
Jakub Kicinski Oct. 26, 2020, 11:17 p.m. UTC | #3
On Fri, 23 Oct 2020 14:22:12 +0300 Dan Carpenter wrote:
> Smatch complains that "ret" might be uninitialized if we don't enter
> the loop.  We do always enter the loop so it's a false positive, but
> it's cleaner to just return a literal zero and that silences the
> warning as well.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
index 15f69fa86323..e8495f58a1a8 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
@@ -1373,7 +1373,7 @@  static int hclge_tm_bp_setup(struct hclge_dev *hdev)
 			return ret;
 	}
 
-	return ret;
+	return 0;
 }
 
 int hclge_pause_setup_hw(struct hclge_dev *hdev, bool init)