lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151009184738.GL2189@localhost.localdomain>
Date:	Fri, 9 Oct 2015 21:47:38 +0300
From:	Sergei Zviagintsev <sergei@...v.net>
To:	David Herrmann <dh.herrmann@...il.com>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Daniel Mack <daniel@...que.org>,
	Djalal Harouni <tixxdz@...ndz.org>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 31/44] kdbus: Cleanup kdbus_conn_move_messages()

Hi,

On Thu, Oct 08, 2015 at 04:50:31PM +0200, David Herrmann wrote:
> Hi
> 
> On Thu, Oct 8, 2015 at 1:32 PM, Sergei Zviagintsev <sergei@...v.net> wrote:
> >  - Move `r' and `ret' to scopes where they are used. Drop redundant
> >    initialization of `ret'.
> >
> >  - Initialize `bus' on declaration.
> >
> >  - Replace list_for_each_entry_safe() with list_for_each_entry() when
> >    iterating over list of replies.
> >
> >  - Drop redundant `continue'.
> >
> > Signed-off-by: Sergei Zviagintsev <sergei@...v.net>
> > ---
> >  ipc/kdbus/connection.c | 14 +++++++-------
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c
> > index b32b4f981618..6ee688d3de53 100644
> > --- a/ipc/kdbus/connection.c
> > +++ b/ipc/kdbus/connection.c
> > @@ -1293,25 +1293,24 @@ void kdbus_conn_move_messages(struct kdbus_conn *conn_dst,
> >                               u64 name_id)
> >  {
> >         struct kdbus_queue_entry *e, *e_tmp;
> > -       struct kdbus_reply *r, *r_tmp;
> > -       struct kdbus_bus *bus;
> > +       struct kdbus_bus *bus = conn_src->ep->bus;
> >         struct kdbus_conn *c;
> >         LIST_HEAD(msg_list);
> > -       int i, ret = 0;
> > +       int i;
> >
> >         if (WARN_ON(conn_src == conn_dst))
> >                 return;
> >
> > -       bus = conn_src->ep->bus;
> > -
> >         /* lock order: domain -> bus -> ep -> names -> conn */
> >         down_read(&bus->conn_rwlock);
> >         hash_for_each(bus->conn_hash, i, c, hentry) {
> > +               struct kdbus_reply *r;
> > +
> 
> Why make 'r' local?

So what is the rule to keep some vars block-local and some not? This
function has a number of local vars, so the rationale is to keep things
simple. We don't use `r' function wide, but use it only in this block,
so why don't have it block-local?

> 
> >                 if (c == conn_src || c == conn_dst)
> >                         continue;
> >
> >                 mutex_lock(&c->lock);
> > -               list_for_each_entry_safe(r, r_tmp, &c->reply_list, entry) {
> > +               list_for_each_entry(r, &c->reply_list, entry) {
> 
> Looks good.
> 
> >                         if (r->reply_src != conn_src)
> >                                 continue;
> >
> > @@ -1328,6 +1327,8 @@ void kdbus_conn_move_messages(struct kdbus_conn *conn_dst,
> >
> >         kdbus_conn_lock2(conn_src, conn_dst);
> >         list_for_each_entry_safe(e, e_tmp, &conn_src->queue.msg_list, entry) {
> > +               int ret;
> > +
> 
> Why make it local?

Same thing here. We have the only use of this `ret' var, so why don't
keep it right here?

> 
> >                 /* filter messages for a specific name */
> >                 if (name_id > 0 && e->dst_name_id != name_id)
> >                         continue;
> > @@ -1343,7 +1344,6 @@ void kdbus_conn_move_messages(struct kdbus_conn *conn_dst,
> >                 if (ret < 0) {
> >                         kdbus_conn_lost_message(conn_dst);
> >                         kdbus_queue_entry_free(e);
> > -                       continue;
> 
> Looks good.
> 
> Thanks
> David
> 
> >                 }
> >         }
> >         kdbus_conn_unlock2(conn_src, conn_dst);
> > --
> > 1.8.3.1
> >
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ