HomeClusterLabs Projects

Log: various: best practices for bit setting/clearing functions

Description

Log: various: best practices for bit setting/clearing functions

This renames crm_clear_bit() and crm_set_bit() to follow current guidelines,
tweaks them for better logging, and moves them from crm_internal.h to
crm/common/internal.h to minimize what we keep in crm_internal.h.

The intent is a new model for bit flags:

  • They will be consistently referred to as a "flag group" of "flags" rather than a bitmask, mask, or word of bits, for readability and consistency.
  • The naming now makes it clear that multiple flags may be set or cleared.
  • set_bit() and clear_bit() are now deprecated, though still used as of this commit. The goal is to define object-specific wrappers instead, similar to pe_set_action_bit()/pe_clear_action_bit().

As of this commit, the logging improvement is to change something like:

Bit 0x00010000 for some_action_id set by some_function:100

to:

Action flags 0x00010000 (pe_action_dc) for some_action_id set by some_function:100

The wrappers such as pe_set_action_bit() and pe_clear_action_bit() will be kept
as macros, so they work with bitmasks of any length, and so we can use
stringification to put a readable description of the flags in the log message.
The latter means that the message will be more useful when set to a named
constant like pe_action_dc than a variable like "flags", but we use constants
often enough to make it useful.

Details

Provenance
kgaillotAuthored on Jun 25 2020, 2:20 PM
Parents
rP643f19b71e9f: Merge pull request #2146 from kgaillot/scheduler
Branches
Unknown
Tags
Unknown

Event Timeline