All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anderson Lizardo <anderson.lizardo@openbossa.org>
To: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
Cc: BlueZ development <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH 4/5] l2cap-tester: Remove unneeded variable
Date: Mon, 16 Dec 2013 06:39:28 -0400	[thread overview]
Message-ID: <CAJdJm_NJCUAeMkvGMYLah3L__DECCd_ocPyd-F46KrcdmCuGMg@mail.gmail.com> (raw)
In-Reply-To: <1387184262-21439-4-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Mon, Dec 16, 2013 at 4:57 AM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> --- a/tools/l2cap-tester.c
> +++ b/tools/l2cap-tester.c
> @@ -489,15 +489,14 @@ static int create_l2cap_sock(struct test_data *data, uint16_t psm)
>  {
>         const uint8_t *master_bdaddr;
>         struct sockaddr_l2 addr;
> -       int sk, err;
> +       int sk;
>
>         sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET | SOCK_NONBLOCK,
>                                                         BTPROTO_L2CAP);
>         if (sk < 0) {
> -               err = -errno;
>                 tester_warn("Can't create socket: %s (%d)", strerror(errno),
>                                                                         errno);
> -               return err;
> +               return -errno;
>         }
>
>         master_bdaddr = hciemu_get_master_bdaddr(data->hciemu);
> @@ -517,11 +516,10 @@ static int create_l2cap_sock(struct test_data *data, uint16_t psm)
>                 addr.l2_bdaddr_type = BDADDR_BREDR;
>
>         if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
> -               err = -errno;
>                 tester_warn("Can't bind socket: %s (%d)", strerror(errno),
>                                                                         errno);
>                 close(sk);
> -               return err;
> +               return -errno;

This is not a good idea because close() will overwrite the original
error if it fails as well. The previous situation is also valid
because tester_warn() may call library functions that set errno.

Best Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

  reply	other threads:[~2013-12-16 10:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-16  8:57 [PATCH 1/5] btmgmt: Remove unneeded code Andrei Emeltchenko
2013-12-16  8:57 ` [PATCH 2/5] avdtp: Remove unneeded local variable Andrei Emeltchenko
2013-12-16  9:18   ` Johan Hedberg
2013-12-16  8:57 ` [PATCH 3/5] hciemu: Make code consistent Andrei Emeltchenko
2013-12-16  8:57 ` [PATCH 4/5] l2cap-tester: Remove unneeded variable Andrei Emeltchenko
2013-12-16 10:39   ` Anderson Lizardo [this message]
2013-12-16 10:50     ` Andrei Emeltchenko
2013-12-16  8:57 ` [PATCH 5/5] hciemu: Print error in case hci_vhci is not loaded Andrei Emeltchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJdJm_NJCUAeMkvGMYLah3L__DECCd_ocPyd-F46KrcdmCuGMg@mail.gmail.com \
    --to=anderson.lizardo@openbossa.org \
    --cc=Andrei.Emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.