Hello freeipmi developers,

Looking at common/miscutil/hostlist.c I was rather surprised to see code of
the form:

assert((i->magic = 0x1));

At a glance, my first thought was that it was an error.

Upon looking closer, I see that the 'int magic' members of the structs are
guarded by "#ifndef NDEBUG" and came to understand two things.
First, the assert() is being used to turn the assignment into a no-op
unless debug.
Second, the value of "0x1" instead of "0x0" is chosen to avoid assert
failure.

While this works, I found it jarring and I expect other developers may also
"get tripped up" by it.

Would you be open to a contribution which would make the conditional
assignment more explicit?

Perhaps something simply along the lines of:

#define hostlist_magic_set(s) assert(((s)->magic = HOSTLIST_MAGIC))
#define hostlist_magic_unset(s) assert(((s)->magic = 0x1))

If so, are there contribution instructions or other contribution guidelines
I should follow?
Or should I simply send a patch to this list?

Cheers,
-Eric

Reply via email to