All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] proc: proc_create() should return true if CONFIG_PROC_FS is not configured
@ 2015-02-25  5:14 Zhang Zhaolong
  2015-02-25  7:48 ` Jonathon Reinhart
  0 siblings, 1 reply; 5+ messages in thread
From: Zhang Zhaolong @ 2015-02-25  5:14 UTC (permalink / raw)
  To: davem; +Cc: netdev, viro, dhowells, Zhang Zhaolong

proc_create() should return true if CONFIG_PROC_FS is not configured.
Otherwise if-statement like this "if (!proc_create())" would go to the false path.

Signed-off-by: Zhang Zhaolong <zhangzl2013@126.com>
---
 include/linux/proc_fs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index b97bf2e..1fc07b9 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -60,8 +60,8 @@ static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
 	umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
 static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
 	umode_t mode, struct proc_dir_entry *parent) { return NULL; }
-#define proc_create(name, mode, parent, proc_fops) ({NULL;})
-#define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;})
+#define proc_create(name, mode, parent, proc_fops) ({ 1; })
+#define proc_create_data(name, mode, parent, proc_fops, data) ({ 1; })
 
 static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
 static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] proc: proc_create() should return true if CONFIG_PROC_FS is not configured
  2015-02-25  5:14 [PATCH] proc: proc_create() should return true if CONFIG_PROC_FS is not configured Zhang Zhaolong
@ 2015-02-25  7:48 ` Jonathon Reinhart
  2015-02-25 11:19   ` David Howells
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathon Reinhart @ 2015-02-25  7:48 UTC (permalink / raw)
  To: Zhang Zhaolong; +Cc: David S. Miller, Linux Netdev List, viro, dhowells

On Wed, Feb 25, 2015 at 12:14 AM, Zhang Zhaolong <zhangzl2013@126.com> wrote:
>
> proc_create() should return true if CONFIG_PROC_FS is not configured.
> Otherwise if-statement like this "if (!proc_create())" would go to the false path.

Does that even compile? proc_create() and proc_create_data() both return
"struct proc_dir_entry *". It doesn't make sense for those macros to "return"
anything but NULL - certainly not 1.

Besides, why shouldn't "if (!proc_create())" behave like proc_create()
failed when
CONFIG_PROC_FS is not enabled?  You wouldn't want the caller to start trying
to use that ((struct proc_dir_entry *)1) would you?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] proc: proc_create() should return true if CONFIG_PROC_FS is not configured
  2015-02-25  7:48 ` Jonathon Reinhart
@ 2015-02-25 11:19   ` David Howells
  2015-02-25 21:22     ` Jonathon Reinhart
  0 siblings, 1 reply; 5+ messages in thread
From: David Howells @ 2015-02-25 11:19 UTC (permalink / raw)
  To: Jonathon Reinhart
  Cc: dhowells, Zhang Zhaolong, David S. Miller, Linux Netdev List,
	viro

Jonathon Reinhart <jonathon.reinhart@gmail.com> wrote:

> Does that even compile? proc_create() and proc_create_data() both return
> "struct proc_dir_entry *". It doesn't make sense for those macros to "return"
> anything but NULL - certainly not 1.
> 
> Besides, why shouldn't "if (!proc_create())" behave like proc_create()
> failed when
> CONFIG_PROC_FS is not enabled?  You wouldn't want the caller to start trying
> to use that ((struct proc_dir_entry *)1) would you?

It's sort of arguable.  If the proc interface is merely informational and
doesn't impact the function of a module to not be present, then, yes, having
proc_create() return some "true" value might make sense.  It's possible to
arrange things so that all the proc-related functions and data get compiled
out in such a situation by not being referenced by anything.

However, if the proc interface isn't merely functional, then the proc_create()
failure *is* cause for module loading failure.  But in that case, there should
be a Kconfig dependency on procfs and you should never use the dummy
functions.

David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] proc: proc_create() should return true if CONFIG_PROC_FS is not configured
  2015-02-25 11:19   ` David Howells
@ 2015-02-25 21:22     ` Jonathon Reinhart
  2015-02-26  1:21       ` Zhaolong Zhang
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathon Reinhart @ 2015-02-25 21:22 UTC (permalink / raw)
  To: David Howells; +Cc: Zhang Zhaolong, David S. Miller, Linux Netdev List, viro

On Wed, Feb 25, 2015 at 6:19 AM, David Howells <dhowells@redhat.com> wrote:
>> Does that even compile? proc_create() and proc_create_data() both return
>> "struct proc_dir_entry *". It doesn't make sense for those macros to "return"
>> anything but NULL - certainly not 1.
>>
>> Besides, why shouldn't "if (!proc_create())" behave like proc_create()
>> failed when
>> CONFIG_PROC_FS is not enabled?  You wouldn't want the caller to start trying
>> to use that ((struct proc_dir_entry *)1) would you?
>
> It's sort of arguable.  If the proc interface is merely informational and
> doesn't impact the function of a module to not be present, then, yes, having
> proc_create() return some "true" value might make sense.  It's possible to
> arrange things so that all the proc-related functions and data get compiled
> out in such a situation by not being referenced by anything.
>
> However, if the proc interface isn't merely functional, then the proc_create()
> failure *is* cause for module loading failure.  But in that case, there should
> be a Kconfig dependency on procfs and you should never use the dummy
> functions.

Of the 528 calls to proc_create(_data), only 70 are in an "if (!proc_create())"
style conditional. Another 188 assign the result to something, presumably a
"struct proc_dir_entry *, which are going to fail compilation with this patch.

Is breaking the build when the result of these dummy functions are assigned
to something what you're after? If that's the case, then why not remove them
altogether?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] proc: proc_create() should return true if CONFIG_PROC_FS is not configured
  2015-02-25 21:22     ` Jonathon Reinhart
@ 2015-02-26  1:21       ` Zhaolong Zhang
  0 siblings, 0 replies; 5+ messages in thread
From: Zhaolong Zhang @ 2015-02-26  1:21 UTC (permalink / raw)
  To: Jonathon Reinhart, David Howells
  Cc: Zhang Zhaolong, David S. Miller, Linux Netdev List, viro

On 02/26/2015 05:22 AM, Jonathon Reinhart wrote:
> On Wed, Feb 25, 2015 at 6:19 AM, David Howells<dhowells@redhat.com>  wrote:
>>> >>Does that even compile? proc_create() and proc_create_data() both return
>>> >>"struct proc_dir_entry *". It doesn't make sense for those macros to "return"
>>> >>anything but NULL - certainly not 1.
>>> >>
>>> >>Besides, why shouldn't "if (!proc_create())" behave like proc_create()
>>> >>failed when
>>> >>CONFIG_PROC_FS is not enabled?  You wouldn't want the caller to start trying
>>> >>to use that ((struct proc_dir_entry *)1) would you?
>> >
>> >It's sort of arguable.  If the proc interface is merely informational and
>> >doesn't impact the function of a module to not be present, then, yes, having
>> >proc_create() return some "true" value might make sense.  It's possible to
>> >arrange things so that all the proc-related functions and data get compiled
>> >out in such a situation by not being referenced by anything.
>> >
>> >However, if the proc interface isn't merely functional, then the proc_create()
>> >failure*is*  cause for module loading failure.  But in that case, there should
>> >be a Kconfig dependency on procfs and you should never use the dummy
>> >functions.
> Of the 528 calls to proc_create(_data), only 70 are in an "if (!proc_create())"
> style conditional. Another 188 assign the result to something, presumably a
> "struct proc_dir_entry *, which are going to fail compilation with this patch.

Oh, the usage of the CONFIG_PROC_FS macro should be checked wherever 
proc_create(_data) being called, right?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-26  1:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-25  5:14 [PATCH] proc: proc_create() should return true if CONFIG_PROC_FS is not configured Zhang Zhaolong
2015-02-25  7:48 ` Jonathon Reinhart
2015-02-25 11:19   ` David Howells
2015-02-25 21:22     ` Jonathon Reinhart
2015-02-26  1:21       ` Zhaolong Zhang

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.