GNOME Bugzilla – Bug 755046
gfileutils: Add precondition checks to g_file_test()
Last modified: 2017-04-08 05:16:24 UTC
Trivial patch attached.
Created attachment 311334 [details] [review] gfileutils: Add precondition checks to g_file_test() Otherwise g_file_test(NULL, …) causes a call to access(NULL, …) on Linux, which is disallowed and valgrind complains about it.
I'm not a huge fan of slapping these onto everything. A != NULL check really adds very little, and it is not free.
(In reply to Matthias Clasen from comment #2) > A != NULL check really adds very little It adds a runtime warning message when the programmer does something bad, and a convenient way of breaking on the error with G_DEBUG=fatal-warnings. > and it is not free. Isn’t that what G_DISABLE_CHECKS is for?
(In reply to Philip Withnall from comment #3) > Isn’t that what G_DISABLE_CHECKS is for? G_DISABLE_CHECKS disables _all_ runtime checks. The useless ones and the useful ones. Thats not an excuse for adding more and more useless ones...
(In reply to Matthias Clasen from comment #4) > (In reply to Philip Withnall from comment #3) > > > Isn’t that what G_DISABLE_CHECKS is for? > > G_DISABLE_CHECKS disables _all_ runtime checks. The useless ones and the > useful ones. Thats not an excuse for adding more and more useless ones... Then what’s the point in G_DISABLE_CHECKS? Runtime checks should never fail; if one does, that’s a programming error. As I understand it, if someone cares about runtime performance, they should set G_DISABLE_CHECKS for their release builds, and keep it unset for development builds.
Review of attachment 311334 [details] [review]: Sure
Attachment 311334 [details] pushed as a5b58da - gfileutils: Add precondition checks to g_file_test()