[Git][NTPsec/ntpsec][master] NTS: fix unused-result warnings on Ubuntu

Hal Murray gitlab at mg.gitlab.com
Mon Apr 8 06:45:49 UTC 2019



Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
9a452854 by Hal Murray at 2019-04-07T11:08:08Z
NTS: fix unused-result warnings on Ubuntu

- - - - -


4 changed files:

- ntpd/nts.c
- ntpd/nts_client.c
- ntpd/nts_cookie.c
- ntpd/nts_server.c


Changes:

=====================================
ntpd/nts.c
=====================================
@@ -18,6 +18,7 @@
 #include <openssl/err.h>
 
 #include "ntp_types.h"
+#include "ntp_stdlib.h"
 #include "ntpd.h"
 #include "nts.h"
 #include "nts2.h"
@@ -210,7 +211,7 @@ int nts_ssl_read(SSL *ssl, uint8_t *buff, int buff_length) {
     char errbuf[100];
     bytes_read = SSL_read(ssl, buff, buff_length);
     if (0 >= bytes_read) {
-        strerror_r(errno, errbuf, sizeof(errbuf));
+        IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
         msyslog(LOG_INFO, "NTS: SSL_read error: %s", errbuf);
         nts_log_ssl_error();
         return -1;
@@ -223,7 +224,7 @@ int nts_ssl_write(SSL *ssl, uint8_t *buff, int buff_length) {
     char errbuf[100];
     bytes_written = SSL_write(ssl, buff, buff_length);
     if (0 >= bytes_written) {
-        strerror_r(errno, errbuf, sizeof(errbuf));
+        IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
         msyslog(LOG_INFO, "NTS: SSL_write error: %s", errbuf);
         nts_log_ssl_error();
         return -1;


=====================================
ntpd/nts_client.c
=====================================
@@ -99,7 +99,7 @@ bool nts_probe(struct peer * peer) {
 
   err = setsockopt(server, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
   if (0 > err) {
-    strerror_r(errno, errbuf, sizeof(errbuf));
+    IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
     msyslog(LOG_ERR, "NTSc: can't setsockopt: %s", errbuf);
     close(server);
     nts_ke_probes_bad++;
@@ -290,13 +290,13 @@ int open_TCP_socket(struct peer *peer, const char *hostname) {
 
   sockfd = socket(answer->ai_family, SOCK_STREAM, 0);
   if (-1 == sockfd) {
-    strerror_r(errno, errbuf, sizeof(errbuf));
+    IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
     msyslog(LOG_INFO, "NTSc: nts_probe: no socket: %s", errbuf);
   } else {
     // Use first answer
     err = connect(sockfd, answer->ai_addr, answer->ai_addrlen);
     if (-1 == err) {
-      strerror_r(errno, errbuf, sizeof(errbuf));
+      IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
       msyslog(LOG_INFO, "NTSc: nts_probe: connect failed: %s", errbuf);
       close(sockfd);
       sockfd = -1;
@@ -433,7 +433,7 @@ bool nts_client_send_request(SSL *ssl, struct peer* peer) {
 
   used = sizeof(buff)-buf.left;
   if (used >= (int)(sizeof(buff)-10)) {
-    strerror_r(errno, errbuf, sizeof(errbuf));
+    IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
     msyslog(LOG_ERR, "NTSc: write failed: %d, %ld, %s",
         used, (long)sizeof(buff), errbuf);
     return false;
@@ -608,7 +608,7 @@ bool nts_set_cert_search(SSL_CTX *ctx, const char *filename) {
         filename, statbuf.st_mode);
     return false;
   }
-  strerror_r(errno, errbuf, sizeof(errbuf));
+  IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
   msyslog(LOG_ERR, "NTSc: can't stat cert dir/file: %s, %s",
       ntsconfig.ca, errbuf);
   return false;


=====================================
ntpd/nts_cookie.c
=====================================
@@ -205,13 +205,13 @@ bool nts_write_cookie_keys(void) {
     cookie_filename = ntsconfig.KI;
   fd = open(cookie_filename, O_CREAT|O_WRONLY, S_IRUSR|S_IWUSR);
   if (-1 == fd) {
-    strerror_r(errno, errbuf, sizeof(errbuf));
+    IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
     msyslog(LOG_ERR, "ERR: can't open %s: %s", cookie_filename, errbuf);
     return false;
   }
   out = fdopen(fd, "w");
   if (NULL == out) {
-    strerror_r(errno, errbuf, sizeof(errbuf));
+    IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
     msyslog(LOG_ERR, "ERR: can't fdopen %s: %s", cookie_filename, errbuf);
     close(fd);
     return false;


=====================================
ntpd/nts_server.c
=====================================
@@ -96,12 +96,12 @@ bool nts_server_init2(void) {
     pthread_sigmask(SIG_BLOCK, &block_mask, &saved_sig_mask);
     rc = pthread_create(&worker, NULL, nts_ke_listener, &listner4_sock);
     if (rc) {
-      strerror_r(errno, errbuf, sizeof(errbuf));
+      IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
       msyslog(LOG_ERR, "NTSs: nts_start_server4: error from pthread_create: %s", errbuf);
     }
     rc = pthread_create(&worker, NULL, nts_ke_listener, &listner6_sock);
     if (rc) {
-      strerror_r(errno, errbuf, sizeof(errbuf));
+      IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
       msyslog(LOG_ERR, "NTSs: nts_start_server6: error from pthread_create: %s", errbuf);
     }
     pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL);
@@ -123,7 +123,7 @@ void* nts_ke_listener(void* arg) {
 
         client = accept(sock, &addr.sa, &len);
         if (client < 0) {
-            strerror_r(errno, errbuf, sizeof(errbuf));
+            IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
             msyslog(LOG_ERR, "NTSs: TCP accept failed: %s", errbuf);
             if (EBADF == errno)
                 return NULL;
@@ -137,7 +137,7 @@ void* nts_ke_listener(void* arg) {
         msyslog(LOG_INFO, "NTSs: TCP accept-ed from %s", errbuf);
         err = setsockopt(client, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
         if (0 > err) {
-            strerror_r(errno, errbuf, sizeof(errbuf));
+            IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
             msyslog(LOG_ERR, "NTSs: can't setsockopt: %s", errbuf);
             close(client);
             nts_ke_serves_bad++;
@@ -242,26 +242,26 @@ int create_listener(int port, int family) {
         addr.sa4.sin_addr.s_addr= htonl(INADDR_ANY);
         sock = socket(AF_INET, SOCK_STREAM, 0);
         if (sock < 0) {
-          strerror_r(errno, errbuf, sizeof(errbuf));
+          IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
           msyslog(LOG_ERR, "NTSs: Can't create socket4: %s", errbuf);
           return -1;
         }
 	err = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
         if (0 > err) {
-          strerror_r(errno, errbuf, sizeof(errbuf));
+          IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
           msyslog(LOG_ERR, "NTSs: can't setsockopt4: %s", errbuf);
 	  close(sock);
           return -1;
         }
         err = bind(sock, &addr.sa, sizeof(addr.sa4));
         if (0 > err) {
-          strerror_r(errno, errbuf, sizeof(errbuf));
+          IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
           msyslog(LOG_ERR, "NTSs: can't bind4: %s", errbuf);
 	  close(sock);
           return -1;
         }
         if (listen(sock, 6) < 0) {
-          strerror_r(errno, errbuf, sizeof(errbuf));
+          IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
           msyslog(LOG_ERR, "NTSs: can't listen4: %s", errbuf);
 	  close(sock);
           return -1;
@@ -274,34 +274,34 @@ int create_listener(int port, int family) {
         addr.sa6.sin6_addr = in6addr_any;
         sock = socket(AF_INET6, SOCK_STREAM, 0);
         if (sock < 0) {
-          strerror_r(errno, errbuf, sizeof(errbuf));
+          IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
           msyslog(LOG_ERR, "NTSs: Can't create socket6: %s", errbuf);
           return -1;
         }
         /* Hack to keep IPV6 from listening on IPV4 too */
         err = setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
         if (0 > err) {
-          strerror_r(errno, errbuf, sizeof(errbuf));
+          IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
           msyslog(LOG_ERR, "NTSs: can't setsockopt6only: %s", errbuf);
 	  close(sock);
           return -1;
         }
 	err = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
         if (0 > err) {
-          strerror_r(errno, errbuf, sizeof(errbuf));
+          IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
           msyslog(LOG_ERR, "NTSs: can't setsockopt6: %s", errbuf);
 	  close(sock);
           return -1;
         }
         err = bind(sock, &addr.sa, sizeof(addr.sa6));
         if (0 > err) {
-          strerror_r(errno, errbuf, sizeof(errbuf));
+          IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
           msyslog(LOG_ERR, "NTSs: can't bind6: %s", errbuf);
 	  close(sock);
           return -1;
         }
         if (listen(sock, 6) < 0) {
-          strerror_r(errno, errbuf, sizeof(errbuf));
+          IGNORE(strerror_r(errno, errbuf, sizeof(errbuf)));
           msyslog(LOG_ERR, "NTSs: can't listen6: %s", errbuf);
           close(sock);
           return -1;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/9a4528545b3e0154958b7ed3450e2af1c76b0d8e

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/9a4528545b3e0154958b7ed3450e2af1c76b0d8e
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20190408/d1a7a336/attachment-0001.html>


More information about the vc mailing list