[pseudo][PATCH] client: Fix some compiler warnings

From: Philip Lorenz <hidden>
Date: 2021-05-17 19:25:00
Subsystem: the rest · Maintainer: Linus Torvalds

Fix some warnings reported by GCC 10.2.0:

* NULL pointer passed to '%s' format string parameter:

  pseudo_client.c: In function ‘pseudo_root_path’:
  pseudo_client.c:848:3: warning: ‘%s’ directive argument is null
  [-Wformat-overflow=]
    848 |   pseudo_diag("couldn't allocate absolute path for '%s'.\n",
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    849 |    path);

* Return of variable with local storage duration:

  pseudo_client.c: In function ‘pseudo_client_op’:
  cc1: warning: function may return address of local variable
  [-Wreturn-local-addr]
  pseudo_client.c:1592:15: note: declared here
   1592 |  pseudo_msg_t msg = { .type = PSEUDO_MSG_OP };

Signed-off-by: Philip Lorenz <redacted>
---
 pseudo_client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pseudo_client.c b/pseudo_client.c
index 579db33..6edd2ee 100644
--- a/pseudo_client.c
+++ b/pseudo_client.c
@@ -846,7 +846,7 @@ pseudo_root_path(const char *func, int line, int dirfd, const char *path, int le
 	pseudo_magic();
 	if (!rc) {
 		pseudo_diag("couldn't allocate absolute path for '%s'.\n",
-			path);
+			path ? path : "null");
 	}
 	pseudo_debug(PDBGF_CHROOT, "root_path [%s, %d]: '%s' from '%s'\n",
 		func, line,
@@ -1589,7 +1589,7 @@ int pseudo_client_ignore_path(const char *path) {
 pseudo_msg_t *
 pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path, const PSEUDO_STATBUF *buf, ...) {
 	pseudo_msg_t *result = 0;
-	pseudo_msg_t msg = { .type = PSEUDO_MSG_OP };
+	static pseudo_msg_t msg = { .type = PSEUDO_MSG_OP };
 	size_t pathlen = -1;
 	int do_request = 0;
 	char *path_extra_1 = 0;
-- 
2.31.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help