Page MenuHomeFreeBSD

siftr: replace macro constants with debug friendly enums
Needs ReviewPublic

Authored by cc on Mon, Mar 30, 8:53 AM.

Details

Reviewers
rscheff
tuexen
Test Plan

no functional change

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 71811
Build 68694: arc lint + arc unit

Event Timeline

cc requested review of this revision.Mon, Mar 30, 8:53 AM

I think arbitrary unrelated constants should not be put into a single enum.

I think arbitrary unrelated constants should not be put into a single enum.

Here, the use-case is not for a group of meaning related constants under a new identifier like enum color {red, green, blue,};.
It's anonymous. It's more like define enum SIFTR_CONSTS {HOOK = 0, UNHOOK = 1, SIFTR_DISABLE = 0, ...};, without the identifier SIFTR_CONSTS.

I understand that this helps with debugging, as ENUMs get printed as symbols. However, since these are, as Michael points out, quite unrelated to each other, and defining multiple enum identifiers may help catch incorrect assignments by the compiler, why not split the ENUM up into multiple, independently identified enums, still with explicit assignments?

The variables holding these enums can (should) be redefined as the corresponding enum type, thus possibly catching incorrect assignments - and helping which constant goes where.