]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Replace the rest of the gettimeofday() calls with i_gettimeofday()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 24 Jan 2020 21:36:52 +0000 (23:36 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 6 Feb 2020 06:46:01 +0000 (06:46 +0000)
It can't practically fail, so don't keep error handling that is never
tested.

src/auth/db-ldap.c
src/auth/userdb-passwd.c
src/lib-master/test-event-stats.c

index 7db536261ee5422a1bbcbc4f70fe803872947d7f..84754e7506c6f71cde872ec06b3e722349f4c060 100644 (file)
@@ -1226,10 +1226,8 @@ int db_ldap_connect(struct ldap_connection *conn)
        if (conn->conn_state != LDAP_CONN_STATE_DISCONNECTED)
                return 0;
 
-       if (debug) {
-               if (gettimeofday(&start, NULL) < 0)
-                       i_zero(&start);
-       }
+       if (debug)
+               i_gettimeofday(&start);
        i_assert(conn->pending_count == 0);
 
        if (conn->delayed_connect) {
@@ -1262,10 +1260,9 @@ int db_ldap_connect(struct ldap_connection *conn)
                return -1;
 
        if (debug) {
-               if (gettimeofday(&end, NULL) == 0) {
-                       int msecs = timeval_diff_msecs(&end, &start);
-                       i_debug("LDAP initialization took %d msecs", msecs);
-               }
+               i_gettimeofday(&end);
+               int msecs = timeval_diff_msecs(&end, &start);
+               i_debug("LDAP initialization took %d msecs", msecs);
        }
 
        db_ldap_get_fd(conn);
index 708762b84a3a8414085f227ebae897ffd1511398..0ec7c49c80fbc3eacb2846b73254b71672f519dc 100644 (file)
@@ -40,8 +40,7 @@ passwd_check_warnings(struct auth_request *auth_request,
        struct timeval end_tv;
        unsigned int msecs, percentage;
 
-       if (gettimeofday(&end_tv, NULL) < 0)
-               return;
+       i_gettimeofday(&end_tv);
 
        msecs = timeval_diff_msecs(&end_tv, start_tv);
        if (msecs >= PASSWD_SLOW_WARN_MSECS) {
@@ -89,8 +88,7 @@ static void passwd_lookup(struct auth_request *auth_request,
 
        e_debug(authdb_event(auth_request), "lookup");
 
-       if (gettimeofday(&start_tv, NULL) < 0)
-               start_tv.tv_sec = 0;
+       i_gettimeofday(&start_tv);
        ret = i_getpwnam(auth_request->user, &pw);
        if (start_tv.tv_sec != 0)
                passwd_check_warnings(auth_request, module, &start_tv);
index b639187c3b2f6e404284651e549c4793d4de6469..b0b9837525e4c444fe59a0a1005c09cf2e089cf6 100644 (file)
@@ -195,16 +195,10 @@ static void stats_conn_input(struct connection *_conn)
 static void wait_for_signal(const char *signal_file)
 {
        struct timeval start, now;
-       if (gettimeofday(&start, NULL) < 0) {
-               kill_stats_child();
-               i_fatal("gettimeofday() failed %m");
-       }
+       i_gettimeofday(&start);
        while (access(signal_file, F_OK) < 0) {
                i_sleep_msecs(10);
-               if (gettimeofday(&now, NULL) < 0) {
-                       kill_stats_child();
-                       i_fatal("gettimeofday() failed %m");
-               }
+               i_gettimeofday(&now);
                if (timeval_diff_usecs(&now, &start) > 10000000) {
                        kill_stats_child();
                        i_fatal("wait_for_signal has timed out");