From: Rusty Russell <rusty@rustcorp.com.au>
To: George Spelvin <linux@horizon.com>,
akpm@linux-foundation.org, linux@horizon.com
Cc: linux-kernel@vger.kernel.org, rdunlap@infradead.org
Subject: Re: [PATCH v2] VERIFY_OCTAL_PERMISSIONS: Move to <linux/sysfs.h> where it belongs
Date: Mon, 15 Dec 2014 14:26:15 +1030 [thread overview]
Message-ID: <87egs1d0rk.fsf@rustcorp.com.au> (raw)
In-Reply-To: <20141206032310.27123.qmail@ns.horizon.com>
George Spelvin <linux@horizon.com> writes:
> It's the only user of <linux/bug.h> in kernel.h, so that reduces
> the compile-time cost of #include <linux/kernel.h>
>
> Only one user has to change: <linux/moduleparam.h>. The <linux/types.h>
> there is needed for one function prototype that passes s16 parameters.
> My first reaction is to wonder if that can be gotten rid of, too.
>
> Some other extraneous header files pruned while I was at it.
> Tested with allyesconfig & allmodconfig on x86-64, just to
> be sure.
>
> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: George Spelvin <linux@horizon.com>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Thanks,
Rusty.
> ---
> Look, even more header pruning.
>
> include/linux/kernel.h | 10 ----------
> include/linux/moduleparam.h | 4 ++--
> include/linux/sysfs.h | 15 ++++++++++++---
> 3 files changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 3d770f55..07080aa2 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -804,14 +804,4 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
> # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
> #endif
>
> -/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */
> -#define VERIFY_OCTAL_PERMISSIONS(perms) \
> - (BUILD_BUG_ON_ZERO((perms) < 0) + \
> - BUILD_BUG_ON_ZERO((perms) > 0777) + \
> - /* User perms >= group perms >= other perms */ \
> - BUILD_BUG_ON_ZERO(((perms) >> 6) < (((perms) >> 3) & 7)) + \
> - BUILD_BUG_ON_ZERO((((perms) >> 3) & 7) < ((perms) & 7)) + \
> - /* Other writable? Generally considered a bad idea. */ \
> - BUILD_BUG_ON_ZERO((perms) & 2) + \
> - (perms))
> #endif
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> index 1c9effa2..974097df 100644
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -1,9 +1,9 @@
> #ifndef _LINUX_MODULE_PARAMS_H
> #define _LINUX_MODULE_PARAMS_H
> /* (C) Copyright 2001, 2002 Rusty Russell IBM Corporation */
> -#include <linux/init.h>
> #include <linux/stringify.h>
> -#include <linux/kernel.h>
> +#include <linux/sysfs.h>
> +#include <linux/types.h>
>
> /* You can override this manually, but generally this should match the
> module name. */
> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
> index f97d0dbb..3562f331 100644
> --- a/include/linux/sysfs.h
> +++ b/include/linux/sysfs.h
> @@ -14,12 +14,10 @@
>
> #include <linux/kernfs.h>
> #include <linux/compiler.h>
> -#include <linux/errno.h>
> -#include <linux/list.h>
> #include <linux/lockdep.h>
> #include <linux/kobject_ns.h>
> #include <linux/stat.h>
> -#include <linux/atomic.h>
> +#include <linux/bug.h>
>
> struct kobject;
> struct module;
> @@ -70,6 +68,17 @@ struct attribute_group {
> * for examples..
> */
>
> +/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */
> +#define VERIFY_OCTAL_PERMISSIONS(perms) \
> + (BUILD_BUG_ON_ZERO((perms) < 0) + \
> + BUILD_BUG_ON_ZERO((perms) > 0777) + \
> + /* User perms >= group perms >= other perms */ \
> + BUILD_BUG_ON_ZERO(((perms) >> 6) < (((perms) >> 3) & 7)) + \
> + BUILD_BUG_ON_ZERO((((perms) >> 3) & 7) < ((perms) & 7)) + \
> + /* Other writable? Generally considered a bad idea. */ \
> + BUILD_BUG_ON_ZERO((perms) & 2) + \
> + (perms))
> +
> #define __ATTR(_name, _mode, _show, _store) { \
> .attr = {.name = __stringify(_name), \
> .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
> --
> 2.1.3
next prev parent reply other threads:[~2014-12-15 19:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-06 0:07 [PATCH] VERIFY_OCTAL_PERMISSIONS needs <linux/bug.h> George Spelvin
2014-12-06 0:12 ` Randy Dunlap
2014-12-06 0:15 ` Andrew Morton
2014-12-06 1:18 ` [PATCH] [PATCH] VERIFY_OCTAL_PERMISSIONS: Move to <linux/sysfs.h> where it belongs George Spelvin
2014-12-06 1:28 ` Andrew Morton
2014-12-06 2:49 ` George Spelvin
2014-12-06 2:53 ` Joe Perches
2014-12-06 2:57 ` Jeff Kirsher
2014-12-06 2:58 ` Andrew Morton
2014-12-06 3:23 ` [PATCH v2] " George Spelvin
2014-12-15 3:56 ` Rusty Russell [this message]
2014-12-15 23:09 ` Stephen Rothwell
2014-12-16 0:14 ` George Spelvin
2014-12-16 0:31 ` Stephen Rothwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87egs1d0rk.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@horizon.com \
--cc=rdunlap@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.