Skip to contentSkip to conversation

selftests: uevent filtering: fix return on error in uevent_listener

PATCH Superseded Javier Carrasco 2 participants 2 messages Sep 16, 2023 – Sep 18, 2023 Kselftest

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: uevent filtering: fix return on error in uevent_listener

Assign the error value to the real returned variable fret. The ret variable is used to check function return values and assigning values to it on error has no effect as it is an unused value.

---
 tools/testing/selftests/uevent/uevent_filtering.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/uevent/uevent_filtering.c +2 -2
index 5cebfb356345..e191b6d69f8c 100644
@@ -158,7 +158,7 @@ static int uevent_listener(unsigned long post_flags, bool expect_uevent,
 		r = recvmsg(sk_fd, &hdr, 0);
 		if (r <= 0) {
 			fprintf(stderr, "%s - Failed to receive uevent\n", strerror(errno));
-			ret = -1;
+			fret = -1;
 			break;
 		}
 
@@ -172,7 +172,7 @@ static int uevent_listener(unsigned long post_flags, bool expect_uevent,
 
 		if (!expect_uevent) {
 			fprintf(stderr, "Received unexpected uevent:\n");
-			ret = -1;
+			fret = -1;
 		}
 
 		if (TH_LOG_ENABLED) {

---
base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d
change-id: 20230916-topic-self_uevent_filtering-17b53262bc46

Best regards,

Signature · 1 line
Javier Carrasco <[email protected]>
maintainer
#1 lore raw
Quoted 24 lines · Javier Carrasco

Assign the error value to the real returned variable fret. The ret variable is used to check function return values and assigning values to it on error has no effect as it is an unused value.

---
  tools/testing/selftests/uevent/uevent_filtering.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/uevent/uevent_filtering.c +1 -1
index 5cebfb356345..e191b6d69f8c 100644
@@ -158,7 +158,7 @@ static int uevent_listener(unsigned long post_flags, bool expect_uevent,
  		r = recvmsg(sk_fd, &hdr, 0);
  		if (r <= 0) {
  			fprintf(stderr, "%s - Failed to receive uevent\n", strerror(errno));
-			ret = -1;
+			fret = -1;
  			break;
  		}
 

tools/testing/selftests/uevent/uevent_filtering.c static int uevent_listener(unsigned long post_flags, bool expect_uevent, · line 178

Quoted 8 lines
tools/testing/selftests/uevent/uevent_filtering.c +1 -1
@@ -172,7 +172,7 @@ static int uevent_listener(unsigned long post_flags, bool expect_uevent,
 
  		if (!expect_uevent) {
  			fprintf(stderr, "Received unexpected uevent:\n");
-			ret = -1;
+			fret = -1;
  		}
 
  		if (TH_LOG_ENABLED) {

Thank you for the find. Please simplify these leg and use just one variable for failures, ret or fret and not both to avoid future coding errors like this one you are fixing.

thanks,
-- Shuah