mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Assuming NULL
@ 2005-06-11 16:24 Jan Engelhardt
  2005-06-11 16:49 ` Måns Rullgård
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jan Engelhardt @ 2005-06-11 16:24 UTC (permalink / raw)
  To: Linux Kernel Mailing List

Hi developers,



some places in fs/*.c have conditions like

(namei.c, 238, in "int permission()"):
        if(inode->i_op && inode->i_op->permission)

Others just have
(namei.c, 813, in "int fastcall link_path_walk()"):
        if(!inode->i_op->lookup)

My question is: Which one is right wrt the case "i_op ==/!= NULL"?
There are two ways:

- the kernel assumes i_op (and similar) is always non-NULL
  => then we can remove a lot of checks, like the first example above

- the kernel does not assume...
  => then we need some extra checks, like in the second example above



Jan Engelhardt                                                               
--                                                                            
| Gesellschaft fuer Wissenschaftliche Datenverarbeitung Goettingen,
| Am Fassberg, 37077 Goettingen, www.gwdg.de

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

* Re: Assuming NULL
  2005-06-11 16:24 Assuming NULL Jan Engelhardt
@ 2005-06-11 16:49 ` Måns Rullgård
  2005-06-11 17:17   ` Jan Engelhardt
  2005-06-11 17:24 ` Willy Tarreau
  2005-06-11 17:30 ` Christoph Hellwig
  2 siblings, 1 reply; 5+ messages in thread
From: Måns Rullgård @ 2005-06-11 16:49 UTC (permalink / raw)
  To: linux-kernel

Jan Engelhardt <jengelh@linux01.gwdg.de> writes:

> Hi developers,
>
> some places in fs/*.c have conditions like
>
> (namei.c, 238, in "int permission()"):
>         if(inode->i_op && inode->i_op->permission)
>
> Others just have
> (namei.c, 813, in "int fastcall link_path_walk()"):
>         if(!inode->i_op->lookup)
>
> My question is: Which one is right wrt the case "i_op ==/!= NULL"?
> There are two ways:
>
> - the kernel assumes i_op (and similar) is always non-NULL
>   => then we can remove a lot of checks, like the first example above
>
> - the kernel does not assume...
>   => then we need some extra checks, like in the second example above

And a third:

- in some places it's safe to assume non-NULL, but not always
  => then we need to check only the unsafe places

-- 
Måns Rullgård
mru@inprovide.com


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

* Re: Assuming NULL
  2005-06-11 16:49 ` Måns Rullgård
@ 2005-06-11 17:17   ` Jan Engelhardt
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Engelhardt @ 2005-06-11 17:17 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: linux-kernel


>And a third:
>
>- in some places it's safe to assume non-NULL, but not always
>  => then we need to check only the unsafe places

Fine, it would be nice to know where in my module (providing a filesystem) I 
can assume something and where not. (And not only my module.)



Jan Engelhardt                                                               
--                                                                            
| Gesellschaft fuer Wissenschaftliche Datenverarbeitung Goettingen,
| Am Fassberg, 37077 Goettingen, www.gwdg.de

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

* Re: Assuming NULL
  2005-06-11 16:24 Assuming NULL Jan Engelhardt
  2005-06-11 16:49 ` Måns Rullgård
@ 2005-06-11 17:24 ` Willy Tarreau
  2005-06-11 17:30 ` Christoph Hellwig
  2 siblings, 0 replies; 5+ messages in thread
From: Willy Tarreau @ 2005-06-11 17:24 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Linux Kernel Mailing List

Hi Jan,

On Sat, Jun 11, 2005 at 06:24:22PM +0200, Jan Engelhardt wrote:
(...)
> My question is: Which one is right wrt the case "i_op ==/!= NULL"?
> There are two ways:
> 
> - the kernel assumes i_op (and similar) is always non-NULL
>   => then we can remove a lot of checks, like the first example above
> 
> - the kernel does not assume...
>   => then we need some extra checks, like in the second example above

and in any case, adding a comment telling why it CAN or why it CANNOT
be NULL would prevent other people from having to redo the same work
in 6 months.

Willy


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

* Re: Assuming NULL
  2005-06-11 16:24 Assuming NULL Jan Engelhardt
  2005-06-11 16:49 ` Måns Rullgård
  2005-06-11 17:24 ` Willy Tarreau
@ 2005-06-11 17:30 ` Christoph Hellwig
  2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2005-06-11 17:30 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Linux Kernel Mailing List

On Sat, Jun 11, 2005 at 06:24:22PM +0200, Jan Engelhardt wrote:
> Hi developers,
> 
> 
> 
> some places in fs/*.c have conditions like
> 
> (namei.c, 238, in "int permission()"):
>         if(inode->i_op && inode->i_op->permission)
> 
> Others just have
> (namei.c, 813, in "int fastcall link_path_walk()"):
>         if(!inode->i_op->lookup)
> 
> My question is: Which one is right wrt the case "i_op ==/!= NULL"?
> There are two ways:
> 
> - the kernel assumes i_op (and similar) is always non-NULL
>   => then we can remove a lot of checks, like the first example above

i_op must not be NULL .alloc_inode() intitializes it to &empty_iops,
and setting it to NULL would be a bug.


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

end of thread, other threads:[~2005-06-11 17:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-11 16:24 Assuming NULL Jan Engelhardt
2005-06-11 16:49 ` Måns Rullgård
2005-06-11 17:17   ` Jan Engelhardt
2005-06-11 17:24 ` Willy Tarreau
2005-06-11 17:30 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®