[PATCH xclock] Fix a crash on sparc64

Alan Coopersmith alan.coopersmith at oracle.com
Thu Jul 29 12:54:14 PDT 2010


Matthieu Herrb wrote:
> From 017b77fa3323f34f7cf09efbe0e3358a3ea733f8 Mon Sep 17 00:00:00 2001
> From: David Coppa <dcoppa at gmail.com>
> Date: Thu, 29 Jul 2010 21:46:11 +0200
> Subject: [PATCH xclock] Fix a crash on sparc64.
> 
> The pid variable that is passed to XChangeProperty() is not a long.
> The libX11 code deferences the variable as a long and on a 64-bit sparc
> this must be aligned on a 8-byte boundary.
> 
> Signed-off-by: Matthieu Herrb <matthieu.herrb at laas.fr>
> ---
>  xclock.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/xclock.c b/xclock.c
> index 6b80ad0..5965a83 100644
> --- a/xclock.c
> +++ b/xclock.c
> @@ -215,7 +215,7 @@ main(int argc, char *argv[])
>  
>  #ifdef HAVE_GETPID
>      {
> -	pid_t pid = getpid();
> +	unsigned long pid = (unsigned long)getpid();
>  	XChangeProperty(XtDisplay(toplevel), XtWindow(toplevel),
>  			XInternAtom(XtDisplay(toplevel), "_NET_WM_PID", False),
>  			XA_CARDINAL, 32, PropModeReplace,

Oops.  Oh how I wish we could undo xlib's "CARD32 is always long" confusion...

Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list