From: Volker Lendecke Date: Sat, 21 Dec 2019 09:47:37 +0000 (+0100) Subject: torture3: Introduce "key" helper variable X-Git-Tag: ldb-2.1.0~146 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf592a1905984042aeb57ddef654229ffb2ee39b;p=thirdparty%2Fsamba.git torture3: Introduce "key" helper variable Call string_term_tdb_data() once instead of three times Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/torture/test_g_lock.c b/source3/torture/test_g_lock.c index c720e7d6612..6a199c50354 100644 --- a/source3/torture/test_g_lock.c +++ b/source3/torture/test_g_lock.c @@ -455,6 +455,7 @@ bool run_g_lock4(int dummy) struct messaging_context *msg = NULL; struct g_lock_ctx *ctx = NULL; const char *lockname = "lock4"; + TDB_DATA key = string_term_tdb_data(lockname); pid_t child; int ready_pipe[2]; int exit_pipe[2]; @@ -501,24 +502,23 @@ bool run_g_lock4(int dummy) return false; } - status = g_lock_lock(ctx, string_term_tdb_data(lockname), G_LOCK_WRITE, - (struct timeval) { .tv_usec = 1 }); + status = g_lock_lock( + ctx, key, G_LOCK_WRITE, (struct timeval) { .tv_usec = 1 }); if (!NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { fprintf(stderr, "g_lock_lock returned %s\n", nt_errstr(status)); goto fail; } - status = g_lock_lock(ctx, string_term_tdb_data(lockname), G_LOCK_READ, - (struct timeval) { .tv_usec = 1 }); + status = g_lock_lock( + ctx, key, G_LOCK_READ, (struct timeval) { .tv_usec = 1 }); if (!NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { fprintf(stderr, "g_lock_lock returned %s\n", nt_errstr(status)); goto fail; } - req = g_lock_lock_send(ev, ev, ctx, string_term_tdb_data(lockname), - G_LOCK_WRITE); + req = g_lock_lock_send(ev, ev, ctx, key, G_LOCK_WRITE); if (req == NULL) { fprintf(stderr, "g_lock_lock send failed\n"); goto fail; @@ -547,8 +547,7 @@ bool run_g_lock4(int dummy) .me = messaging_server_id(msg) }; - status = g_lock_dump(ctx, string_term_tdb_data(lockname), - lock4_check, &state); + status = g_lock_dump(ctx, key, lock4_check, &state); if (!NT_STATUS_IS_OK(status)) { fprintf(stderr, "g_lock_dump failed: %s\n", nt_errstr(status));