GNOME Bugzilla – Bug 754026
gfileutils: add some sanity checks
Last modified: 2017-10-05 12:43:56 UTC
While developing an app using glib, I ended up with some spurious segfault due to the fact I was passing uninitialized and non-null GError to g_dir_make_tmp() function. To avoid programming errors with this function, I propose to add a sanity check.
Created attachment 309923 [details] [review] gfileutils: add some sanity checks To avoid handling non-null GError or NULL filename in some fileutils functions.
not really in favour of littering the code with these
Created attachment 310332 [details] [review] gfileutils: add some sanity checks Update to fix compiler warning about mixing code an declaration.
(In reply to Matthias Clasen from comment #2) > not really in favour of littering the code with these Some other functions in this file, and more generally in GLib, check bad input parameters (GError, strings...). So I think an user can expect GLib functions to tell him when he is doing wrong. It's also make usage of GLib more coherent in my opinion.
I”ve updated this to apply cleanly to master, and to s/FALSE/-1/ one of the precondition failure return values (to match the function documentation). If people are worried about the performance impact of this, they should be compiling GLib with G_DISABLE_CHECKS to disable all precondition checks. The presence of precondition checks helps developers diagnose failures, and provides hints to static analysis tools. Attachment 310332 [details] pushed as 21d2c64 - gfileutils: add some sanity checks