Skip to contentSkip to conversation

net: mptcp: clean up harmless false expressions

PATCH In review Jεan Sacren 3 participants 3 messages Dec 10, 2021 – Dec 14, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: mptcp: clean up harmless false expressions

From: Jean Sacren <[email protected]>

entry->addr.id is u8 with a range from 0 to 255 and MAX_ADDR_ID is 255. We should drop both false expressions of (entry->addr.id > MAX_ADDR_ID).

We should also remove the obsolete parentheses in the first if branch.

Use U8_MAX for MAX_ADDR_ID and add a comment to show the link to mptcp_addr_info.id as suggested by Mr. Matthieu Baerts.

---
v2:
(1) Use U8_MAX for MAX_ADDR_ID.
(2) Add a comment for link to mptcp_addr_info.id.
Thank you, Mr. Matthieu Baerts!

 net/mptcp/pm_netlink.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/mptcp/pm_netlink.c +4 -4
index 4ff8d55cbe82..35cc4c64c06c 100644
@@ -38,7 +38,8 @@ struct mptcp_pm_add_entry {
 	u8			retrans_times;
 };
 
-#define MAX_ADDR_ID		255
+/* max value of mptcp_addr_info.id */
+#define MAX_ADDR_ID		U8_MAX
 #define BITMAP_SZ DIV_ROUND_UP(MAX_ADDR_ID + 1, BITS_PER_LONG)
 
 struct pm_nl_pernet {
@@ -822,14 +823,13 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
 		entry->addr.id = find_next_zero_bit(pernet->id_bitmap,
 						    MAX_ADDR_ID + 1,
 						    pernet->next_id);
-		if ((!entry->addr.id || entry->addr.id > MAX_ADDR_ID) &&
-		    pernet->next_id != 1) {
+		if (!entry->addr.id && pernet->next_id != 1) {
 			pernet->next_id = 1;
 			goto find_next;
 		}
 	}
 
-	if (!entry->addr.id || entry->addr.id > MAX_ADDR_ID)
+	if (!entry->addr.id)
 		goto out;
 
 	__set_bit(entry->addr.id, pernet->id_bitmap);
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Jεan Sacren

From: Jean Sacren <[email protected]>

entry->addr.id is u8 with a range from 0 to 255 and MAX_ADDR_ID is 255. We should drop both false expressions of (entry->addr.id > MAX_ADDR_ID).

We should also remove the obsolete parentheses in the first if branch.

Use U8_MAX for MAX_ADDR_ID and add a comment to show the link to mptcp_addr_info.id as suggested by Mr. Matthieu Baerts.

Quoted 8 lines

---
v2:
(1) Use U8_MAX for MAX_ADDR_ID.
(2) Add a comment for link to mptcp_addr_info.id.
Thank you, Mr. Matthieu Baerts!
net/mptcp/pm_netlink.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)

Looks good to me:

Quoted 23 lines
net/mptcp/pm_netlink.c +3 -3
index 4ff8d55cbe82..35cc4c64c06c 100644
@@ -38,7 +38,8 @@ struct mptcp_pm_add_entry {
 	u8			retrans_times;
 };
 
-#define MAX_ADDR_ID		255
+/* max value of mptcp_addr_info.id */
+#define MAX_ADDR_ID		U8_MAX
 #define BITMAP_SZ DIV_ROUND_UP(MAX_ADDR_ID + 1, BITS_PER_LONG)
 
 struct pm_nl_pernet {
@@ -822,14 +823,13 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
 		entry->addr.id = find_next_zero_bit(pernet->id_bitmap,
 						    MAX_ADDR_ID + 1,
 						    pernet->next_id);
-		if ((!entry->addr.id || entry->addr.id > MAX_ADDR_ID) &&
-		    pernet->next_id != 1) {
+		if (!entry->addr.id && pernet->next_id != 1) {

net/mptcp/pm_netlink.c static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet, · line 835

Quoted 10 lines
net/mptcp/pm_netlink.c +1 -1
 			pernet->next_id = 1;
 			goto find_next;
 		}
 	}
 
-	if (!entry->addr.id || entry->addr.id > MAX_ADDR_ID)
+	if (!entry->addr.id)
 		goto out;
 
 	__set_bit(entry->addr.id, pernet->id_bitmap);

--
Mat Martineau
Intel

#2 lore raw
In reply to Jεan Sacren

Hi Jean,

Quoted 4 lines · Jεan Sacren

From: Jean Sacren <[email protected]>

entry->addr.id is u8 with a range from 0 to 255 and MAX_ADDR_ID is 255. We should drop both false expressions of (entry->addr.id > MAX_ADDR_ID).

Thank you for the new version!

Now in our tree with Mat and my RvB tag:

- 51708fedab61: net: mptcp: clean up harmless false expressions

- d41488e31d8a: tg:msg: remove 'net:' as it is an 'mptcp' patch
- Results: f4539ed375ce..3fa476cdb0a9

This patch will be sent later to netdev for inclusion in net-next with other patches.

Builds and tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20211214T160950

https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net