diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2007-10-04 13:15:46 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2007-10-04 13:31:44 +0100 |
commit | bed8239f03773ad1584c8ba48ceb0b34bbe69453 (patch) | |
tree | fb97a0cd4874f4fd4a2b22d6ec882a77f04202da /src/cairo-unicode.c | |
parent | d90d4bb6b99e0a912650234e28d097ea76c1cecc (diff) | |
download | cairo-bed8239f03773ad1584c8ba48ceb0b34bbe69453.tar.gz |
[cairo-error] Clean up all the warnings and missing _cairo_error() calls.
Every time we assign or return a hard-coded error status wrap that value
with a call to _cairo_error(). So the idiom becomes:
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
or
return _cairo_error (CAIRO_STATUS_INVALID_DASH);
This ensures that a breakpoint placed on _cairo_error() will trigger
immediately cairo detects the error.
Diffstat (limited to 'src/cairo-unicode.c')
-rw-r--r-- | src/cairo-unicode.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/cairo-unicode.c b/src/cairo-unicode.c index 8ee6d246a..2b224a3ab 100644 --- a/src/cairo-unicode.c +++ b/src/cairo-unicode.c @@ -231,20 +231,18 @@ _cairo_utf8_to_ucs4 (const unsigned char *str, { uint32_t wc = _utf8_get_char_extended (in, str + len - in); if (wc & 0x80000000 || !UNICODE_VALID (wc)) - return CAIRO_STATUS_INVALID_STRING; + return _cairo_error (CAIRO_STATUS_INVALID_STRING); n_chars++; if (n_chars == INT_MAX) - return CAIRO_STATUS_INVALID_STRING; + return _cairo_error (CAIRO_STATUS_INVALID_STRING); in = UTF8_NEXT_CHAR (in); } str32 = _cairo_malloc_ab (n_chars + 1, sizeof (uint32_t)); - if (!str32) { - _cairo_error (CAIRO_STATUS_NO_MEMORY); - return CAIRO_STATUS_NO_MEMORY; - } + if (!str32) + return _cairo_error (CAIRO_STATUS_NO_MEMORY); in = str; for (i=0; i < n_chars; i++) { @@ -296,7 +294,7 @@ _cairo_utf8_to_utf16 (const unsigned char *str, while ((len < 0 || str + len - in > 0) && *in) { uint32_t wc = _utf8_get_char_extended (in, str + len - in); if (wc & 0x80000000 || !UNICODE_VALID (wc)) - return CAIRO_STATUS_INVALID_STRING; + return _cairo_error (CAIRO_STATUS_INVALID_STRING); if (wc < 0x10000) n16 += 1; @@ -304,16 +302,14 @@ _cairo_utf8_to_utf16 (const unsigned char *str, n16 += 2; if (n16 == INT_MAX - 1 || n16 == INT_MAX) - return CAIRO_STATUS_INVALID_STRING; + return _cairo_error (CAIRO_STATUS_INVALID_STRING); in = UTF8_NEXT_CHAR (in); } str16 = _cairo_malloc_ab (n16 + 1, sizeof (uint16_t)); - if (!str16) { - _cairo_error (CAIRO_STATUS_NO_MEMORY); - return CAIRO_STATUS_NO_MEMORY; - } + if (!str16) + return _cairo_error (CAIRO_STATUS_NO_MEMORY); in = str; for (i = 0; i < n16;) { |