Re: [PATCH 3/6] tools/rfcomm-tester: Add RFCOMM server write test case

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

 



Hi Marcin,

On Wed, Feb 12, 2014, Marcin Kraglak wrote:
> This will check data write from server to client.
> ---
>  tools/rfcomm-tester.c | 43 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/tools/rfcomm-tester.c b/tools/rfcomm-tester.c
> index 80448cb..1c2563d 100644
> --- a/tools/rfcomm-tester.c
> +++ b/tools/rfcomm-tester.c
> @@ -66,6 +66,9 @@ struct rfcomm_server_data {
>  	uint8_t server_channel;
>  	uint8_t client_channel;
>  	bool expected_status;
> +	const uint8_t *send_data;
> +	const uint8_t *read_data;
> +	uint16_t data_len;

> +static void server_hook_func(const void *data, uint16_t len,
> +							void *user_data)
> +{
> +	struct test_data *test_data = tester_get_data();
> +	const struct rfcomm_server_data *server_data = test_data->test_data;
> +
> +	if (memcmp(server_data->send_data, data, len))

Don't you have to first check that server_data->data_len == len?

> +	if (server_data->send_data) {
> +		if (server_data->data_len != write(new_sk,
> +							server_data->send_data,
> +							server_data->data_len))

This looks ugly. I'd create a separate ssize_t ret variable, assing the
return value from write to it and then compare with data_len.

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