diff mbox series

net/atm: use list_is_singular() in br2684_setfilt()

Message ID 20201026165700.GA8218@rlk
State Changes Requested
Delegated to: David Miller
Headers show
Series net/atm: use list_is_singular() in br2684_setfilt() | expand

Checks

Context Check Description
jkicinski/cover_letter success Link
jkicinski/fixes_present success Link
jkicinski/patch_count success Link
jkicinski/tree_selection success Guessed tree name to be net-next
jkicinski/subject_prefix warning Target tree name not specified in the subject
jkicinski/source_inline success Was 0 now: 0
jkicinski/verify_signedoff success Link
jkicinski/module_param success Was 0 now: 0
jkicinski/build_32bit fail Errors and warnings before: 4 this patch: 4
jkicinski/kdoc success Errors and warnings before: 0 this patch: 0
jkicinski/verify_fixes success Link
jkicinski/checkpatch fail Link
jkicinski/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
jkicinski/header_inline success Link
jkicinski/stable success Stable not CCed

Commit Message

Hui Su Oct. 26, 2020, 4:57 p.m. UTC
list_is_singular() can tell whether a list has just one entry.
So we use list_is_singular() here.

Signed-off-by: Hui Su <sh_def@163.com>
---
 net/atm/br2684.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Jakub Kicinski Oct. 28, 2020, 12:47 a.m. UTC | #1
On Tue, 27 Oct 2020 00:57:00 +0800 Hui Su wrote:
> list_is_singular() can tell whether a list has just one entry.
> So we use list_is_singular() here.
> 
> Signed-off-by: Hui Su <sh_def@163.com>
> ---
>  net/atm/br2684.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/atm/br2684.c b/net/atm/br2684.c
> index 3e17a5ecaa94..398f7e086cf4 100644
> --- a/net/atm/br2684.c
> +++ b/net/atm/br2684.c
> @@ -372,8 +372,7 @@ static int br2684_setfilt(struct atm_vcc *atmvcc, void __user * arg)
>  		struct br2684_dev *brdev;
>  		read_lock(&devs_lock);
>  		brdev = BRPRIV(br2684_find_dev(&fs.ifspec));
> -		if (brdev == NULL || list_empty(&brdev->brvccs) ||
> -		    brdev->brvccs.next != brdev->brvccs.prev)	/* >1 VCC */
> +		if (brdev == NULL || !list_is_singular(&brdev->brvccs))	/* >1 VCC */

You can drop the /* >1 VCC */ comment now, the code is clear enough

>  			brvcc = NULL;
>  		else
>  			brvcc = list_entry_brvcc(brdev->brvccs.next);
diff mbox series

Patch

diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 3e17a5ecaa94..398f7e086cf4 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -372,8 +372,7 @@  static int br2684_setfilt(struct atm_vcc *atmvcc, void __user * arg)
 		struct br2684_dev *brdev;
 		read_lock(&devs_lock);
 		brdev = BRPRIV(br2684_find_dev(&fs.ifspec));
-		if (brdev == NULL || list_empty(&brdev->brvccs) ||
-		    brdev->brvccs.next != brdev->brvccs.prev)	/* >1 VCC */
+		if (brdev == NULL || !list_is_singular(&brdev->brvccs))	/* >1 VCC */
 			brvcc = NULL;
 		else
 			brvcc = list_entry_brvcc(brdev->brvccs.next);