From: Timo Sirainen Date: Fri, 24 Jan 2020 21:36:52 +0000 (+0200) Subject: global: Replace the rest of the gettimeofday() calls with i_gettimeofday() X-Git-Tag: 2.3.10~97 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5a34ae86512823052a36ad642d183b35cfadafaa;p=thirdparty%2Fdovecot%2Fcore.git global: Replace the rest of the gettimeofday() calls with i_gettimeofday() It can't practically fail, so don't keep error handling that is never tested. --- diff --git a/src/auth/db-ldap.c b/src/auth/db-ldap.c index 7db536261e..84754e7506 100644 --- a/src/auth/db-ldap.c +++ b/src/auth/db-ldap.c @@ -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); diff --git a/src/auth/userdb-passwd.c b/src/auth/userdb-passwd.c index 708762b84a..0ec7c49c80 100644 --- a/src/auth/userdb-passwd.c +++ b/src/auth/userdb-passwd.c @@ -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); diff --git a/src/lib-master/test-event-stats.c b/src/lib-master/test-event-stats.c index b639187c3b..b0b9837525 100644 --- a/src/lib-master/test-event-stats.c +++ b/src/lib-master/test-event-stats.c @@ -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");