[PATCH v4 2/2] Weston: Replace fprintf() by weston_log()

Pekka Paalanen ppaalanen at gmail.com
Fri Jun 1 03:14:45 PDT 2012


On Thu, 31 May 2012 22:48:44 +0200
Martin Minarik <minarik11 at student.fiit.stuba.sk> wrote:

> Now it is possible removing include stdio as well.
> ---
>  src/compositor-drm.c          |  105 ++++++++++++++++++++---------------------
>  src/compositor-openwfd.c      |   38 +++++++-------
>  src/compositor-wayland.c      |   27 ++++++-----
>  src/compositor-x11.c          |   22 ++++----
>  src/compositor.c              |   57 +++++++++++------------
>  src/evdev.c                   |   12 ++--
>  src/shell.c                   |   15 +++---
>  src/tablet-shell.c            |   11 ++--
>  src/tty.c                     |   33 ++++++-------
>  src/xwayland/launcher.c       |   30 ++++++------
>  src/xwayland/selection.c      |   52 ++++++++++----------
>  src/xwayland/window-manager.c |   74 ++++++++++++++---------------
>  12 files changed, 235 insertions(+), 241 deletions(-)

Hi Martin,

this patch looks good, just a couple of comments:
- apparently needs to be rebased to current master
- the following:

> diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
> index b8be54c..827dccb 100644
> --- a/src/xwayland/window-manager.c
> +++ b/src/xwayland/window-manager.c
> @@ -36,6 +36,7 @@
>  
>  #include "../../shared/cairo-util.h"
>  #include "../compositor.h"
> +#include "../log.h"
>  #include "xserver-server-protocol.h"
>  #include "hash.h"
>  
> @@ -148,13 +149,13 @@ dump_property(struct weston_wm *wm,
>  	int width, len;
>  	uint32_t i;
>  
> -	width = fprintf(stderr, "%s: ", get_atom_name(wm->conn, property));
> +	width = weston_log_continue("%s: ", get_atom_name(wm->conn, property));

This function starts straight with weston_log_continue(), does this
imply that every caller of dump_property() already calls weston_log()
first and with a newline?

>  	if (reply == NULL) {
> -		fprintf(stderr, "(no reply)\n");
> +		weston_log_continue("(no reply)\n");
>  		return;
>  	}
>  
> -	width += fprintf(stderr,
> +	width += weston_log_continue(
>  			 "%s/%d, length %d (value_len %d): ",
>  			 get_atom_name(wm->conn, reply->type),
>  			 reply->format,
> @@ -163,7 +164,7 @@ dump_property(struct weston_wm *wm,
>  
>  	if (reply->type == wm->atom.incr) {
>  		incr_value = xcb_get_property_value(reply);
> -		fprintf(stderr, "%d\n", *incr_value);
> +		weston_log_continue("%d\n", *incr_value);
>  	} else if (reply->type == wm->atom.utf8_string ||
>  	      reply->type == wm->atom.string) {
>  		text_value = xcb_get_property_value(reply);
> @@ -171,23 +172,23 @@ dump_property(struct weston_wm *wm,
>  			len = 40;
>  		else
>  			len = reply->value_len;
> -		fprintf(stderr, "\"%.*s\"\n", len, text_value);
> +		weston_log_continue("\"%.*s\"\n", len, text_value);
>  	} else if (reply->type == XCB_ATOM_ATOM) {
>  		atom_value = xcb_get_property_value(reply);
>  		for (i = 0; i < reply->value_len; i++) {
>  			name = get_atom_name(wm->conn, atom_value[i]);
>  			if (width + strlen(name) + 2 > 78) {
> -				fprintf(stderr, "\n    ");
> +				weston_log_continue("\n    ");
>  				width = 4;
>  			} else if (i > 0) {
> -				width += fprintf(stderr, ", ");
> +				width +=  weston_log_continue(", ");
>  			}
>  
> -			width += fprintf(stderr, "%s", name);
> +			width +=  weston_log_continue("%s", name);
>  		}
> -		fprintf(stderr, "\n");
> +		weston_log_continue("\n");
>  	} else {
> -		fprintf(stderr, "huh?\n");
> +		weston_log_continue("huh?\n");
>  	}
>  }
>  

Thanks,
pq


More information about the wayland-devel mailing list