Use safe wrappers wherever possible

This commit is contained in:
shdown
2015-08-03 12:50:50 +03:00
parent bc52fae15c
commit c85d16faa4
14 changed files with 31 additions and 52 deletions

View File

@ -80,18 +80,10 @@ char *root_atom_contents(const char *atomname, xcb_connection_t *provided_conn,
if (prop_reply->type == XCB_ATOM_CARDINAL) {
/* We treat a CARDINAL as a >= 32-bit unsigned int. The only CARDINAL
* we query is I3_PID, which is 32-bit. */
if (asprintf(&content, "%u", *((unsigned int *)xcb_get_property_value(prop_reply))) == -1) {
free(atom_reply);
free(prop_reply);
return NULL;
}
sasprintf(&content, "%u", *((unsigned int *)xcb_get_property_value(prop_reply)));
} else {
if (asprintf(&content, "%.*s", xcb_get_property_value_length(prop_reply),
(char *)xcb_get_property_value(prop_reply)) == -1) {
free(atom_reply);
free(prop_reply);
return NULL;
}
sasprintf(&content, "%.*s", xcb_get_property_value_length(prop_reply),
(char *)xcb_get_property_value(prop_reply));
}
if (provided_conn == NULL)
xcb_disconnect(conn);