osmith has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/37328?usp=email )


Change subject: mslookup: don't ignore return value of write()
......................................................................

mslookup: don't ignore return value of write()

Fix GCC 13.2.0 refuses to build this with -Werror:

src/mslookup/osmo-mslookup-client.c: In function 'socket_client_respond_result':
src/osmo-hlr/src/mslookup/osmo-mslookup-client.c:432:9: error: ignoring return 
value of 'write' declared with attribute 'warn_unused_result' 
[-Werror=unused-result]
  432 |         write(c->ofd.fd, response, strlen(response));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/mslookup/osmo-mslookup-client.c: In function 'socket_accept':
src/osmo-hlr/src/mslookup/osmo-mslookup-client.c:530:17: error: ignoring return 
value of 'write' declared with attribute 'warn_unused_result' 
[-Werror=unused-result]
  530 |                 write(c->ofd.fd, CSV_HEADERS, strlen(CSV_HEADERS));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: I4b2e5cabe5306a999197f7c98362d872a3739078
---
M src/mslookup/osmo-mslookup-client.c
1 file changed, 32 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/28/37328/1

diff --git a/src/mslookup/osmo-mslookup-client.c 
b/src/mslookup/osmo-mslookup-client.c
index 37f1256..0a29645 100644
--- a/src/mslookup/osmo-mslookup-client.c
+++ b/src/mslookup/osmo-mslookup-client.c
@@ -429,7 +429,11 @@

 void socket_client_respond_result(struct socket_client *c, const char 
*response)
 {
-       write(c->ofd.fd, response, strlen(response));
+       size_t len = strlen(response);
+       int rc = write(c->ofd.fd, response, len);
+
+       if (rc != len)
+               print_error("%s: write() returned %d instead of %zu\n", 
__func__, rc, len);
 }

 static int socket_read_cb(struct osmo_fd *ofd)
@@ -526,8 +530,13 @@

        llist_add(&c->entry, &globals.socket_clients);

-       if (globals.format == FORMAT_CSV && cmdline_opts.csv_headers)
-               write(c->ofd.fd, CSV_HEADERS, strlen(CSV_HEADERS));
+       if (globals.format == FORMAT_CSV && cmdline_opts.csv_headers) {
+               size_t len = strlen(CSV_HEADERS);
+               int rc = write(c->ofd.fd, CSV_HEADERS, strlen(CSV_HEADERS));
+
+               if (rc != len)
+                       print_error("%s: write() returned %d instead of %zu\n", 
__func__, rc, len);
+       }

        return 0;
 }

--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/37328?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I4b2e5cabe5306a999197f7c98362d872a3739078
Gerrit-Change-Number: 37328
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osm...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to