xmppipe_uuid_gen: xmpp_uuid_gen NULL check wrapper

master
Michael Santos 5 years ago
parent ad1bf58c55
commit abfa336640

@ -469,10 +469,7 @@ int handle_disco_items(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
xmppipe_stanza_set_type(iq, "get");
xmppipe_stanza_set_attribute(iq, "to", jid);
id = xmpp_uuid_gen(state->ctx);
if (id == NULL) {
errx(EXIT_FAILURE, "unable to allocate message id");
}
id = xmppipe_uuid_gen(state->ctx);
xmppipe_stanza_set_id(iq, id);
reply = xmppipe_stanza_new(ctx);

@ -149,6 +149,7 @@ char *xmppipe_getenv(const char *);
char *xmppipe_strdup(const char *);
void *xmppipe_malloc(size_t);
void *xmppipe_calloc(size_t, size_t);
char *xmppipe_uuid_gen(xmpp_ctx_t *ctx);
xmpp_stanza_t *xmppipe_message_new(xmpp_ctx_t *ctx, const char *const type,
const char *const to, const char *const id);

@ -167,11 +167,7 @@ static void xmppipe_send_message(xmppipe_state_t *state, char *to, char *type,
xmpp_stanza_t *message = NULL;
char *id = NULL;
id = xmpp_uuid_gen(state->ctx);
if (id == NULL) {
errx(EXIT_FAILURE, "unable to allocate message id");
}
id = xmppipe_uuid_gen(state->ctx);
message = xmppipe_message_new(state->ctx, type, to, id);
@ -199,11 +195,7 @@ static void xmppipe_send_oob(xmppipe_state_t *state, char *to, char *type,
xmpp_stanza_t *text;
char *id;
id = xmpp_uuid_gen(state->ctx);
if (id == NULL) {
errx(EXIT_FAILURE, "unable to allocate message id");
}
id = xmppipe_uuid_gen(state->ctx);
message = xmppipe_message_new(state->ctx, type, to, id);
@ -250,11 +242,7 @@ static void xmppipe_send_http_upload(xmppipe_state_t *state, char *to,
return;
}
id = xmpp_uuid_gen(state->ctx);
if (id == NULL) {
errx(EXIT_FAILURE, "unable to allocate message id");
}
id = xmppipe_uuid_gen(state->ctx);
start = buf;

@ -249,6 +249,17 @@ char *xmppipe_roomname(char *label) {
return buf;
}
char *xmppipe_uuid_gen(xmpp_ctx_t *ctx) {
char *uuid;
uuid = xmpp_uuid_gen(ctx);
if (uuid == NULL)
errx(EXIT_FAILURE, "unable to allocate message id");
return uuid;
}
void xmppipe_next_state(xmppipe_state_t *state, int status) {
if (state->verbose)
(void)fprintf(stderr, "next state: %s (%d) -> %s (%d)\n",

Loading…
Cancel
Save