Re: [PATCH RESEND] KEYS: fix parsing invalid pkey info string

From: Linus Torvalds
Date: Mon Dec 17 2018 - 15:31:56 EST


On Mon, Dec 17, 2018 at 12:21 PM Mimi Zohar <zohar@xxxxxxxxxxxxx> wrote:
>
> It's being used for parsing and displaying the policy, which do need
> to be in sync.

Yes, but it needs a comment somewhere.

Also, the way you use those enums as array indices also implies that
for your case, Opt_err should definitely not be -1, and it should
instead be at the *end* of the enum list (the same way it's at the end
of the array).

That would also automatically mean that "Opt_measure" would have value
0, and the pl(token) macro shouldn't need any offsetting at all,
because the enums and the array indices just automatically match up
(as long as they are always updated together!)

Linus