Bug Summary

File:root/firefox-clang/gfx/cairo/cairo/src/cairo-device.c
Warning:line 271, column 6
Value stored to 'status' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_c_gfx_cairo_cairo_src1.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/gfx/cairo/cairo/src -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/gfx/cairo/cairo/src -resource-dir /usr/lib/llvm-21/lib/clang/21 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D _GLIBCXX_ASSERTIONS -D DEBUG=1 -D HAVE_FT_LOAD_SFNT_TABLE -D PACKAGE_VERSION="moz" -D PACKAGE_BUGREPORT="http://bugzilla.mozilla.org/" -D CAIRO_HAS_PTHREAD -D _GNU_SOURCE -D MOZ_TREE_PIXMAN -D SIZEOF_VOID_P=__SIZEOF_POINTER__ -D SIZEOF_INT=__SIZEOF_INT__ -D SIZEOF_LONG=__SIZEOF_LONG__ -D SIZEOF_LONG_LONG=__SIZEOF_LONG_LONG__ -D HAVE_UINT64_T -D HAVE_CXX11_ATOMIC_PRIMITIVES -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/gfx/cairo/cairo/src -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/gfx/cairo/cairo/src -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/freetype2 -I /usr/include/libpng16 -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-error=tautological-type-limit-compare -Wno-range-loop-analysis -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-unknown-warning-option -Wno-enum-compare -Wno-int-to-pointer-cast -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-sign-compare -Wno-type-limits -Wno-missing-field-initializers -Wno-conversion -Wno-narrowing -Wno-switch -Wno-unused -Wno-unused-variable -Wno-error=uninitialized -Wno-absolute-value -Wno-deprecated-register -Wno-incompatible-pointer-types -Wno-macro-redefined -Wno-shift-negative-value -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Wno-unreachable-code -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2025-06-30-093548-1913035-1 -x c Unified_c_gfx_cairo_cairo_src1.c
1/* Cairo - a vector graphics library with display and print output
2 *
3 * Copyright © 2009 Intel Corporation
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it either under the terms of the GNU Lesser General Public
7 * License version 2.1 as published by the Free Software Foundation
8 * (the "LGPL") or, at your option, under the terms of the Mozilla
9 * Public License Version 1.1 (the "MPL"). If you do not alter this
10 * notice, a recipient may use your version of this file under either
11 * the MPL or the LGPL.
12 *
13 * You should have received a copy of the LGPL along with this library
14 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
16 * You should have received a copy of the MPL along with this library
17 * in the file COPYING-MPL-1.1
18 *
19 * The contents of this file are subject to the Mozilla Public License
20 * Version 1.1 (the "License"); you may not use this file except in
21 * compliance with the License. You may obtain a copy of the License at
22 * http://www.mozilla.org/MPL/
23 *
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26 * the specific language governing rights and limitations.
27 *
28 * The Original Code is the cairo graphics library.
29 *
30 * The Initial Developer of the Original Code is Intel Corporation.
31 *
32 * Contributors(s):
33 * Chris Wilson <chris@chris-wilson.co.uk>
34 */
35
36#include "cairoint.h"
37#include "cairo-device-private.h"
38#include "cairo-error-private.h"
39
40/**
41 * SECTION:cairo-device
42 * @Title: cairo_device_t
43 * @Short_Description: interface to underlying rendering system
44 * @See_Also: #cairo_surface_t
45 *
46 * Devices are the abstraction Cairo employs for the rendering system
47 * used by a #cairo_surface_t. You can get the device of a surface using
48 * cairo_surface_get_device().
49 *
50 * Devices are created using custom functions specific to the rendering
51 * system you want to use. See the documentation for the surface types
52 * for those functions.
53 *
54 * An important function that devices fulfill is sharing access to the
55 * rendering system between Cairo and your application. If you want to
56 * access a device directly that you used to draw to with Cairo, you must
57 * first call cairo_device_flush() to ensure that Cairo finishes all
58 * operations on the device and resets it to a clean state.
59 *
60 * Cairo also provides the functions cairo_device_acquire() and
61 * cairo_device_release() to synchronize access to the rendering system
62 * in a multithreaded environment. This is done internally, but can also
63 * be used by applications.
64 *
65 * Putting this all together, a function that works with devices should
66 * look something like this:
67 * <informalexample><programlisting>
68 * void
69 * my_device_modifying_function (cairo_device_t *device)
70 * {
71 * cairo_status_t status;
72 *
73 * // Ensure the device is properly reset
74 * cairo_device_flush (device);
75 * // Try to acquire the device
76 * status = cairo_device_acquire (device);
77 * if (status != CAIRO_STATUS_SUCCESS) {
78 * printf ("Failed to acquire the device: %s\n", cairo_status_to_string (status));
79 * return;
80 * }
81 *
82 * // Do the custom operations on the device here.
83 * // But do not call any Cairo functions that might acquire devices.
84 *
85 * // Release the device when done.
86 * cairo_device_release (device);
87 * }
88 * </programlisting></informalexample>
89 *
90 * <note><para>Please refer to the documentation of each backend for
91 * additional usage requirements, guarantees provided, and
92 * interactions with existing surface API of the device functions for
93 * surfaces of that type.
94 * </para></note>
95 **/
96
97static const cairo_device_t _nil_device = {
98 CAIRO_REFERENCE_COUNT_INVALID{((cairo_atomic_int_t) -1)},
99 CAIRO_STATUS_NO_MEMORY,
100};
101
102static const cairo_device_t _mismatch_device = {
103 CAIRO_REFERENCE_COUNT_INVALID{((cairo_atomic_int_t) -1)},
104 CAIRO_STATUS_DEVICE_TYPE_MISMATCH,
105};
106
107static const cairo_device_t _invalid_device = {
108 CAIRO_REFERENCE_COUNT_INVALID{((cairo_atomic_int_t) -1)},
109 CAIRO_STATUS_DEVICE_ERROR,
110};
111
112cairo_device_t *
113_cairo_device_create_in_error (cairo_status_t status)
114{
115 switch (status) {
116 case CAIRO_STATUS_NO_MEMORY:
117 return (cairo_device_t *) &_nil_device;
118 case CAIRO_STATUS_DEVICE_ERROR:
119 return (cairo_device_t *) &_invalid_device;
120 case CAIRO_STATUS_DEVICE_TYPE_MISMATCH:
121 return (cairo_device_t *) &_mismatch_device;
122
123 case CAIRO_STATUS_SUCCESS:
124 case CAIRO_STATUS_LAST_STATUS:
125 ASSERT_NOT_REACHEDdo { ((void) sizeof ((!"reached") ? 1 : 0), __extension__ ({ if
(!"reached") ; else __assert_fail ("!\"reached\"", "/root/firefox-clang/gfx/cairo/cairo/src/cairo-device.c"
, 125, __extension__ __PRETTY_FUNCTION__); })); } while (0)
;
126 /* fall-through */
127 case CAIRO_STATUS_SURFACE_TYPE_MISMATCH:
128 case CAIRO_STATUS_INVALID_STATUS:
129 case CAIRO_STATUS_INVALID_FORMAT:
130 case CAIRO_STATUS_INVALID_VISUAL:
131 case CAIRO_STATUS_READ_ERROR:
132 case CAIRO_STATUS_WRITE_ERROR:
133 case CAIRO_STATUS_FILE_NOT_FOUND:
134 case CAIRO_STATUS_TEMP_FILE_ERROR:
135 case CAIRO_STATUS_INVALID_STRIDE:
136 case CAIRO_STATUS_INVALID_SIZE:
137 case CAIRO_STATUS_INVALID_RESTORE:
138 case CAIRO_STATUS_INVALID_POP_GROUP:
139 case CAIRO_STATUS_NO_CURRENT_POINT:
140 case CAIRO_STATUS_INVALID_MATRIX:
141 case CAIRO_STATUS_NULL_POINTER:
142 case CAIRO_STATUS_INVALID_STRING:
143 case CAIRO_STATUS_INVALID_PATH_DATA:
144 case CAIRO_STATUS_SURFACE_FINISHED:
145 case CAIRO_STATUS_PATTERN_TYPE_MISMATCH:
146 case CAIRO_STATUS_INVALID_DASH:
147 case CAIRO_STATUS_INVALID_DSC_COMMENT:
148 case CAIRO_STATUS_INVALID_INDEX:
149 case CAIRO_STATUS_CLIP_NOT_REPRESENTABLE:
150 case CAIRO_STATUS_FONT_TYPE_MISMATCH:
151 case CAIRO_STATUS_USER_FONT_IMMUTABLE:
152 case CAIRO_STATUS_USER_FONT_ERROR:
153 case CAIRO_STATUS_NEGATIVE_COUNT:
154 case CAIRO_STATUS_INVALID_CLUSTERS:
155 case CAIRO_STATUS_INVALID_SLANT:
156 case CAIRO_STATUS_INVALID_WEIGHT:
157 case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED:
158 case CAIRO_STATUS_INVALID_CONTENT:
159 case CAIRO_STATUS_INVALID_MESH_CONSTRUCTION:
160 case CAIRO_STATUS_DEVICE_FINISHED:
161 case CAIRO_STATUS_JBIG2_GLOBAL_MISSING:
162 case CAIRO_STATUS_PNG_ERROR:
163 case CAIRO_STATUS_FREETYPE_ERROR:
164 case CAIRO_STATUS_WIN32_GDI_ERROR:
165 case CAIRO_STATUS_TAG_ERROR:
166 case CAIRO_STATUS_DWRITE_ERROR:
167 case CAIRO_STATUS_SVG_FONT_ERROR:
168 default:
169 _cairo_error_throw (CAIRO_STATUS_NO_MEMORY)do { cairo_status_t status__ = _cairo_error (CAIRO_STATUS_NO_MEMORY
); (void) status__; } while (0)
;
170 return (cairo_device_t *) &_nil_device;
171 }
172}
173
174void
175_cairo_device_init (cairo_device_t *device,
176 const cairo_device_backend_t *backend)
177{
178 CAIRO_REFERENCE_COUNT_INIT (&device->ref_count, 1)((&device->ref_count)->ref_count = (1));
179 device->status = CAIRO_STATUS_SUCCESS;
180
181 device->backend = backend;
182
183 CAIRO_RECURSIVE_MUTEX_INIT (device->mutex)do { pthread_mutexattr_t attr; pthread_mutexattr_init (&attr
); pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE
); pthread_mutex_init (&(device->mutex), &attr); pthread_mutexattr_destroy
(&attr); } while (0)
;
184 device->mutex_depth = 0;
185
186 device->finished = FALSE0;
187
188 _cairo_user_data_array_init (&device->user_data);
189}
190
191/**
192 * cairo_device_reference:
193 * @device: a #cairo_device_t
194 *
195 * Increases the reference count on @device by one. This prevents
196 * @device from being destroyed until a matching call to
197 * cairo_device_destroy() is made.
198 *
199 * Use cairo_device_get_reference_count() to get the number of references
200 * to a #cairo_device_t.
201 *
202 * Return value: the referenced #cairo_device_t.
203 *
204 * Since: 1.10
205 **/
206cairo_device_t *
207cairo_device_reference_moz_cairo_device_reference (cairo_device_t *device)
208{
209 if (device == NULL((void*)0) ||
210 CAIRO_REFERENCE_COUNT_IS_INVALID (&device->ref_count)(_cairo_atomic_int_get (&(&device->ref_count)->
ref_count) == ((cairo_atomic_int_t) -1))
)
211 {
212 return device;
213 }
214
215 assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&device->ref_count))((void) sizeof (((_cairo_atomic_int_get (&(&device->
ref_count)->ref_count) > 0)) ? 1 : 0), __extension__ ({
if ((_cairo_atomic_int_get (&(&device->ref_count)
->ref_count) > 0)) ; else __assert_fail ("CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&device->ref_count)"
, "/root/firefox-clang/gfx/cairo/cairo/src/cairo-device.c", 215
, __extension__ __PRETTY_FUNCTION__); }))
;
216 _cairo_reference_count_inc (&device->ref_count)((void) __atomic_fetch_add(&(&device->ref_count)->
ref_count, 1, 5))
;
217
218 return device;
219}
220
221/**
222 * cairo_device_status:
223 * @device: a #cairo_device_t
224 *
225 * Checks whether an error has previously occurred for this
226 * device.
227 *
228 * Return value: %CAIRO_STATUS_SUCCESS on success or an error code if
229 * the device is in an error state.
230 *
231 * Since: 1.10
232 **/
233cairo_status_t
234cairo_device_status_moz_cairo_device_status (cairo_device_t *device)
235{
236 if (device == NULL((void*)0))
237 return CAIRO_STATUS_NULL_POINTER;
238
239 return device->status;
240}
241
242/**
243 * cairo_device_flush:
244 * @device: a #cairo_device_t
245 *
246 * Finish any pending operations for the device and also restore any
247 * temporary modifications cairo has made to the device's state.
248 * This function must be called before switching from using the
249 * device with Cairo to operating on it directly with native APIs.
250 * If the device doesn't support direct access, then this function
251 * does nothing.
252 *
253 * This function may acquire devices.
254 *
255 * Since: 1.10
256 **/
257void
258cairo_device_flush_moz_cairo_device_flush (cairo_device_t *device)
259{
260 cairo_status_t status;
261
262 if (device == NULL((void*)0) || device->status)
263 return;
264
265 if (device->finished)
266 return;
267
268 if (device->backend->flush != NULL((void*)0)) {
269 status = device->backend->flush (device);
270 if (unlikely (status)(__builtin_expect (!!(status), 0)))
271 status = _cairo_device_set_error (device, status);
Value stored to 'status' is never read
272 }
273}
274
275/**
276 * cairo_device_finish:
277 * @device: the #cairo_device_t to finish
278 *
279 * This function finishes the device and drops all references to
280 * external resources. All surfaces, fonts and other objects created
281 * for this @device will be finished, too.
282 * Further operations on the @device will not affect the @device but
283 * will instead trigger a %CAIRO_STATUS_DEVICE_FINISHED error.
284 *
285 * When the last call to cairo_device_destroy() decreases the
286 * reference count to zero, cairo will call cairo_device_finish() if
287 * it hasn't been called already, before freeing the resources
288 * associated with the device.
289 *
290 * This function may acquire devices.
291 *
292 * Since: 1.10
293 **/
294void
295cairo_device_finish_moz_cairo_device_finish (cairo_device_t *device)
296{
297 if (device == NULL((void*)0) ||
298 CAIRO_REFERENCE_COUNT_IS_INVALID (&device->ref_count)(_cairo_atomic_int_get (&(&device->ref_count)->
ref_count) == ((cairo_atomic_int_t) -1))
)
299 {
300 return;
301 }
302
303 if (device->finished)
304 return;
305
306 cairo_device_flush_moz_cairo_device_flush (device);
307
308 if (device->backend->finish != NULL((void*)0))
309 device->backend->finish (device);
310
311 /* We only finish the device after the backend's callback returns because
312 * the device might still be needed during the callback
313 * (e.g. for cairo_device_acquire ()).
314 */
315 device->finished = TRUE1;
316}
317
318/**
319 * cairo_device_destroy:
320 * @device: a #cairo_device_t
321 *
322 * Decreases the reference count on @device by one. If the result is
323 * zero, then @device and all associated resources are freed. See
324 * cairo_device_reference().
325 *
326 * This function may acquire devices if the last reference was dropped.
327 *
328 * Since: 1.10
329 **/
330void
331cairo_device_destroy_moz_cairo_device_destroy (cairo_device_t *device)
332{
333 cairo_user_data_array_t user_data;
334
335 if (device == NULL((void*)0) ||
336 CAIRO_REFERENCE_COUNT_IS_INVALID (&device->ref_count)(_cairo_atomic_int_get (&(&device->ref_count)->
ref_count) == ((cairo_atomic_int_t) -1))
)
337 {
338 return;
339 }
340
341 assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&device->ref_count))((void) sizeof (((_cairo_atomic_int_get (&(&device->
ref_count)->ref_count) > 0)) ? 1 : 0), __extension__ ({
if ((_cairo_atomic_int_get (&(&device->ref_count)
->ref_count) > 0)) ; else __assert_fail ("CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&device->ref_count)"
, "/root/firefox-clang/gfx/cairo/cairo/src/cairo-device.c", 341
, __extension__ __PRETTY_FUNCTION__); }))
;
342 if (! _cairo_reference_count_dec_and_test (&device->ref_count)(__atomic_fetch_sub(&(&device->ref_count)->ref_count
, 1, 5) == 1)
)
343 return;
344
345 cairo_device_finish_moz_cairo_device_finish (device);
346
347 assert (device->mutex_depth == 0)((void) sizeof ((device->mutex_depth == 0) ? 1 : 0), __extension__
({ if (device->mutex_depth == 0) ; else __assert_fail ("device->mutex_depth == 0"
, "/root/firefox-clang/gfx/cairo/cairo/src/cairo-device.c", 347
, __extension__ __PRETTY_FUNCTION__); }))
;
348 CAIRO_MUTEX_FINI (device->mutex)pthread_mutex_destroy (&(device->mutex));
349
350 user_data = device->user_data;
351
352 device->backend->destroy (device);
353
354 _cairo_user_data_array_fini (&user_data);
355
356}
357
358/**
359 * cairo_device_get_type:
360 * @device: a #cairo_device_t
361 *
362 * This function returns the type of the device. See #cairo_device_type_t
363 * for available types.
364 *
365 * Return value: The type of @device.
366 *
367 * Since: 1.10
368 **/
369cairo_device_type_t
370cairo_device_get_type_moz_cairo_device_get_type (cairo_device_t *device)
371{
372 if (device == NULL((void*)0) ||
373 CAIRO_REFERENCE_COUNT_IS_INVALID (&device->ref_count)(_cairo_atomic_int_get (&(&device->ref_count)->
ref_count) == ((cairo_atomic_int_t) -1))
)
374 {
375 return CAIRO_DEVICE_TYPE_INVALID;
376 }
377
378 return device->backend->type;
379}
380
381/**
382 * cairo_device_acquire:
383 * @device: a #cairo_device_t
384 *
385 * Acquires the @device for the current thread. This function will block
386 * until no other thread has acquired the device.
387 *
388 * If the return value is %CAIRO_STATUS_SUCCESS, you successfully acquired the
389 * device. From now on your thread owns the device and no other thread will be
390 * able to acquire it until a matching call to cairo_device_release(). It is
391 * allowed to recursively acquire the device multiple times from the same
392 * thread.
393 *
394 * <note><para>You must never acquire two different devices at the same time
395 * unless this is explicitly allowed. Otherwise the possibility of deadlocks
396 * exist.
397 *
398 * As various Cairo functions can acquire devices when called, these functions
399 * may also cause deadlocks when you call them with an acquired device. So you
400 * must not have a device acquired when calling them. These functions are
401 * marked in the documentation.
402 * </para></note>
403 *
404 * Return value: %CAIRO_STATUS_SUCCESS on success or an error code if
405 * the device is in an error state and could not be
406 * acquired. After a successful call to cairo_device_acquire(),
407 * a matching call to cairo_device_release() is required.
408 *
409 * Since: 1.10
410 **/
411cairo_status_t
412cairo_device_acquire_moz_cairo_device_acquire (cairo_device_t *device)
413{
414 if (device == NULL((void*)0))
415 return CAIRO_STATUS_SUCCESS;
416
417 if (unlikely (device->status)(__builtin_expect (!!(device->status), 0)))
418 return device->status;
419
420 if (unlikely (device->finished)(__builtin_expect (!!(device->finished), 0)))
421 return _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_FINISHED);
422
423 CAIRO_MUTEX_LOCK (device->mutex)pthread_mutex_lock (&(device->mutex));
424 if (device->mutex_depth++ == 0) {
425 if (device->backend->lock != NULL((void*)0))
426 device->backend->lock (device);
427 }
428
429 return CAIRO_STATUS_SUCCESS;
430}
431
432/**
433 * cairo_device_release:
434 * @device: a #cairo_device_t
435 *
436 * Releases a @device previously acquired using cairo_device_acquire(). See
437 * that function for details.
438 *
439 * Since: 1.10
440 **/
441void
442cairo_device_release_moz_cairo_device_release (cairo_device_t *device)
443{
444 if (device == NULL((void*)0))
445 return;
446
447 assert (device->mutex_depth > 0)((void) sizeof ((device->mutex_depth > 0) ? 1 : 0), __extension__
({ if (device->mutex_depth > 0) ; else __assert_fail (
"device->mutex_depth > 0", "/root/firefox-clang/gfx/cairo/cairo/src/cairo-device.c"
, 447, __extension__ __PRETTY_FUNCTION__); }))
;
448
449 if (--device->mutex_depth == 0) {
450 if (device->backend->unlock != NULL((void*)0))
451 device->backend->unlock (device);
452 }
453
454 CAIRO_MUTEX_UNLOCK (device->mutex)pthread_mutex_unlock (&(device->mutex));
455}
456
457cairo_status_t
458_cairo_device_set_error (cairo_device_t *device,
459 cairo_status_t status)
460{
461 if (status == CAIRO_STATUS_SUCCESS)
462 return CAIRO_STATUS_SUCCESS;
463
464 _cairo_status_set_error (&device->status, status)do { int ret__; ((void) sizeof ((status < CAIRO_STATUS_LAST_STATUS
) ? 1 : 0), __extension__ ({ if (status < CAIRO_STATUS_LAST_STATUS
) ; else __assert_fail ("status < CAIRO_STATUS_LAST_STATUS"
, "/root/firefox-clang/gfx/cairo/cairo/src/cairo-device.c", 464
, __extension__ __PRETTY_FUNCTION__); })); ((void) sizeof ((sizeof
(*&device->status) == sizeof(cairo_atomic_int_t)) ? 1 :
0), __extension__ ({ if (sizeof(*&device->status) == sizeof
(cairo_atomic_int_t)) ; else __assert_fail ("sizeof(*&device->status) == sizeof(cairo_atomic_int_t)"
, "/root/firefox-clang/gfx/cairo/cairo/src/cairo-device.c", 464
, __extension__ __PRETTY_FUNCTION__); })); ret__ = _cairo_atomic_int_cmpxchg_impl
((cairo_atomic_int_t *) &device->status, CAIRO_STATUS_SUCCESS
, status); (void) ret__; } while (0)
;
465
466 return _cairo_error (status);
467}
468
469/**
470 * cairo_device_get_reference_count:
471 * @device: a #cairo_device_t
472 *
473 * Returns the current reference count of @device.
474 *
475 * Return value: the current reference count of @device. If the
476 * object is a nil object, 0 will be returned.
477 *
478 * Since: 1.10
479 **/
480unsigned int
481cairo_device_get_reference_count_moz_cairo_device_get_reference_count (cairo_device_t *device)
482{
483 if (device == NULL((void*)0) ||
484 CAIRO_REFERENCE_COUNT_IS_INVALID (&device->ref_count)(_cairo_atomic_int_get (&(&device->ref_count)->
ref_count) == ((cairo_atomic_int_t) -1))
)
485 return 0;
486
487 return CAIRO_REFERENCE_COUNT_GET_VALUE (&device->ref_count)_cairo_atomic_int_get (&(&device->ref_count)->ref_count
)
;
488}
489
490/**
491 * cairo_device_get_user_data:
492 * @device: a #cairo_device_t
493 * @key: the address of the #cairo_user_data_key_t the user data was
494 * attached to
495 *
496 * Return user data previously attached to @device using the
497 * specified key. If no user data has been attached with the given
498 * key this function returns %NULL.
499 *
500 * Return value: the user data previously attached or %NULL.
501 *
502 * Since: 1.10
503 **/
504void *
505cairo_device_get_user_data_moz_cairo_device_get_user_data (cairo_device_t *device,
506 const cairo_user_data_key_t *key)
507{
508 return _cairo_user_data_array_get_data (&device->user_data,
509 key);
510}
511
512/**
513 * cairo_device_set_user_data:
514 * @device: a #cairo_device_t
515 * @key: the address of a #cairo_user_data_key_t to attach the user data to
516 * @user_data: the user data to attach to the #cairo_device_t
517 * @destroy: a #cairo_destroy_func_t which will be called when the
518 * #cairo_t is destroyed or when new user data is attached using the
519 * same key.
520 *
521 * Attach user data to @device. To remove user data from a surface,
522 * call this function with the key that was used to set it and %NULL
523 * for @data.
524 *
525 * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY if a
526 * slot could not be allocated for the user data.
527 *
528 * Since: 1.10
529 **/
530cairo_status_t
531cairo_device_set_user_data_moz_cairo_device_set_user_data (cairo_device_t *device,
532 const cairo_user_data_key_t *key,
533 void *user_data,
534 cairo_destroy_func_t destroy)
535{
536 if (CAIRO_REFERENCE_COUNT_IS_INVALID (&device->ref_count)(_cairo_atomic_int_get (&(&device->ref_count)->
ref_count) == ((cairo_atomic_int_t) -1))
)
537 return device->status;
538
539 return _cairo_user_data_array_set_data (&device->user_data,
540 key, user_data, destroy);
541}