[cairo-bugs] [Bug 93281] New: _cairo_surface_is_snapshot() return error result on armcc on RVDS/MDK
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Sun Dec 6 22:52:36 PST 2015
https://bugs.freedesktop.org/show_bug.cgi?id=93281
Bug ID: 93281
Summary: _cairo_surface_is_snapshot() return error result on
armcc on RVDS/MDK
Product: cairo
Version: unspecified
Hardware: ARM
OS: All
Status: NEW
Severity: critical
Priority: medium
Component: image backend
Assignee: chris at chris-wilson.co.uk
Reporter: chenzunfeng at qq.com
QA Contact: cairo-bugs at cairographics.org
static inline cairo_bool_t
_cairo_surface_is_snapshot (cairo_surface_t *surface)
{
return surface->backend->type ==
(cairo_surface_type_t)CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT;
}
On some platforms or compilers, size of enumuration types may be refered to the
max value of them, to reduce the memory usage. Like armcc of RVDS/MDK.
The detail on the armcc:
All the enum values of cairo_surface_type_t are small than 255, so the variable
defined by cairo_surface_type_t only has 1 bytes on the memory stack, but
CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT = 0x1000, so it has two bytes.
The code snippet from cairo-surface-snapshort-inline.h (above), comparation
between cairo_surface_type_t and cairo_internal_surface_type_t,
CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT is casted to cairo_surface_type_t, the
value may be wrong. Because not every compiler treates enumuration type as int.
Because of this, image surface crashed on arm cpu which is not running any OS.
There are too many code snippets cast a enumuration type to another one, this
may be not a good idea. ARMCC of RVDS/MDK gave me too many warning about the
issue.
I think there are not many persons run cairo on the bear metal without OS, but
it it indeed a problem.
The fixed code snippet that I've done is below:
static inline cairo_bool_t
_cairo_surface_is_snapshot (cairo_surface_t *surface)
{
return (int)surface->backend->type ==
(int)CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT;
}
--
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo-bugs/attachments/20151207/7bb976ad/attachment.html>
More information about the cairo-bugs
mailing list