Re: [PATCH] ipc: constify ipc_ops

From: Andrew Morton
Date: Mon Mar 31 2014 - 17:59:40 EST


On Mon, 31 Mar 2014 07:12:36 -0700 Davidlohr Bueso <davidlohr@xxxxxx> wrote:

> > >> --- a/ipc/msg.c
> > >> +++ b/ipc/msg.c
> > >> @@ -306,15 +306,14 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
> > >> SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
> > >> {
> > >> struct ipc_namespace *ns;
> > >> - struct ipc_ops msg_ops;
> > >> + static const struct ipc_ops msg_ops = {
> > >> + .getnew = newque,
> > >> + .associate = msg_security,
> > >
> > > For completeness, please add .more_checks = NULL as well.
> >
> > The C standard already ensures that .more_checks is initialized with
> > NULL. So I don't see any benefit from doing it explicitly.
> > We're not initializing global/static variables holding NULL pointers
> > in the majority of the code base either, so this is just "best
> > practice".
>
> Hence the word _completeness_.

It's unusual to fill in the zeroed fields. We could put it in
explicitly as commentary to tell the reader "this exists - we thought
about it and decided to leave it zero". Which presumably is along the
lines of what you're thinking. Or not ;)

I'm easy either way. I'll shove the patch into my nice pile of
things-to-look-at-after-rc1.
--
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/