Re: [PATCH 1/9] procfs: use flags to deny or allow access to /proc/<pid>/$entry

From: Djalal Harouni
Date: Tue May 27 2014 - 09:42:29 EST


On Mon, May 26, 2014 at 12:17:48PM -0700, Andy Lutomirski wrote:
> On Mon, May 26, 2014 at 12:13 PM, Djalal Harouni <tixxdz@xxxxxxxxxx> wrote:
> > On Mon, May 26, 2014 at 11:06:40AM -0700, Andy Lutomirski wrote:
> >> On Mon, May 26, 2014 at 10:21 AM, Djalal Harouni <tixxdz@xxxxxxxxxx> wrote:
> >> > I would like to keep it enum, enum is type-safe and I want to follow the
> >> > semantics of /proc/pid/stat and others:
> >>
> >> It's not type-safe the way you're doing it, though.
> > Can you please shed some light Andy, thank you in advance!
>
> You're casting these things back and forth. If you were storing enum
> values in an enum-typed variable, great, but you're not.
Ok I see your point! Yes, but AFAIK in this case it's perfectly safe!

We don't use large values, the one used here can be represented as an
int, and later we cast them to unsigned long to make sure that we are
using the correct value and the correct size of a pointer.

GCC is able to warn in this case of any appropriate cast:
-Wpointer-to-int-cast ...

And from Documentation/CodingStyle:
"Enums are preferred when defining several related constants."

Perhaps I'm missing something!

> --Andy

--
Djalal Harouni
http://opendz.org
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/