]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Remove timeval_set()
authorVolker Lendecke <vl@samba.org>
Wed, 13 Mar 2024 15:19:48 +0000 (16:19 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Mar 2024 06:07:42 +0000 (06:07 +0000)
We have the same function in tevent, no need to duplicate code. More lines just
due to clang-format.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Mar 22 06:07:42 UTC 2024 on atb-devel-224

13 files changed:
lib/util/time.c
lib/util/time.h
source3/lib/dbwrap/dbwrap_ctdb.c
source3/printing/queue_process.c
source3/smbd/open.c
source3/smbd/smb2_process.c
source3/smbd/smb2_setinfo.c
source3/torture/msg_sink.c
source3/torture/msg_source.c
source3/utils/net_g_lock.c
source3/utils/net_registry.c
source3/winbindd/winbindd_cred_cache.c
source3/winbindd/winbindd_dual.c

index fe2a2b499f5e7b8dc57ba436fbcbc1dd11c96d34..d2bf2454e317ea67044d578a2851db73d96b6b3b 100644 (file)
@@ -617,18 +617,6 @@ _PUBLIC_ struct timeval timeval_current(void)
        return tv;
 }
 
-/**
-  return a timeval struct with the given elements
-*/
-_PUBLIC_ struct timeval timeval_set(uint32_t secs, uint32_t usecs)
-{
-       struct timeval tv;
-       tv.tv_sec = secs;
-       tv.tv_usec = usecs;
-       return tv;
-}
-
-
 /**
   return a timeval ofs microseconds after tv
 */
index cc4fd98771c6e3e6fd413c045a53cbadadd088e6..1180dd0cfc4bf376b69cab301e44b971ae614dd5 100644 (file)
@@ -240,11 +240,6 @@ bool timeval_is_zero(const struct timeval *tv);
 */
 struct timeval timeval_current(void);
 
-/**
-  return a timeval struct with the given elements
-*/
-struct timeval timeval_set(uint32_t secs, uint32_t usecs);
-
 /**
   return a timeval ofs microseconds after tv
 */
index 46165e8fbfb08ce7db56a1ab23cfbda355aa238f..807b7f5224860d40028efe1db4a9cce46ea20780 100644 (file)
@@ -381,8 +381,12 @@ static int db_ctdb_transaction_start(struct db_context *db)
        /*
         * Wait a day, i.e. forever...
         */
-       status = g_lock_lock(ctx->lock_ctx, string_term_tdb_data(h->lock_name),
-                            G_LOCK_WRITE, timeval_set(86400, 0), NULL, NULL);
+       status = g_lock_lock(ctx->lock_ctx,
+                            string_term_tdb_data(h->lock_name),
+                            G_LOCK_WRITE,
+                            tevent_timeval_set(86400, 0),
+                            NULL,
+                            NULL);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("g_lock_lock failed: %s\n", nt_errstr(status)));
                TALLOC_FREE(h);
index 6613e8f9f55f192ec51c626e9e2664ea4a1480e4..d1e95bb083ad5373442d8787dd66964c6b63c8f4 100644 (file)
@@ -186,10 +186,13 @@ static bool printing_subsystem_queue_tasks(struct bq_state *state)
                return true;
        }
 
-       state->housekeep = event_add_idle(state->ev, NULL,
-                                         timeval_set(housekeeping_period, 0),
-                                         "print_queue_housekeeping",
-                                         print_queue_housekeeping, state);
+       state->housekeep = event_add_idle(
+               state->ev,
+               NULL,
+               tevent_timeval_set(housekeeping_period, 0),
+               "print_queue_housekeeping",
+               print_queue_housekeeping,
+               state);
        if (state->housekeep == NULL) {
                DEBUG(0,("Could not add print_queue_housekeeping event\n"));
                return false;
index bd397376d2632d862bc573aaea6963f74ef7c29d..ae47d130650270441b1a03e861bfaa39a28482c9 100644 (file)
@@ -3206,7 +3206,7 @@ static void schedule_defer_open(struct share_mode_lock *lck,
         * measure here in case the other smbd is stuck
         * somewhere else. */
 
-       timeout = timeval_set(OPLOCK_BREAK_TIMEOUT*2, 0);
+       timeout = tevent_timeval_set(OPLOCK_BREAK_TIMEOUT * 2, 0);
 
        if (request_timed_out(req, timeout)) {
                return;
@@ -3230,7 +3230,7 @@ static void schedule_async_open_timer(struct tevent_context *ev,
 static void schedule_async_open(struct smb_request *req)
 {
        struct deferred_open_record *open_rec = NULL;
-       struct timeval timeout = timeval_set(20, 0);
+       struct timeval timeout = tevent_timeval_set(20, 0);
        bool ok;
 
        if (request_timed_out(req, timeout)) {
@@ -4184,11 +4184,11 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                 * the oplock got removed.
                 */
 
-               setup_poll_open(
-                       req,
-                       &fsp->file_id,
-                       timeval_set(OPLOCK_BREAK_TIMEOUT*2, 0),
-                       timeval_set(1, 0));
+               setup_poll_open(req,
+                               &fsp->file_id,
+                               tevent_timeval_set(OPLOCK_BREAK_TIMEOUT * 2,
+                                                  0),
+                               tevent_timeval_set(1, 0));
 
                return NT_STATUS_SHARING_VIOLATION;
        }
index 2783ac238229002ce1fcbd011bdf7a777272e8c2..482c448e81b386e386cb55dd77a181a5df88db20 100644 (file)
@@ -2020,26 +2020,37 @@ void smbd_process(struct tevent_context *ev_ctx,
                           MSG_DEBUG, debug_message);
 
 #if defined(WITH_SMB1SERVER)
-       if ((lp_keepalive() != 0)
-           && !(event_add_idle(ev_ctx, NULL,
-                               timeval_set(lp_keepalive(), 0),
-                               "keepalive", keepalive_fn,
-                               sconn))) {
+       if ((lp_keepalive() != 0) &&
+           !(event_add_idle(ev_ctx,
+                            NULL,
+                            tevent_timeval_set(lp_keepalive(), 0),
+                            "keepalive",
+                            keepalive_fn,
+                            sconn)))
+       {
                DEBUG(0, ("Could not add keepalive event\n"));
                exit(1);
        }
 #endif
 
-       if (!(event_add_idle(ev_ctx, NULL,
-                            timeval_set(IDLE_CLOSED_TIMEOUT, 0),
-                            "deadtime", deadtime_fn, sconn))) {
+       if (!(event_add_idle(ev_ctx,
+                            NULL,
+                            tevent_timeval_set(IDLE_CLOSED_TIMEOUT, 0),
+                            "deadtime",
+                            deadtime_fn,
+                            sconn)))
+       {
                DEBUG(0, ("Could not add deadtime event\n"));
                exit(1);
        }
 
-       if (!(event_add_idle(ev_ctx, NULL,
-                            timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
-                            "housekeeping", housekeeping_fn, sconn))) {
+       if (!(event_add_idle(ev_ctx,
+                            NULL,
+                            tevent_timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
+                            "housekeeping",
+                            housekeeping_fn,
+                            sconn)))
+       {
                DEBUG(0, ("Could not add housekeeping event\n"));
                exit(1);
        }
index f26fce77a2397bf557cd677a294d4593f1f28b8d..dd0ba880fd1dcf946be3ed2c30d64ad53d139773 100644 (file)
@@ -279,7 +279,7 @@ static struct tevent_req *delay_rename_for_lease_break(struct tevent_req *req,
 
        tevent_req_set_callback(subreq, defer_rename_done, rename_state);
 
-       timeout = timeval_set(OPLOCK_BREAK_TIMEOUT*2, 0);
+       timeout = tevent_timeval_set(OPLOCK_BREAK_TIMEOUT * 2, 0);
        if (!tevent_req_set_endtime(subreq,
                        ev,
                        timeval_sum(&smb2req->request_time, &timeout))) {
index 3c3dda3c779b178849a1405c3cd2bdfe576b5cc2..d61dd259d62bfc86c1a457bde6e830da740173e4 100644 (file)
@@ -266,8 +266,8 @@ int main(void)
 
        printf("server_id: %s\n", server_id_str_buf(id, &tmp));
 
-       req = msgcount_send(ev, ev, msg_ctx, MSG_SMB_NOTIFY,
-                           timeval_set(1, 0));
+       req = msgcount_send(
+               ev, ev, msg_ctx, MSG_SMB_NOTIFY, tevent_timeval_set(1, 0));
        if (req == NULL) {
                perror("msgcount_send failed");
                return -1;
index e718018be98e5ae1e8f13d4c6b0821392dfd87fd..6fb23f72252ccc6a7c46f21323bfb024acb1c229 100644 (file)
@@ -139,8 +139,12 @@ int main(int argc, const char *argv[])
                return -1;
        }
 
-       req = source_send(ev, ev, msg_ctx, MSG_SMB_NOTIFY,
-                         timeval_set(0, 10000), id);
+       req = source_send(ev,
+                         ev,
+                         msg_ctx,
+                         MSG_SMB_NOTIFY,
+                         tevent_timeval_set(0, 10000),
+                         id);
        if (req == NULL) {
                perror("source_send failed");
                return -1;
index a1000284102c56ffe6857bd0b55e9cc05241b90a..30dda0116a4a403eead5307fd1667b3fd791e91a 100644 (file)
@@ -83,13 +83,13 @@ static int net_g_lock_do(struct net_context *c, int argc, const char **argv)
                d_fprintf(stderr, _("g_lock_ctx_init failed\n"));
                return -1;
        }
-       status = g_lock_lock(
-               ctx,
-               key,
-               G_LOCK_WRITE,
-               timeval_set(timeout / 1000, timeout % 1000),
-               NULL,
-               NULL);
+       status = g_lock_lock(ctx,
+                            key,
+                            G_LOCK_WRITE,
+                            tevent_timeval_set(timeout / 1000,
+                                               timeout % 1000),
+                            NULL,
+                            NULL);
        if (!NT_STATUS_IS_OK(status)) {
                d_fprintf(stderr,
                          _("g_lock_lock failed: %s\n"),
index 5d1314ec37a5ebe4b4ba065d29afd8bf42e24f5f..92f6ebf374be979e6659ebe6a225c24af1187d7a 100644 (file)
@@ -616,7 +616,7 @@ static int net_registry_increment(struct net_context *c, int argc,
        status = g_lock_lock(ctx,
                             lock_key,
                             G_LOCK_WRITE,
-                            timeval_set(600, 0),
+                            tevent_timeval_set(600, 0),
                             NULL,
                             NULL);
        if (!NT_STATUS_IS_OK(status)) {
index 59daaffbd25ad043b1f6dd565098a8f1d0f69d80..a73afe483fb30624b3d53eb448e0c30c1544e3b5 100644 (file)
@@ -174,8 +174,10 @@ rekinit:
                                        new_start = time(NULL) +
                                                    MAX(30, lp_winbind_cache_time());
 #endif
-                                       add_krb5_ticket_gain_handler_event(entry,
-                                                       timeval_set(new_start, 0));
+                                       add_krb5_ticket_gain_handler_event(
+                                               entry,
+                                               tevent_timeval_set(new_start,
+                                                                  0));
                                        return;
                                }
                                TALLOC_FREE(entry->event);
@@ -250,8 +252,8 @@ rekinit:
 #endif
                        /* ticket is destroyed here, we have to regain it
                         * if it is possible */
-                       add_krb5_ticket_gain_handler_event(entry,
-                                               timeval_set(new_start, 0));
+                       add_krb5_ticket_gain_handler_event(
+                               entry, tevent_timeval_set(new_start, 0));
                        return;
                }
 
@@ -280,18 +282,19 @@ done:
             && (entry->renew_until <= expire_time)) {
                /* try to regain ticket 10 seconds before expiration */
                expire_time -= 10;
-               add_krb5_ticket_gain_handler_event(entry,
-                                       timeval_set(expire_time, 0));
+               add_krb5_ticket_gain_handler_event(
+                       entry, tevent_timeval_set(expire_time, 0));
                return;
        }
 
        if (entry->refresh_time == 0) {
                entry->refresh_time = new_start;
        }
-       entry->event = tevent_add_timer(global_event_context(), entry,
-                                      timeval_set(new_start, 0),
-                                      krb5_ticket_refresh_handler,
-                                      entry);
+       entry->event = tevent_add_timer(global_event_context(),
+                                       entry,
+                                       tevent_timeval_set(new_start, 0),
+                                       krb5_ticket_refresh_handler,
+                                       entry);
 
 #endif
 }
@@ -371,7 +374,7 @@ static void krb5_ticket_gain_handler(struct tevent_context *event_ctx,
   retry_later:
 
 #if defined(DEBUG_KRB5_TKT_RENEWAL)
-       t = timeval_set(time(NULL) + 30, 0);
+       t = tevent_timeval_set(time(NULL) + 30, 0);
 #else
        t = timeval_current_ofs(MAX(30, lp_winbind_cache_time()), 0);
 #endif
@@ -382,9 +385,9 @@ static void krb5_ticket_gain_handler(struct tevent_context *event_ctx,
   got_ticket:
 
 #if defined(DEBUG_KRB5_TKT_RENEWAL)
-       t = timeval_set(time(NULL) + 30, 0);
+       t = tevent_timeval_set(time(NULL) + 30, 0);
 #else
-       t = timeval_set(krb5_event_refresh_time(entry->refresh_time), 0);
+       t = tevent_timeval_set(krb5_event_refresh_time(entry->refresh_time), 0);
 #endif
 
        if (entry->refresh_time == 0) {
@@ -545,10 +548,11 @@ NTSTATUS add_ccache_to_list(const char *princ_name,
                        } else {
                                /* Renew at 1/2 the ticket expiration time */
 #if defined(DEBUG_KRB5_TKT_RENEWAL)
-                               t = timeval_set(time(NULL)+30, 0);
+                               t = tevent_timeval_set(time(NULL) + 30, 0);
 #else
-                               t = timeval_set(krb5_event_refresh_time(ticket_end),
-                                               0);
+                               t = tevent_timeval_set(krb5_event_refresh_time(
+                                                              ticket_end),
+                                                      0);
 #endif
                                if (!entry->refresh_time) {
                                        entry->refresh_time = t.tv_sec;
@@ -659,9 +663,9 @@ NTSTATUS add_ccache_to_list(const char *princ_name,
        } else {
                /* Renew at 1/2 the ticket expiration time */
 #if defined(DEBUG_KRB5_TKT_RENEWAL)
-               t = timeval_set(time(NULL)+30, 0);
+               t = tevent_timeval_set(time(NULL) + 30, 0);
 #else
-               t = timeval_set(krb5_event_refresh_time(ticket_end), 0);
+               t = tevent_timeval_set(krb5_event_refresh_time(ticket_end), 0);
 #endif
                if (entry->refresh_time == 0) {
                        entry->refresh_time = t.tv_sec;
index e63b4052fd81fcf86822f16990e99f0d67afc5ac..fdb66d0e1c7b4ab11ee3bd97b7a6de7312143547 100644 (file)
@@ -1285,7 +1285,7 @@ static bool calculate_next_machine_pwd_change(const char *domain,
                next_change = pass_last_set_time + timeout;
                DEBUG(10,("machine password still valid until: %s\n",
                        http_timestring(talloc_tos(), next_change)));
-               *t = timeval_set(next_change, 0);
+               *t = tevent_timeval_set(next_change, 0);
 
                if (lp_clustering()) {
                        uint8_t randbuf;