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] [day] [month] [year] [list]
Message-ID: <CAL_jEz_Hg+cBfECWsQpGiLy_ArtwoUewRf83ksXa3S-uZ+ELUg@mail.gmail.com>
Date:	Thu, 26 Nov 2015 10:14:10 -0600
From:	Konstantin Shkolnyy <konstantin.shkolnyy@...il.com>
To:	Andy Shevchenko <andy.shevchenko@...il.com>
Cc:	Johan Hovold <johan@...nel.org>, USB <linux-usb@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] USB: serial: cp210x: Add tx_empty()

On Wed, Nov 25, 2015 at 2:26 PM, Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
> On Wed, Nov 25, 2015 at 12:28 AM, Konstantin Shkolnyy
> <konstantin.shkolnyy@...il.com> wrote:

>> +static bool cp210x_tx_empty(struct usb_serial_port *port)
>> +{
>> +       int err;
>> +       u32 count;
>> +
>> +       err = cp210x_get_tx_queue_byte_count(port, &count);
>
>> +       if (!err && count)
>> +               return false;
>> +
>> +       return true;
>
> return err || !count;

To me, expressing it like this is harder to read. The code as I wrote
it, in my mind, reads like this:

if successfully read the counter and it's not 0 then
   tx is not empty, return false

> Btw, can be count left uninitialized?

When the function succeeds it assigns a value to count.
--
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