1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

Whitespace changes and using the CTDB_NO_MEMORY() macro changes to

the previous patch.

(This used to be ctdb commit d623ea7c04daa6349b42d50862843c9f86115488)
This commit is contained in:
Ronnie Sahlberg 2009-05-21 11:49:16 +10:00
parent 2fcedf6dac
commit 26e1486db7
9 changed files with 35 additions and 27 deletions

View File

@ -2709,24 +2709,24 @@ int ctdb_ctrl_get_server_id_list(struct ctdb_context *ctdb,
*/
struct ctdb_context *ctdb_init(struct event_context *ev)
{
int ret;
int ret;
struct ctdb_context *ctdb;
ctdb = talloc_zero(ev, struct ctdb_context);
if (ctdb == NULL) {
if (ctdb == NULL) {
DEBUG(DEBUG_ERR,(__location__ " talloc_zero failed.\n"));
return NULL;
}
return NULL;
}
ctdb->ev = ev;
ctdb->idr = idr_init(ctdb);
CTDB_NO_MEMORY_NULL(ctdb, ctdb->idr);
ret = ctdb_set_socketname(ctdb, CTDB_PATH);
if (ret != 0) {
if (ret != 0) {
DEBUG(DEBUG_ERR,(__location__ " ctdb_set_socketname failed.\n"));
talloc_free(ctdb);
return NULL;
}
talloc_free(ctdb);
return NULL;
}
return ctdb;
}
@ -2746,7 +2746,8 @@ void ctdb_set_flags(struct ctdb_context *ctdb, unsigned flags)
int ctdb_set_socketname(struct ctdb_context *ctdb, const char *socketname)
{
ctdb->daemon.name = talloc_strdup(ctdb, socketname);
if (ctdb->daemon.name == NULL) return -1;
CTDB_NO_MEMORY(ctdb, ctdb->daemon.name);
return 0;
}

View File

@ -73,7 +73,8 @@ int ctdb_parse_address(struct ctdb_context *ctdb,
endservent();
address->address = talloc_strdup(mem_ctx, str);
if (address->address == NULL) return -1;
CTDB_NO_MEMORY(ctdb, address->address);
if (se == NULL) {
address->port = CTDB_PORT;
} else {

View File

@ -166,7 +166,8 @@ int ctdb_ibw_receive_handler(struct ibw_conn *conn, void *buf, int n)
* and being reused for next receive
* noticed that HL requires talloc-ed memory to be stolen */
buf2 = talloc_zero_size(conn, n);
if (buf2 == NULL) return -1;
CTDB_NO_MEMORY(ctdb, buf2);
memcpy(buf2, buf, n);
ctdb->upcalls->recv_pkt(ctdb, (uint8_t *)buf2, (uint32_t)n);

View File

@ -164,15 +164,11 @@ static int ctdb_ibw_queue_pkt(struct ctdb_node *node, uint8_t *data, uint32_t le
rc = ctdb_ibw_send_pkt(cn->conn, data, length);
} else {
struct ctdb_ibw_msg *p = talloc_zero(cn, struct ctdb_ibw_msg);
if (p == NULL) {
DEBUG(DEBUG_ERR, ("talloc_zero failed.\n"));
return -1;
}
CTDB_NO_MEMORY(node->ctdb, p);
p->data = talloc_memdup(p, data, length);
if (p->data == NULL) {
DEBUG(DEBUG_ERR, ("talloc_memdup failed.\n"));
return -1;
}
CTDB_NO_MEMORY(node->ctdb, p->data);
p->length = length;
DLIST_ADD_AFTER(cn->queue, p, cn->queue_last);

View File

@ -852,7 +852,9 @@ static int ibw_wc_recv(struct ibw_conn *conn, struct ibv_wc *wc)
}
if (part->to_read==0) {
if(pctx->receive_func(conn, part->buf, part->len)) goto error;
if (pctx->receive_func(conn, part->buf, part->len) != 0) {
goto error;
}
part->len = 0; /* tells not having partial data (any more) */
if (ibw_wc_mem_threshold(pconn, part, pctx->opts.recv_threshold))
goto error;
@ -867,7 +869,9 @@ static int ibw_wc_recv(struct ibw_conn *conn, struct ibv_wc *wc)
/* mostly awaited case: */
if (msglen<=remain) {
if(pctx->receive_func(conn, p, msglen)) goto error;
if (pctx->receive_func(conn, p, msglen) != 0) {
goto error;
}
p += msglen;
remain -= msglen;
} else {

View File

@ -28,7 +28,7 @@ static void _do_debug_v(const char *format, va_list ap)
char *s = NULL;
struct tm *tm;
char tbuf[100];
int ret;
int ret;
ret = vasprintf(&s, format, ap);
if (ret == -1) {

View File

@ -84,7 +84,9 @@ static void ctdb_logfile_log(const char *format, va_list ap)
ret = vasprintf(&s, format, ap);
if (ret == -1) {
write(log_state->fd, "vasprintf failed\n", strlen("vasprintf failed\n"));
const char *errstr = "vasprintf failed\n";
write(log_state->fd, errstr, strlen(errstr));
return;
}
@ -97,7 +99,8 @@ static void ctdb_logfile_log(const char *format, va_list ap)
tbuf, (unsigned)t.tv_usec, (unsigned)getpid(), s);
free(s);
if (ret == -1) {
write(log_state->fd, "asprintf failed\n", strlen("asprintf failed\n"));
const char *errstr = "asprintf failed\n";
write(log_state->fd, errstr, strlen(errstr));
return;
}
if (s2) {

View File

@ -31,7 +31,8 @@
int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport)
{
ctdb->transport = talloc_strdup(ctdb, transport);
if (ctdb->transport == NULL) return -1;
CTDB_NO_MEMORY(ctdb, ctdb->transport);
return 0;
}
@ -58,7 +59,8 @@ int ctdb_ip_to_nodeid(struct ctdb_context *ctdb, const char *nodeip)
int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file)
{
ctdb->recovery_lock_file = talloc_strdup(ctdb, file);
if (ctdb->recovery_lock_file == NULL) return -1;
CTDB_NO_MEMORY(ctdb, ctdb->recovery_lock_file);
return 0;
}

View File

@ -71,7 +71,7 @@ static void check_counters(struct ctdb_context *ctdb, TDB_DATA data)
{
int i;
uint32_t *counters, *old_counters;
unsigned char *tmp_dptr;
unsigned char *tmp_dptr;
counters = (uint32_t *)data.dptr;
old_counters = (uint32_t *)old_data.dptr;