Re: [PATCH 1/2] Bluetooth: Return proper error codes on rfcomm tty init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 24, 2011 at 3:57 PM, Anderson Briglia
<anderson.briglia@xxxxxxxxxxxxx> wrote:
> Hi David,
>
> On Mon, Oct 24, 2011 at 3:30 PM, David Herrmann
> <dh.herrmann@xxxxxxxxxxxxxx> wrote:
>> Forward error codes from tty core to the rfcomm_init caller instead of using
>> generic -1 errors.
>>
>> Signed-off-by: David Herrmann <dh.herrmann@xxxxxxxxxxxxxx>
>> ---
>>  net/bluetooth/rfcomm/tty.c |    9 ++++++---
>>  1 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
>> index c258796..2b753a3 100644
>> --- a/net/bluetooth/rfcomm/tty.c
>> +++ b/net/bluetooth/rfcomm/tty.c
>> @@ -1155,9 +1155,11 @@ static const struct tty_operations rfcomm_ops = {
>>
>>  int __init rfcomm_init_ttys(void)
>>  {
>> +       int error;
>> +
>>        rfcomm_tty_driver = alloc_tty_driver(RFCOMM_TTY_PORTS);
>>        if (!rfcomm_tty_driver)
>> -               return -1;
>> +               return -ENOMEM;
>>
>>        rfcomm_tty_driver->owner        = THIS_MODULE;
>>        rfcomm_tty_driver->driver_name  = "rfcomm";
>> @@ -1172,10 +1174,11 @@ int __init rfcomm_init_ttys(void)
>>        rfcomm_tty_driver->init_termios.c_lflag &= ~ICANON;
>>        tty_set_operations(rfcomm_tty_driver, &rfcomm_ops);
>>
>> -       if (tty_register_driver(rfcomm_tty_driver)) {
>> +       error = tty_register_driver(rfcomm_tty_driver);
>> +       if (error) {
>>                BT_ERR("Can't register RFCOMM TTY driver");
>>                put_tty_driver(rfcomm_tty_driver);
>> -               return -1;
>> +               return error;
>
> Since you are defining a new variable (error), how about use it on
> other error paths and add a "goto out" and have just one return path?

Isn't it quite common style to have the first error path return
directly? And then the other error paths use goto. However, there is
only one additional error path left so I don't see any way to make
this look nicer.

With more than 2 error paths I agree, a goto would be more readable,
but I cannot see this making this function look nicer. Anyway, if you
guys want, I can resend with goto's.

> Regards,
>
> Anderson Briglia

Regards
David
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux