Skip to contentSkip to conversation

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

PATCH In review Hui Su 2 participants 2 messages Oct 26, 2020 – Oct 29, 2020

Subsystems (3)
lore
Share & tools
lore

Hui Su

author
#0 lore raw

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

list_is_singular() can tell whether a list has just one entry. So we use list_is_singular() here.

---
 net/atm/br2684.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/atm/br2684.c +1 -2
index 3e17a5ecaa94..398f7e086cf4 100644
@@ -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);
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 13 lines · 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.

---
 net/atm/br2684.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/atm/br2684.c +0 -0
index 3e17a5ecaa94..398f7e086cf4 100644

net/atm/br2684.c static int br2684_setfilt(struct atm_vcc *atmvcc, void __user * arg) · line 375

Quoted 6 lines
net/atm/br2684.c +1 -2
@@ -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

Quoted 3 lines
net/atm/br2684.c +0 -0
 			brvcc = NULL;
 		else
 			brvcc = list_entry_brvcc(brdev->brvccs.next);