After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 640975 - Check that error exists before trying to set it
Check that error exists before trying to set it
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-01-30 23:06 UTC by Ignacio Casal Quinteiro (nacho)
Modified: 2011-09-18 00:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
error (867 bytes, patch)
2011-01-30 23:06 UTC, Ignacio Casal Quinteiro (nacho)
committed Details | Review
error v2 (1.71 KB, patch)
2011-01-31 14:18 UTC, Ignacio Casal Quinteiro (nacho)
none Details | Review
error v3 (1.74 KB, patch)
2011-02-01 09:13 UTC, Ignacio Casal Quinteiro (nacho)
none Details | Review
Remove redundant checks (2.19 KB, patch)
2011-09-18 00:28 UTC, Matthias Clasen
committed Details | Review

Description Ignacio Casal Quinteiro (nacho) 2011-01-30 23:06:54 UTC
Created attachment 179658 [details] [review]
error

See the patch.
Comment 1 Ignacio Casal Quinteiro (nacho) 2011-01-31 12:34:21 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
Comment 2 Christian Persch 2011-01-31 14:13:52 UTC
-              {
-                int errsv = errno;
-                
-                g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED,
-                             _("Error during conversion: %s"),
-                             g_strerror (errsv));
-              }
+	      if (error)
+                {
+                  int errsv = errno;
+
+                  g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED,
+                               _("Error during conversion: %s"),
+                               g_strerror (errsv));
+                }

What exactly was the bug here? g_set_error already checks whether error is NULL, so as far as I can see, this change is unnecessary?
Comment 3 Ignacio Casal Quinteiro (nacho) 2011-01-31 14:16:32 UTC
well, this was added to keep concordance with the other cases, but you are right, didn't know it was already checked. I guess the right solution here should be to remove the if (error) check in all places in this function.
Comment 4 Ignacio Casal Quinteiro (nacho) 2011-01-31 14:18:50 UTC
Created attachment 179720 [details] [review]
error v2

See that it was already doing this check everywhere.
Comment 5 Ignacio Casal Quinteiro (nacho) 2011-02-01 09:13:53 UTC
Created attachment 179773 [details] [review]
error v3

Minor fix
Comment 6 Matthias Clasen 2011-09-18 00:28:44 UTC
The following fix has been pushed:
7b9571e Remove redundant checks
Comment 7 Matthias Clasen 2011-09-18 00:28:47 UTC
Created attachment 196857 [details] [review]
Remove redundant checks

g_set_error() handles error == NULL, so no need to check.
Patch by Ignacio Casal Quinteiro.