Re: [PATCH obexd v0 03/11] client: refactor transfer callback use

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

 



Hi Mikel,

On Mon, Mar 12, 2012 at 10:32 AM, Mikel Astiz <mikel.astiz.oss@xxxxxxxxx> wrote:
> From: Mikel Astiz <mikel.astiz@xxxxxxxxxxxx>
>
> Separated internal functions are used to report success, failure, and
> progress, instead of using the callback directly.
>
> This makes the code more readable.
> ---
>  client/transfer.c |   86 ++++++++++++++++++++++++++++++++--------------------
>  1 files changed, 53 insertions(+), 33 deletions(-)
>
> diff --git a/client/transfer.c b/client/transfer.c
> index a609aa9..f2a153c 100644
> --- a/client/transfer.c
> +++ b/client/transfer.c
> @@ -138,10 +138,47 @@ static DBusMessage *obc_transfer_get_properties(DBusConnection *connection,
>        return reply;
>  }
>
> -static void obc_transfer_abort(struct obc_transfer *transfer)
> +static void transfer_notify_progress(struct obc_transfer *transfer)
> +{
> +       struct transfer_callback *callback = transfer->callback;
> +
> +       DBG("%p", transfer);
> +
> +       if ((callback != NULL) && (transfer->transferred != transfer->size))
> +               callback->func(transfer, transfer->transferred, NULL,
> +                                                               callback->data);
> +}

Usually we use early returns and simple statements to be more
readable, so if (callback == NULL) return would have been better. Also
I guess we don't really need this check for transferred != size since
gobex has a complete callback and latter you set it to NULL.


-- 
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