[PATCH libX11 2/2] xcb_io: Add comment explaining a mixed type double assignment

Uli Schlachter psychon at znc.in
Sun Nov 17 05:06:59 PST 2013


Hi,

On 16.11.2013 22:37, Jonas Petersen wrote:
> The assignment might be confusing at first. So I added a note.
> 
> Signed-off-by: Jonas Petersen <jnsptrsn1 at gmail.com>
> ---
>  src/xcb_io.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/xcb_io.c b/src/xcb_io.c
> index f2978d0..acb1e3b 100644
> --- a/src/xcb_io.c
> +++ b/src/xcb_io.c
> @@ -83,6 +83,10 @@ static void require_socket(Display *dpy)
>  						 "did not own the socket",
>  			                         xcb_xlib_seq_number_wrapped);
>  		}
> +		/* The following line will truncate the 64-bit 'sent'
> +		 * to 32-bit when assigning it to 'dpy->request'. The
> +		 * truncated value will then be assigned to the 64-bit
> +		 * 'dpy->xcb->last_flushed' (which is intended). */
>  		dpy->xcb->last_flushed = dpy->request = sent;
>  		dpy->bufmax = dpy->xcb->real_bufmax;
>  	}

The involved types are:

   uint64_t sent;
   uint64_t last_flushed;
   unsigned long request;

So request isn't really a 32-bit type. In fact, on my system, all of these three
are the same type. So the comment doesn't really fit.

Now let's assume that unsigned long is a 32-bit integer. *Why* is it intended to
truncate last_flushed? This means that Xlib uses a 64 bit integer for to
tracking the sequence number, but only actually tracks it with 32 bits. This
seems wasteful. Why are you sure that this is intended?

Disclaimer: I don't know too much about Xlib internals and were not involved in
writing xcb_io.c

Cheers,
Uli
-- 
"Every once in a while, declare peace. It confuses the hell out of your enemies"
 - 79th Rule of Acquisition


More information about the xorg-devel mailing list