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 <[email protected]>
---
 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

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#151991): 
https://lists.openembedded.org/g/openembedded-core/message/151991
Mute This Topic: https://lists.openembedded.org/mt/82895289/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to