Skip to contentSkip to conversation

android/ion: fix error return code in opensocket()

PATCH In review Wang Hai 2 participants 2 messages Nov 18, 2020 Kselftest

lore
Share & tools
lore

Wang Hai

author
#0 lore raw

PATCH v2 1/1 android/ion: fix error return code in opensocket()

Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.

Fixes 47a18c42d992 ("android/ion: userspace test utility for ion buffer sharing")

---
v1->v2: add missing ";"

 tools/testing/selftests/android/ion/ipcsocket.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/android/ion/ipcsocket.c +3 -2
index 7dc521002095..13b3455ba39c 100644
@@ -28,8 +28,9 @@ int opensocket(int *sockfd, const char *name, int connecttype)
 	}
 
 	*sockfd = ret;
-	if (setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR,
-		(char *)&temp, sizeof(int)) < 0) {
+	ret = setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&temp,
+			 sizeof(int));
+	if (ret < 0) {
 		fprintf(stderr, "<%s>: Failed setsockopt: <%s>\n",
 		__func__, strerror(errno));
 		goto err;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 18 lines · Wang Hai

Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.

Fixes 47a18c42d992 ("android/ion: userspace test utility for ion buffer sharing")

---
v1->v2: add missing ";"

  tools/testing/selftests/android/ion/ipcsocket.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/android/ion/ipcsocket.c +0 -0
index 7dc521002095..13b3455ba39c 100644
@@ -28,8 +28,9 @@ int opensocket(int *sockfd, const char *name, int connecttype)
  	}

tools/testing/selftests/android/ion/ipcsocket.c int opensocket(int *sockfd, const char *name, int connecttype) · line 36

Quoted 10 lines
tools/testing/selftests/android/ion/ipcsocket.c +3 -2
 
  	*sockfd = ret;
-	if (setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR,
-		(char *)&temp, sizeof(int)) < 0) {
+	ret = setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&temp,
+			 sizeof(int));
+	if (ret < 0) {
  		fprintf(stderr, "<%s>: Failed setsockopt: <%s>\n",
  		__func__, strerror(errno));
  		goto err;

This test is slated removal and I have stopped accepting patches that aren't critical fixes at this time.

thanks,
-- Shuah