]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Maintenance: use void return for commSetTimeout functions (#1956)
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Mon, 2 Dec 2024 22:47:57 +0000 (22:47 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Mon, 2 Dec 2024 23:55:05 +0000 (23:55 +0000)
On some systems (e.g. Linux), time_t is a signed 64-bit integer. int may
be a signed 32-bit integer, resulting in possible truncation errors.

Detected by Coverity. CID 1547031: Use of 32-bit time_t (Y2K38_SAFETY).

src/comm.cc
src/comm.h
src/tests/stub_comm.cc

index c5f4751bc78103023c9471f9afb3fd529133bbad..6ff2a7d8c871a31e0f0e1fd211c717826c0de07c 100644 (file)
@@ -588,7 +588,7 @@ commUnsetFdTimeout(int fd)
     F->timeout = 0;
 }
 
-int
+void
 commSetConnTimeout(const Comm::ConnectionPointer &conn, time_t timeout, AsyncCall::Pointer &callback)
 {
     debugs(5, 3, conn << " timeout " << timeout);
@@ -608,18 +608,16 @@ commSetConnTimeout(const Comm::ConnectionPointer &conn, time_t timeout, AsyncCal
             F->timeoutHandler = callback;
         }
 
-        F->timeout = squid_curtime + (time_t) timeout;
+        F->timeout = squid_curtime + timeout;
     }
-
-    return F->timeout;
 }
 
-int
+void
 commUnsetConnTimeout(const Comm::ConnectionPointer &conn)
 {
     debugs(5, 3, "Remove timeout for " << conn);
     AsyncCall::Pointer nil;
-    return commSetConnTimeout(conn, -1, nil);
+    commSetConnTimeout(conn, -1, nil);
 }
 
 /**
index dccf01c80d5867866f543fa6f6d32db536b288c8..1f507e22c653a4f88c5e6f5821c3a9e9286cca8c 100644 (file)
@@ -75,8 +75,8 @@ void commUnsetFdTimeout(int fd);
  * Set or clear the timeout for some action on an active connection.
  * API to replace commSetTimeout() when a Comm::ConnectionPointer is available.
  */
-int commSetConnTimeout(const Comm::ConnectionPointer &conn, time_t seconds, AsyncCall::Pointer &callback);
-int commUnsetConnTimeout(const Comm::ConnectionPointer &conn);
+void commSetConnTimeout(const Comm::ConnectionPointer &, time_t seconds, AsyncCall::Pointer &);
+void commUnsetConnTimeout(const Comm::ConnectionPointer &);
 
 int ignoreErrno(int);
 void commCloseAllSockets(void);
index f1d59cf71db7f400804e5ce66ef705ce94f33b65..7fba46ec6390fb730e1db232dd29adf94758d213 100644 (file)
@@ -48,8 +48,8 @@ int comm_udp_sendto(int, const Ip::Address &, const void *, int) STUB_RETVAL(-1)
 void commCallCloseHandlers(int) STUB
 void commUnsetFdTimeout(int) STUB
 // int commSetTimeout(const Comm::ConnectionPointer &, int, AsyncCall::Pointer&) STUB_RETVAL(-1)
-int commSetConnTimeout(const Comm::ConnectionPointer &, time_t, AsyncCall::Pointer &) STUB_RETVAL(-1)
-int commUnsetConnTimeout(const Comm::ConnectionPointer &) STUB_RETVAL(-1)
+void commSetConnTimeout(const Comm::ConnectionPointer &, time_t, AsyncCall::Pointer &) STUB
+void commUnsetConnTimeout(const Comm::ConnectionPointer &) STUB
 int ignoreErrno(int) STUB_RETVAL(-1)
 void commCloseAllSockets(void) STUB
 void checkTimeouts(void) STUB