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]
Date:	Tue, 9 Sep 2014 09:20:29 +0100
From:	Lee Jones <lee.jones@...aro.org>
To:	Octavian Purdila <octavian.purdila@...el.com>
Cc:	Johan Hovold <johan@...nel.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Linus Walleij <linus.walleij@...aro.org>,
	Alexandre Courbot <gnurou@...il.com>, wsa@...-dreams.de,
	Samuel Ortiz <sameo@...ux.intel.com>,
	Arnd Bergmann <arnd@...db.de>,
	Daniel Baluta <daniel.baluta@...el.com>,
	Laurentiu Palcu <laurentiu.palcu@...el.com>,
	linux-usb@...r.kernel.org, lkml <linux-kernel@...r.kernel.org>,
	linux-gpio@...r.kernel.org, linux-i2c@...r.kernel.org
Subject: Re: [PATCH v3 2/3] i2c: add support for Diolan DLN-2 USB-I2C adapter

On Mon, 08 Sep 2014, Octavian Purdila wrote:

> On Mon, Sep 8, 2014 at 7:30 PM, Johan Hovold <johan@...nel.org> wrote:
> > On Mon, Sep 08, 2014 at 06:57:29PM +0300, Octavian Purdila wrote:
> >> On Mon, Sep 8, 2014 at 5:44 PM, Johan Hovold <johan@...nel.org> wrote:
> >>
> >> <snip>
> >>
> >> Hi Johan,
> >>
> >> Again, thanks for the detailed review, I am addressing your review
> >> comments as we speak. Some questions below.
> >>
> >> <snip>
> >>
> >> > > +     int ret, len;
> >> > > +     struct tx_data {
> >> > > +             u8 port;
> >> > > +             u8 addr;
> >> > > +             u8 mem_addr_len;
> >> > > +             __le32 mem_addr;
> >> > > +             __le16 buf_len;
> >> > > +             u8 buf[DLN2_I2C_MAX_XFER_SIZE];
> >> > > +     } __packed tx;
> >> >
> >> > Allocate these buffers dynamically (possibly at probe).
> >> >
> >>
> >> I double checked this, and DLN2_I2C_MAX_XFER_SIZE should actually be <
> >> 64 as the USB endpoint configuration max packet size is 64. In this
> >> case, can we keep it on the stack?
> >
> > It's better to lift that restriction and allocate it dynamically. Using
> > larger buffers (> EP size) is also more efficient.
> >
> >> <snip>
> >>
> >> > > +     int ret, buf_len, rx_len = sizeof(rx);
> >> >
> >> > Again, one declaration per line.
> >>
> >> AFAICS there are many places where declaration on the same line
> >> (initialization included) are used. When did this became a coding
> >> style issue?
> >
> > It's ugly, hurts readability, and can also obfuscate the fact that your
> > function really needs to be refactored.
> >
> > And it's in the CodingStyle:
> >
> >         "To this end, use just one data declaration per line (no commas
> >         for multiple data declarations)."
> >
> 
> OK, I always thought that was for when declaring structures/unions.
> Just one more question on this subject: is the following allowed:
> 
> int ret, len;
> 
> or should it be:
> 
> int ret;
> int len;

Common sense usually prevails here.  I sometimes bunch up the really
simple/obvious/throw-away variables like; i, j, k, ret, val etc,
especially when there are a lot of variables in use, but it's nicer to
see the less used, more complex ones on separate lines.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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