Skip to contentSkip to conversation

Fix build and add /test/output dir to .gitignore

PATCH Applied Ammar Faizi 2 participants 5 messages Sep 15, 2021 io_uring

lore
Share & tools
lore
#0 lore raw

cover Fix build and add /test/output dir to .gitignore

- Louvian reported build error (2 fixes from me).
- Add /test/output dir to .gitignore from me.

Ammar Faizi (3):
test/io_uring_setup: Don't use __errno as local variable name test/send_recv: Use proper cast for (struct sockaddr *) argument .gitignore: add /test/output/

 .gitignore            |  1 +
 test/io_uring_setup.c | 10 +++++-----
 test/send_recv.c      |  2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)
#1 lore raw

PATCH 1/3 test/io_uring_setup: Don't use `__errno` as local variable name

This commit fixes build for armv8l.

On some systems, the macro errno is defined as
#define errno (*__errno())

It is clear that __errno is a global function on such systems.

The problem is, io_uring_setup.c uses int __errno as a local variable, so it shadows the __errno function, result in the following error:

```
       CC io_uring_setup
  io_uring_setup.c:116:12: error: called object type 'int' is not a function or function pointer
          __errno = errno;
                    ^~~~~
  /usr/include/errno.h:58:24: note: expanded from macro 'errno'
  #define errno (*__errno())
                  ~~~~~~~^
  1 error generated.
  make[1]: *** [Makefile:163: io_uring_setup] Error 1
  make[1]: *** Waiting for unfinished jobs....
```

Fix this by not using __errno as local variable name.

---
 test/io_uring_setup.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
test/io_uring_setup.c +5 -5
index a0709a7..94b54fd 100644
@@ -99,7 +99,7 @@ dump_resv(struct io_uring_params *p)
 int
 try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect, int error)
 {
-	int ret, __errno;
+	int ret, err;
 
 	printf("io_uring_setup(%u, %p), flags: %s, feat: %s, resv: %s, sq_thread_cpu: %u\n",
 	       entries, p, flags_string(p), features_string(p), dump_resv(p),
@@ -113,13 +113,13 @@ try_io_uring_setup(unsigned entries, struct io_uring_params *p, int expect, int
 			close(ret);
 		return 1;
 	}
-	__errno = errno;
-	if (expect == -1 && error != __errno) {
-		if (__errno == EPERM && geteuid() != 0) {
+	err = errno;
+	if (expect == -1 && error != err) {
+		if (err == EPERM && geteuid() != 0) {
 			printf("Needs root, not flagging as an error\n");
 			return 0;
 		}
-		printf("expected errno %d, got %d\n", error, __errno);
+		printf("expected errno %d, got %d\n", error, err);
 		return 1;
 	}
 
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/3 test/send_recv: Use proper cast for (struct sockaddr *) argument

This commit fixes build for armv8l.

Sometimes the compiler accepts (struct sockaddr_in *) to be passed to (struct sockaddr *) without cast. But not all compilers agree with that.

Louvian found the following warning on armv8l:

```
  send_recv.c:203:24: warning: incompatible pointer types passing 'struct sockaddr_in *' to parameter of type 'const struct sockaddr *' [-Wincompatible-pointer-types]
          ret = connect(sockfd, &saddr, sizeof(saddr));
                                ^~~~~~
  /usr/include/sys/socket.h:308:59: note: passing argument to parameter '__addr' here
  __socketcall int connect(int __fd, const struct sockaddr* __addr, socklen_t __addr_length);
                                                            ^
  1 warning generated.
```

Fix this by casting the second argument to (struct sockaddr *).

---
 test/send_recv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/send_recv.c +1 -1
index 38ae27f..1ee0234 100644
@@ -200,7 +200,7 @@ static int do_send(void)
 		return 1;
 	}
 
-	ret = connect(sockfd, &saddr, sizeof(saddr));
+	ret = connect(sockfd, (struct sockaddr *)&saddr, sizeof(saddr));
 	if (ret < 0) {
 		perror("connect");
 		return 1;
Signature · 1 line
2.30.2
#3 lore raw

PATCH 3/3 .gitignore: add `/test/output/`

In reply to Ammar Faizi
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)
.gitignore +1 -0
index 0213bfa..45f3cde 100644
@@ -131,6 +131,7 @@
 /test/submit-link-fail
 /test/exec-target
 /test/*.dmesg
+/test/output/
 
 config-host.h
 config-host.mak
Signature · 1 line
2.30.2
maintainer Applied
#4 lore raw
In reply to Ammar Faizi
Quoted 8 lines · Ammar Faizi

- Louvian reported build error (2 fixes from me).
- Add /test/output dir to .gitignore from me.

Ammar Faizi (3):
test/io_uring_setup: Don't use __errno as local variable name test/send_recv: Use proper cast for (struct sockaddr *) argument .gitignore: add /test/output/

Quoted 4 lines
 .gitignore            |  1 +
 test/io_uring_setup.c | 10 +++++-----
 test/send_recv.c      |  2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

Applied, thanks.

Signature · 1 line
Jens Axboe