[gdk-pixbuf] loaders: Remove "error && *error == NULL" checks
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] loaders: Remove "error && *error == NULL" checks
- Date: Thu, 13 Jul 2017 16:54:28 +0000 (UTC)
commit 3b76db03bdd9c1cbc31a2bb812b24d0e7abdb5c9
Author: Bastien Nocera <hadess hadess net>
Date: Thu Jul 13 18:53:26 2017 +0200
loaders: Remove "error && *error == NULL" checks
g_set_error() and friends already do those checks.
gdk-pixbuf/io-bmp.c | 10 +++-----
gdk-pixbuf/io-jpeg.c | 26 ++++++++++--------------
gdk-pixbuf/io-png.c | 51 +++++++++++++++++++------------------------------
3 files changed, 35 insertions(+), 52 deletions(-)
---
diff --git a/gdk-pixbuf/io-bmp.c b/gdk-pixbuf/io-bmp.c
index 6460e7f..9ba3597 100644
--- a/gdk-pixbuf/io-bmp.c
+++ b/gdk-pixbuf/io-bmp.c
@@ -746,12 +746,10 @@ static gboolean gdk_pixbuf__bmp_image_stop_load(gpointer data, GError **error)
g_object_unref(context->pixbuf);
if (context->read_state == READ_STATE_HEADERS) {
- if (error && *error == NULL) {
- g_set_error_literal (error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
- _("Premature end-of-file encountered"));
- }
+ g_set_error_literal (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ _("Premature end-of-file encountered"));
retval = FALSE;
}
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c
index 1c0eba1..05ca959 100644
--- a/gdk-pixbuf/io-jpeg.c
+++ b/gdk-pixbuf/io-jpeg.c
@@ -701,14 +701,12 @@ gdk_pixbuf__jpeg_image_load (FILE *f, GError **error)
default:
g_object_unref (pixbuf);
pixbuf = NULL;
- if (error && *error == NULL) {
- g_set_error (error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
- _("Unsupported JPEG color space (%s)"),
- colorspace_name (cinfo.out_color_space));
- }
- goto out;
+ g_set_error (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
+ _("Unsupported JPEG color space (%s)"),
+ colorspace_name (cinfo.out_color_space));
+ goto out;
}
}
@@ -914,13 +912,11 @@ gdk_pixbuf__jpeg_image_load_lines (JpegProgContext *context,
convert_cmyk_to_rgb (cinfo, lines);
break;
default:
- if (error && *error == NULL) {
- g_set_error (error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
- _("Unsupported JPEG color space (%s)"),
- colorspace_name (cinfo->out_color_space));
- }
+ g_set_error (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
+ _("Unsupported JPEG color space (%s)"),
+ colorspace_name (cinfo->out_color_space));
return FALSE;
}
diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c
index 759e78a..72bd78a 100644
--- a/gdk-pixbuf/io-png.c
+++ b/gdk-pixbuf/io-png.c
@@ -312,13 +312,10 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, ctype & PNG_COLOR_MASK_ALPHA, 8, w, h);
if (!pixbuf) {
- if (error && *error == NULL) {
- g_set_error_literal (error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
- _("Insufficient memory to load PNG file"));
- }
-
+ g_set_error_literal (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+ _("Insufficient memory to load PNG file"));
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return NULL;
@@ -526,11 +523,9 @@ gdk_pixbuf__png_image_stop_load (gpointer context, GError **error)
if (lc->pixbuf)
g_object_unref (lc->pixbuf);
else {
- if (error && *error == NULL) {
- g_set_error_literal (error, GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
- _("Premature end-of-file encountered"));
- }
+ g_set_error_literal (error, GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ _("Premature end-of-file encountered"));
retval = FALSE;
}
@@ -665,12 +660,10 @@ png_info_callback (png_structp png_read_ptr,
if (w == 0 || h == 0) {
lc->fatal_error_occurred = TRUE;
- if (lc->error && *lc->error == NULL) {
- g_set_error_literal (lc->error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_FAILED,
- _("Transformed PNG has zero width or height."));
- }
+ g_set_error_literal (lc->error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_FAILED,
+ _("Transformed PNG has zero width or height."));
return;
}
}
@@ -680,13 +673,11 @@ png_info_callback (png_structp png_read_ptr,
if (lc->pixbuf == NULL) {
/* Failed to allocate memory */
lc->fatal_error_occurred = TRUE;
- if (lc->error && *lc->error == NULL) {
- g_set_error (lc->error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
- _("Insufficient memory to store a %lu by %lu image; try exiting some
applications to reduce memory usage"),
- (gulong) width, (gulong) height);
- }
+ g_set_error (lc->error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+ _("Insufficient memory to store a %lu by %lu image; try exiting some
applications to reduce memory usage"),
+ (gulong) width, (gulong) height);
return;
}
@@ -758,12 +749,10 @@ png_row_callback (png_structp png_read_ptr,
if (row_num >= lc->pixbuf->height) {
lc->fatal_error_occurred = TRUE;
- if (lc->error && *lc->error == NULL) {
- g_set_error_literal (lc->error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
- _("Fatal error reading PNG image file"));
- }
+ g_set_error_literal (lc->error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ _("Fatal error reading PNG image file"));
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]