Page MenuHome

Code Quality: Let GHash/GSet comparison callbacks return true on equality, not false
Confirmed, NormalPublicTO DO


For historical reasons (compatibility with C library compare functions such as strcmp), the comparison functions of GHash (GHashCmpFP) and GSet (GSetCmpFP) are expected to return false if the items match, not true.
This is confusing and unintuitive and in fact has led to bugs in the past, where this was done the wrong way around: rBf2b86471eaa4

What needs to be done

  • Code using the compare functions has to be corrected.
  • Comments needs to be updated.
  • All comparison callbacks have to be updated. (This is the biggest part of the work.)
  • Make sure the individual comparison callbacks are not used for other logic. If so, that needs to be updated.

Event Timeline

I feel you can go further here and rename the callbacks them selves to be more indicative of the type and expected behavior, ie GHashCompareEqualityCallback over GHashCmpFP

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Needs Information from Developers.Feb 16 2022, 4:35 PM

Not sure if this is still in the decision phase?
Will change status since there is probably not much the Triaging team can do here.

Bastien Montagne (mont29) changed the task status from Needs Information from Developers to Confirmed.Feb 16 2022, 4:54 PM