[PATCHES] dbwrap_ctdb: Small cleanup
Christof Schmitt
cs at samba.org
Wed Nov 18 00:31:14 UTC 2015
From 429c9d281a3d47be757894c8b56bc273803697a3 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Thu, 9 Jul 2015 10:48:13 -0700
Subject: [PATCH 1/2] dbwrap_ctdb: Use C99 initializer instead of ZERO_STRUCT
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/lib/dbwrap/dbwrap_ctdb.c | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 93df7ef..2bc86d2 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -557,9 +557,7 @@ static NTSTATUS db_ctdb_transaction_store(struct db_ctdb_transaction_handle *h,
{
TALLOC_CTX *tmp_ctx = talloc_new(h);
TDB_DATA rec;
- struct ctdb_ltdb_header header;
-
- ZERO_STRUCT(header);
+ struct ctdb_ltdb_header header = { 0 };
/* we need the header so we can update the RSN */
@@ -1443,9 +1441,8 @@ static NTSTATUS db_ctdb_delete_deny(struct db_record *rec)
static void traverse_read_callback(TDB_DATA key, TDB_DATA data, void *private_data)
{
struct traverse_state *state = (struct traverse_state *)private_data;
- struct db_record rec;
+ struct db_record rec = { 0 };
- ZERO_STRUCT(rec);
rec.db = state->db;
rec.key = key;
rec.value = data;
@@ -1460,7 +1457,7 @@ static int traverse_persistent_callback_read(TDB_CONTEXT *tdb, TDB_DATA kbuf, TD
void *private_data)
{
struct traverse_state *state = (struct traverse_state *)private_data;
- struct db_record rec;
+ struct db_record rec = { 0 };
/*
* Skip the __db_sequence_number__ key:
@@ -1472,7 +1469,6 @@ static int traverse_persistent_callback_read(TDB_CONTEXT *tdb, TDB_DATA kbuf, TD
return 0;
}
- ZERO_STRUCT(rec);
rec.db = state->db;
rec.key = kbuf;
rec.value = dbuf;
--
1.7.1
From ec1407742044dd9c26c6a1e8feb50b2336603db8 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Thu, 9 Jul 2015 10:52:30 -0700
Subject: [PATCH 2/2] dbwrap_ctdb: Remove casts from void * for private_data pointer
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/lib/dbwrap/dbwrap_ctdb.c | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 2bc86d2..365f44f 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -83,8 +83,7 @@ struct db_ctdb_ltdb_parse_state {
static int db_ctdb_ltdb_parser(TDB_DATA key, TDB_DATA data,
void *private_data)
{
- struct db_ctdb_ltdb_parse_state *state =
- (struct db_ctdb_ltdb_parse_state *)private_data;
+ struct db_ctdb_ltdb_parse_state *state = private_data;
if (data.dsize < sizeof(struct ctdb_ltdb_header)) {
return -1;
@@ -408,8 +407,7 @@ static void pull_newest_from_marshall_buffer_parser(
TDB_DATA key, struct ctdb_ltdb_header *header,
TDB_DATA data, void *private_data)
{
- struct pull_newest_from_marshall_buffer_state *state =
- (struct pull_newest_from_marshall_buffer_state *)private_data;
+ struct pull_newest_from_marshall_buffer_state *state = private_data;
if (state->pheader != NULL) {
memcpy(state->pheader, header, sizeof(*state->pheader));
@@ -632,7 +630,7 @@ static void db_ctdb_fetch_db_seqnum_parser(
TDB_DATA key, struct ctdb_ltdb_header *header,
TDB_DATA data, void *private_data)
{
- uint64_t *seqnum = (uint64_t *)private_data;
+ uint64_t *seqnum = private_data;
if (data.dsize != sizeof(uint64_t)) {
*seqnum = 0;
@@ -1032,7 +1030,7 @@ static struct db_record *fetch_locked_internal(struct db_ctdb_ctx *ctx,
}
result->db = ctx->db;
- result->private_data = (void *)crec;
+ result->private_data = crec;
crec->ctdb_ctx = ctx;
result->key.dsize = key.dsize;
@@ -1229,8 +1227,7 @@ static void db_ctdb_parse_record_parser_nonpersistent(
TDB_DATA key, struct ctdb_ltdb_header *header,
TDB_DATA data, void *private_data)
{
- struct db_ctdb_parse_record_state *state =
- (struct db_ctdb_parse_record_state *)private_data;
+ struct db_ctdb_parse_record_state *state = private_data;
if (db_ctdb_can_use_local_hdr(header, true)) {
state->parser(key, data, state->private_data);
@@ -1310,7 +1307,7 @@ struct traverse_state {
static void traverse_callback(TDB_DATA key, TDB_DATA data, void *private_data)
{
- struct traverse_state *state = (struct traverse_state *)private_data;
+ struct traverse_state *state = private_data;
struct db_record *rec;
TALLOC_CTX *tmp_ctx = talloc_new(state->db);
/* we have to give them a locked record to prevent races */
@@ -1324,7 +1321,7 @@ static void traverse_callback(TDB_DATA key, TDB_DATA data, void *private_data)
static int traverse_persistent_callback(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
void *private_data)
{
- struct traverse_state *state = (struct traverse_state *)private_data;
+ struct traverse_state *state = private_data;
struct db_record *rec;
TALLOC_CTX *tmp_ctx = talloc_new(state->db);
int ret = 0;
@@ -1456,7 +1453,7 @@ static void traverse_read_callback(TDB_DATA key, TDB_DATA data, void *private_da
static int traverse_persistent_callback_read(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
void *private_data)
{
- struct traverse_state *state = (struct traverse_state *)private_data;
+ struct traverse_state *state = private_data;
struct db_record rec = { 0 };
/*
@@ -1684,7 +1681,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
"migrate_duration", 5000);
db_ctdb->warn_locktime_msecs = lp_ctdb_locktime_warn_threshold();
- result->private_data = (void *)db_ctdb;
+ result->private_data = db_ctdb;
result->fetch_locked = db_ctdb_fetch_locked;
result->try_fetch_locked = db_ctdb_try_fetch_locked;
result->parse_record = db_ctdb_parse_record;
--
1.7.1
More information about the samba-technical
mailing list