Bug 72169 - Cannot compile xf86-video-qxl-0.1.1 with spice-protocol-0.12.3: spiceqxl_display.c:353:56: error: cast from pointer to integer of different size
Cannot compile xf86-video-qxl-0.1.1 with spice-protocol-0.12.3: spiceqxl_disp...
Status: NEW
Product: xorg
Classification: Unclassified
Component: Driver/qxl
unspecified
x86 (IA32) Linux (All)
: medium normal
Assigned To: Søren Sandmann Pedersen
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-30 12:03 UTC by Petr Pisar
Modified: 2015-08-07 09:51 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
fix cast from pointer to integer of different size (876 bytes, patch)
2015-08-06 10:30 UTC, Christian Hesse
no flags Details | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Pisar 2013-11-30 12:03:20 UTC
It's not possible to compile spiceqxl_display.c from xf86-video-qxl-0.1.1 with spice-protocol-0.12.3 on 32-bit x86 because there is a cast from pointer to u_int64_t which is not compatible with 32-bit pointers on x86:

/var/tmp/portage/x11-drivers/xf86-video-qxl-0.1.1/work/xf86-video-qxl-0.1.1/src/spiceqxl_display.c: In function 'spiceqxl_display_monitors_config':
/var/tmp/portage/x11-drivers/xf86-video-qxl-0.1.1/work/xf86-video-qxl-0.1.1/src/spiceqxl_display.c:353:56: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

The bug is at src/spiceqxl_display.c:353 on casting second argument of spice_qxl_monitors_config_async() call:

void spiceqxl_display_monitors_config(qxl_screen_t *qxl)
{
    spice_qxl_monitors_config_async(&qxl->display_sin, (QXLPHYSICAL)qxl->monitors_config,
                                    MEMSLOT_GROUP, 0);
}

while spice-1/spice/qxl_dev.h:

typedef uint64_t QXLPHYSICAL;

and src/qxl.h:

typedef struct _qxl_screen_t qxl_screen_t;

struct _qxl_screen_t
{
  [...]
  struct QXLMonitorsConfig   *monitors_config;
  [...]
}
Comment 1 Peter Wu 2015-08-06 08:55:57 UTC
Confirmed, this is also a problem on Arch Linux and Debian.

https://bugs.debian.org/738744
Comment 2 Peter Wu 2015-08-06 08:57:14 UTC
Forgot to mention versions, it still happens with:
xf86-video-qxl 0.1.4
spice-protocol 0.12.9
spice 0.12.5
Comment 3 Christian Hesse 2015-08-06 10:30:53 UTC
Created attachment 117559 [details] [review]
fix cast from pointer to integer of different size

Why is qxl->monitors_config casted to QXLPHYSICAL at all? Looks like removing the case fixes the issue.
Comment 4 Peter Wu 2015-08-07 09:51:24 UTC
Comment on attachment 117559 [details] [review]
fix cast from pointer to integer of different size

Review of attachment 117559 [details] [review]:
-----------------------------------------------------------------

How is this supposed to help? The prototype in spice.h is:

/* since spice 0.12.0 */
void spice_qxl_monitors_config_async(QXLInstance *instance, QXLPHYSICAL monitors_config,
                                     int group_id, uint64_t cookie);

While xf86-video-qxl/src/qxl.h defines:

    struct _qxl_screen_t
    {
        ...
        struct QXLMonitorsConfig   *monitors_config;
        int monitors_config_size;
        ...
    };


The pointer really needs to be converted to a uint64_t (QXLPHYSICAL). I think that the cast to (uintptr_t) as you proposed on AUR is OK. Don't know whether there is a need to worry about endianess and such though.