Skip to content

Commit

Permalink
drbd: conn_send_cmd2(): Return 0 upon success and an error code other…
Browse files Browse the repository at this point in the history
…wise

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
  • Loading branch information
Andreas Gruenbacher authored and Philipp Reisner committed Nov 8, 2012
1 parent fb708e4 commit ce9879c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
24 changes: 10 additions & 14 deletions drivers/block/drbd/drbd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,21 +769,17 @@ int conn_send_cmd2(struct drbd_tconn *tconn, enum drbd_packet cmd, char *data,
size_t size)
{
struct p_header80 h;
int ok;
int err;

prepare_header80(&h, cmd, size);

if (drbd_get_data_sock(tconn))
return 0;

ok = (sizeof(h) ==
drbd_send(tconn, tconn->data.socket, &h, sizeof(h), 0));
ok = ok && (size ==
drbd_send(tconn, tconn->data.socket, data, size, 0));

drbd_put_data_sock(tconn);

return ok;
err = drbd_get_data_sock(tconn);
if (!err) {
err = drbd_send_all(tconn, tconn->data.socket, &h, sizeof(h), 0);
if (!err)
err = drbd_send_all(tconn, tconn->data.socket, data, size, 0);
drbd_put_data_sock(tconn);
}
return err;
}

int drbd_send_sync_param(struct drbd_conf *mdev)
Expand Down Expand Up @@ -882,7 +878,7 @@ int drbd_send_protocol(struct drbd_tconn *tconn)
if (tconn->agreed_pro_version >= 87)
strcpy(p->integrity_alg, tconn->net_conf->integrity_alg);

rv = conn_send_cmd2(tconn, P_PROTOCOL, p->head.payload, size - sizeof(struct p_header));
rv = !conn_send_cmd2(tconn, P_PROTOCOL, p->head.payload, size - sizeof(struct p_header));
kfree(p);
return rv;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/drbd/drbd_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -4265,7 +4265,7 @@ static int drbd_do_auth(struct drbd_tconn *tconn)

get_random_bytes(my_challenge, CHALLENGE_LEN);

rv = conn_send_cmd2(tconn, P_AUTH_CHALLENGE, my_challenge, CHALLENGE_LEN);
rv = !conn_send_cmd2(tconn, P_AUTH_CHALLENGE, my_challenge, CHALLENGE_LEN);
if (!rv)
goto fail;

Expand Down Expand Up @@ -4320,7 +4320,7 @@ static int drbd_do_auth(struct drbd_tconn *tconn)
goto fail;
}

rv = conn_send_cmd2(tconn, P_AUTH_RESPONSE, response, resp_size);
rv = !conn_send_cmd2(tconn, P_AUTH_RESPONSE, response, resp_size);
if (!rv)
goto fail;

Expand Down

0 comments on commit ce9879c

Please sign in to comment.