gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 10/10: daemon: muted compiler warning, refactored code f


From: gnunet
Subject: [libmicrohttpd] 10/10: daemon: muted compiler warning, refactored code for readability
Date: Tue, 31 May 2022 19:38:19 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 1b8c52f1d0ed637c2a027a5ad86ad497ede8c527
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Tue May 31 20:09:59 2022 +0300

    daemon: muted compiler warning, refactored code for readability
---
 src/microhttpd/daemon.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 3e7131c1..6ac948d9 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -4507,7 +4507,6 @@ MHD_select (struct MHD_Daemon *daemon,
 
   if (MHD_NO != err_state)
     millisec = 0;
-  tv = NULL;
   if (0 == millisec)
   {
     timeout.tv_usec = 0;
@@ -4516,32 +4515,40 @@ MHD_select (struct MHD_Daemon *daemon,
   }
   else
   {
-    uint64_t timeout64;
+    uint64_t mhd_tmo;
+    uint64_t select_tmo;
 
     if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
-         (MHD_NO != MHD_get_timeout64 (daemon, &timeout64)) )
+         (MHD_NO != MHD_get_timeout64 (daemon, &mhd_tmo)) )
     {
-      tv = &timeout; /* have timeout value */
       if ( (0 < millisec) &&
-           (timeout64 > (uint64_t) millisec) )
-        timeout64 = (uint64_t) millisec;
+           (mhd_tmo > (uint64_t) millisec) )
+        select_tmo = (uint64_t) millisec;
+      else
+        select_tmo = mhd_tmo;
+      tv = &timeout; /* have timeout value */
     }
     else if (0 < millisec)
     {
+      select_tmo = (uint64_t) millisec;
       tv = &timeout; /* have timeout value */
-      timeout64 = (uint64_t) millisec;
+    }
+    else
+    {
+      select_tmo = 0; /* Not actually used, silent compiler warning */
+      tv = NULL;
     }
 
     if (NULL != tv)
     { /* have timeout value */
 #if (SIZEOF_UINT64_T - 2) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC
-      if (timeout64 / 1000 > TIMEVAL_TV_SEC_MAX)
+      if (select_tmo / 1000 > TIMEVAL_TV_SEC_MAX)
         timeout.tv_sec = TIMEVAL_TV_SEC_MAX;
       else
 #endif /* (SIZEOF_UINT64_T - 2) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC */
-      timeout.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) (timeout64 / 1000);
+      timeout.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) (select_tmo / 1000);
 
-      timeout.tv_usec = ((uint16_t) (timeout64 % 1000)) * ((int32_t) 1000);
+      timeout.tv_usec = ((uint16_t) (select_tmo % 1000)) * ((int32_t) 1000);
     }
   }
   num_ready = MHD_SYS_select_ (maxsock + 1,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]