From mboxrd@z Thu Jan 1 00:00:00 1970 From: Djalal Harouni Subject: Re: [PATCH 1/9] procfs: use flags to deny or allow access to /proc//$entry Date: Tue, 27 May 2014 14:42:18 +0100 Message-ID: <20140527134218.GB3148@dztty> References: <1401110850-3552-1-git-send-email-tixxdz@opendz.org> <1401110850-3552-2-git-send-email-tixxdz@opendz.org> <20140526172101.GA6380@dztty> <20140526191353.GB6887@dztty> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Kees Cook , Andrew Morton , Alexey Dobriyan , "Eric W. Biederman" , Al Viro , Linus Torvalds , Ingo Molnar , Oleg Nesterov , Peter Zijlstra , LKML , Linux FS Devel To: Andy Lutomirski Return-path: Received: from numidia.opendz.org ([98.142.220.152]:58007 "EHLO numidia.opendz.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752367AbaE0NmW (ORCPT ); Tue, 27 May 2014 09:42:22 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, May 26, 2014 at 12:17:48PM -0700, Andy Lutomirski wrote: > On Mon, May 26, 2014 at 12:13 PM, Djalal Harouni 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 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