Code Quality: Let GHash/GSet comparison callbacks return true on equality, not false #91870

Open
opened 2021-10-01 12:53:39 +02:00 by Julian Eisel · 7 comments
Member

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: f2b86471ea

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.
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: f2b86471ea ### 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.
Author
Member

Added subscriber: @JulianEisel

Added subscriber: @JulianEisel
Member

Added subscriber: @LazyDodo

Added subscriber: @LazyDodo
Member

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
.

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` .
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
Member

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.

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.

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'
Philipp Oeser removed the
Interest
Core
label 2023-02-09 14:42:54 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#91870
No description provided.