Hi Andrei, On Mon, Dec 16, 2013 at 4:57 AM, Andrei Emeltchenko <Andrei.Emeltchenko.news@xxxxxxxxx> 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 -- 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