Re: [PATCH_v7 1/5] bnep: Rename struct bnep_conn to bnep and vars for better readability

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

 



Hi Ravi,

On Fri, Dec 20, 2013 at 1:40 PM, Ravi kumar Veeramally
<ravikumar.veeramally@xxxxxxxxxxxxxxx> wrote:
> ---
>  profiles/network/bnep.c | 80 ++++++++++++++++++++++++-------------------------
>  1 file changed, 40 insertions(+), 40 deletions(-)
>
> diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
> index 08037e6..edf258b 100644
> --- a/profiles/network/bnep.c
> +++ b/profiles/network/bnep.c
> @@ -67,7 +67,7 @@ struct __service_16 {
>         uint16_t src;
>  } __attribute__ ((packed));
>
> -struct bnep_conn {
> +struct bnep {
>         GIOChannel      *io;
>         uint16_t        src;
>         uint16_t        dst;
> @@ -77,17 +77,17 @@ struct bnep_conn {
>         bnep_connect_cb conn_cb;
>  };
>
> -static void free_bnep_connect(struct bnep_conn *bc)
> +static void free_bnep_connect(struct bnep *session)
>  {
> -       if (!bc)
> +       if (!session)
>                 return;
>
> -       if (bc->io) {
> -               g_io_channel_unref(bc->io);
> -               bc->io = NULL;
> +       if (session->io) {
> +               g_io_channel_unref(session->io);
> +               session->io = NULL;
>         }
>
> -       g_free(bc);
> +       g_free(session);
>  }
>
>  uint16_t bnep_service_id(const char *svc)
> @@ -249,7 +249,7 @@ int bnep_if_down(const char *devname)
>  static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
>                                                                 gpointer data)
>  {
> -       struct bnep_conn *bc = data;
> +       struct bnep *session = data;
>         struct bnep_control_rsp *rsp;
>         struct timeval timeo;
>         char pkt[BNEP_MTU];
> @@ -260,9 +260,9 @@ static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
>         if (cond & G_IO_NVAL)
>                 goto failed;
>
> -       if (bc->setup_to > 0) {
> -               g_source_remove(bc->setup_to);
> -               bc->setup_to = 0;
> +       if (session->setup_to > 0) {
> +               g_source_remove(session->setup_to);
> +               session->setup_to = 0;
>         }
>
>         if (cond & (G_IO_HUP | G_IO_ERR)) {
> @@ -309,8 +309,8 @@ static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
>         timeo.tv_sec = 0;
>         setsockopt(sk, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo));
>
> -       sk = g_io_channel_unix_get_fd(bc->io);
> -       if (bnep_connadd(sk, bc->src, iface)) {
> +       sk = g_io_channel_unix_get_fd(session->io);
> +       if (bnep_connadd(sk, session->src, iface)) {
>                 error("bnep conn could not be added");
>                 goto failed;
>         }
> @@ -320,19 +320,19 @@ static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
>                 goto failed;
>         }
>
> -       bc->conn_cb(chan, iface, 0, bc->data);
> -       free_bnep_connect(bc);
> +       session->conn_cb(chan, iface, 0, session->data);
> +       free_bnep_connect(session);
>
>         return FALSE;
>
>  failed:
> -       bc->conn_cb(NULL, NULL, -EIO, bc->data);
> -       free_bnep_connect(bc);
> +       session->conn_cb(NULL, NULL, -EIO, session->data);
> +       free_bnep_connect(session);
>
>         return FALSE;
>  }
>
> -static int bnep_setup_conn_req(struct bnep_conn *bc)
> +static int bnep_setup_conn_req(struct bnep *session)
>  {
>         struct bnep_setup_conn_req *req;
>         struct __service_16 *s;
> @@ -345,34 +345,34 @@ static int bnep_setup_conn_req(struct bnep_conn *bc)
>         req->ctrl = BNEP_SETUP_CONN_REQ;
>         req->uuid_size = 2;     /* 16bit UUID */
>         s = (void *) req->service;
> -       s->src = htons(bc->src);
> -       s->dst = htons(bc->dst);
> +       s->src = htons(session->src);
> +       s->dst = htons(session->dst);
>
> -       fd = g_io_channel_unix_get_fd(bc->io);
> +       fd = g_io_channel_unix_get_fd(session->io);
>         if (write(fd, pkt, sizeof(*req) + sizeof(*s)) < 0) {
>                 error("bnep connection req send failed: %s", strerror(errno));
>                 return -errno;
>         }
>
> -       bc->attempts++;
> +       session->attempts++;
>
>         return 0;
>  }
>
>  static gboolean bnep_conn_req_to(gpointer user_data)
>  {
> -       struct bnep_conn *bc = user_data;
> +       struct bnep *session = user_data;
>
> -       if (bc->attempts == CON_SETUP_RETRIES) {
> +       if (session->attempts == CON_SETUP_RETRIES) {
>                 error("Too many bnep connection attempts");
>         } else {
>                 error("bnep connection setup TO, retrying...");
> -               if (bnep_setup_conn_req(bc) == 0)
> +               if (bnep_setup_conn_req(session) == 0)
>                         return TRUE;
>         }
>
> -       bc->conn_cb(NULL, NULL, -ETIMEDOUT, bc->data);
> -       free_bnep_connect(bc);
> +       session->conn_cb(NULL, NULL, -ETIMEDOUT, session->data);
> +       free_bnep_connect(session);
>
>         return FALSE;
>  }
> @@ -380,28 +380,28 @@ static gboolean bnep_conn_req_to(gpointer user_data)
>  int bnep_connect(int sk, uint16_t src, uint16_t dst, bnep_connect_cb conn_cb,
>                                                                 void *data)
>  {
> -       struct bnep_conn *bc;
> +       struct bnep *session;
>         int err;
>
>         if (!conn_cb)
>                 return -EINVAL;
>
> -       bc = g_new0(struct bnep_conn, 1);
> -       bc->io = g_io_channel_unix_new(sk);
> -       bc->attempts = 0;
> -       bc->src = src;
> -       bc->dst = dst;
> -       bc->conn_cb = conn_cb;
> -       bc->data = data;
> +       session = g_new0(struct bnep, 1);
> +       session->io = g_io_channel_unix_new(sk);
> +       session->attempts = 0;
> +       session->src = src;
> +       session->dst = dst;
> +       session->conn_cb = conn_cb;
> +       session->data = data;
>
> -       err = bnep_setup_conn_req(bc);
> +       err = bnep_setup_conn_req(session);
>         if (err < 0)
>                 return err;
>
> -       bc->setup_to = g_timeout_add_seconds(CON_SETUP_TO,
> -                                                       bnep_conn_req_to, bc);
> -       g_io_add_watch(bc->io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
> -                                                       bnep_setup_cb, bc);
> +       session->setup_to = g_timeout_add_seconds(CON_SETUP_TO,
> +                                               bnep_conn_req_to, session);
> +       g_io_add_watch(session->io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
> +                                                       bnep_setup_cb, session);
>         return 0;
>  }
>
> --
> 1.8.3.2

Pushed, thanks.


-- 
Luiz Augusto von Dentz
--
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