Convert printf_errf/dbgf in several files

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2018-12-20 16:54:51 +00:00
parent 3966491846
commit b5b0f4af7f
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
4 changed files with 15 additions and 14 deletions

View File

@ -4064,8 +4064,8 @@ write_binary_data(const char *path, const unsigned char *data, int length) {
int wrote_len = fwrite(data, sizeof(unsigned char), length, f); int wrote_len = fwrite(data, sizeof(unsigned char), length, f);
fclose(f); fclose(f);
if (wrote_len != length) { if (wrote_len != length) {
printf_errf("(\"%s\"): Failed to write all blocks: %d / %d", path, log_error("Failed to write all blocks: %d / %d to %s",
wrote_len, length); wrote_len, length, path);
return false; return false;
} }
return true; return true;

View File

@ -134,7 +134,7 @@ static inline bool
wid_set_text_prop(session_t *ps, Window wid, Atom prop_atom, char *str) { wid_set_text_prop(session_t *ps, Window wid, Atom prop_atom, char *str) {
XTextProperty *pprop = make_text_prop(ps, str); XTextProperty *pprop = make_text_prop(ps, str);
if (!pprop) { if (!pprop) {
printf_errf("(\"%s\"): Failed to make text property.", str); log_error("Failed to make text property: %s.", str);
return false; return false;
} }
@ -155,10 +155,11 @@ dump_drawable(session_t *ps, Drawable drawable) {
unsigned width = 0, height = 0, border = 0, depth = 0; unsigned width = 0, height = 0, border = 0, depth = 0;
if (XGetGeometry(ps->dpy, drawable, &rroot, &x, &y, &width, &height, if (XGetGeometry(ps->dpy, drawable, &rroot, &x, &y, &width, &height,
&border, &depth)) { &border, &depth)) {
printf_dbgf("(%#010lx): x = %u, y = %u, wid = %u, hei = %d, b = %u, d = %u\n", drawable, x, y, width, height, border, depth); log_trace("Drawable %#010lx: x = %u, y = %u, wid = %u, hei = %d, b = %u, d = %u",
drawable, x, y, width, height, border, depth);
} }
else { else {
printf_dbgf("(%#010lx): Failed\n", drawable); log_trace("Drawable %#010lx: Failed", drawable);
} }
} }

10
src/x.c
View File

@ -112,7 +112,7 @@ static inline void x_get_server_pictfmts(session_t *ps) {
xcb_render_query_pict_formats_reply(ps->c, xcb_render_query_pict_formats_reply(ps->c,
xcb_render_query_pict_formats(ps->c), &e); xcb_render_query_pict_formats(ps->c), &e);
if (e || !ps->pictfmts) { if (e || !ps->pictfmts) {
printf_errf("(): failed to get pict formats\n"); log_fatal("failed to get pict formats\n");
abort(); abort();
} }
} }
@ -142,8 +142,8 @@ x_create_picture_with_pictfmt_and_pixmap(
if (attr) { if (attr) {
xcb_render_create_picture_value_list_serialize(&buf, valuemask, attr); xcb_render_create_picture_value_list_serialize(&buf, valuemask, attr);
if (!buf) { if (!buf) {
printf_errf("(): failed to serialize picture attributes"); log_error("failed to serialize picture attributes");
return None; return XCB_NONE;
} }
} }
@ -153,8 +153,8 @@ x_create_picture_with_pictfmt_and_pixmap(
pixmap, pictfmt->id, valuemask, buf)); pixmap, pictfmt->id, valuemask, buf));
free(buf); free(buf);
if (e) { if (e) {
printf_errf("(): failed to create picture"); log_error("failed to create picture");
return None; return XCB_NONE;
} }
return tmp_picture; return tmp_picture;
} }

View File

@ -40,7 +40,7 @@ xrc_delete_xid_(XID xid, M_POS_DATA_PARAMS) {
xrc_xid_record_t *prec = NULL; xrc_xid_record_t *prec = NULL;
HASH_FIND_XID(gs_xid_records, &xid, prec); HASH_FIND_XID(gs_xid_records, &xid, prec);
if (!prec) { if (!prec) {
printf_err("XRC: %s:%d %s(): Can't find XID %#010lx we want to delete.", log_error("XRC: %s:%d %s(): Can't find XID %#010lx we want to delete.",
file, line, func, xid); file, line, func, xid);
return; return;
} }
@ -54,7 +54,7 @@ xrc_delete_xid_(XID xid, M_POS_DATA_PARAMS) {
void void
xrc_report_xid(void) { xrc_report_xid(void) {
for (xrc_xid_record_t *prec = gs_xid_records; prec; prec = prec->hh.next) for (xrc_xid_record_t *prec = gs_xid_records; prec; prec = prec->hh.next)
printf_dbg("XRC: %s:%d %s(): %#010lx (%s) not freed.\n", log_trace("XRC: %s:%d %s(): %#010lx (%s) not freed.\n",
prec->file, prec->line, prec->func, prec->xid, prec->type); prec->file, prec->line, prec->func, prec->xid, prec->type);
} }