"ZheNing Hu via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: > the enum value of `ATOM_UNKNOWN` is equals to zero, which s/the/The/; > could ensure that we can easily distinguish such a struct > where the atom_type is known from such a struct where it > is unknown yet. > > the enum value of `ATOM_INVALID` is equals to the size of Ditto. > +/* > + * The enum atom_type is used as the coordinates of valid_atom entry. > + * In the atom parsing stage, it will be passed to used_atom.atom_type > + * as the identifier of the atom type. We can judge the type of used_atom > + * entry by `if (used_atom[i].atom_type == ATOM_*)`. > + * > + * ATOM_UNKNOWN equals to 0, used as an enumeration value of uninitialized > + * atom_type. Shouldn't it be (-1)? And I'd assume I am right in the following. > + * ATOM_INVALID equals to the size of valid_atom array, which could help us > + * iterate over valid_atom array like this: > + * > + * for (i = ATOM_UNKNOWN + 1; i < ATOM_INVALID; i++) { I find it far more intuitive to say for (i = 0; i < ATOM_INVALID; i++) than having to say UNKNOWN+1. In any case, the values should be indented, and a comment should ensure that the final one stays at the end, perhaps like this. enum atom_type { ATOM_INVALID = -2, ATOM_UNKNOWN = -1, ATOM_REFNAME, ... ATOM_ELSE, ATOM_MAX /* MUST BE AT THE END */ } (note that the trailing comma is deliberately omitted). It would allow people to say for (i = 0; i < ATOM_MAX; i++) instead, which would be even nicer.