Open Source Telephony
 help / color / mirror / Atom feed
From: Ronald Tessier <ronald.tessier@linux.intel.com>
To: ofono@ofono.org
Subject: Re: [PATCH] Add WSP_VALUE_TYPE_TEXT support in wsp_decode_application_id()
Date: Mon, 21 May 2012 18:23:32 +0200	[thread overview]
Message-ID: <4FBA6C04.1060303@linux.intel.com> (raw)
In-Reply-To: <1337597654-26049-1-git-send-email-jr_extern@vfnet.de>

[-- Attachment #1: Type: text/plain, Size: 2573 bytes --]

Hi Jens,

On 05/21/2012 12:54 PM, Jens Rehsack wrote:
> From: Jens Rehsack<sno@NetBSD.org>
>
> ---
>   src/wsputil.c |   43 ++++++++++++++++++++++++++-----------------
>   1 Datei geändert, 26 Zeilen hinzugefügt(+), 17 Zeilen entfernt(-)
>
> diff --git a/src/wsputil.c b/src/wsputil.c
> index 1b2b2b7..5611ed2 100644
> --- a/src/wsputil.c
> +++ b/src/wsputil.c
> @@ -486,28 +486,37 @@ gboolean wsp_decode_application_id(struct wsp_header_iter *iter,
>   							const void **out_value)
>   {
>   	const unsigned char *pdu_val = wsp_header_iter_get_val(iter);
> -	unsigned int val;
> -	unsigned int val_len;
> -	unsigned int i;
>
> -	/*
> -	 * Well-known field values MUST be encoded using the
> -	 * compact binary formats
> -	 */
> -	if (wsp_header_iter_get_val_type(iter) == WSP_VALUE_TYPE_SHORT) {
> -		val = *pdu_val&  0x7f;
> +	if (wsp_header_iter_get_val_type(iter) == WSP_VALUE_TYPE_TEXT) {
> +		wsp_header_iter_get_val_len(iter);
> +
> +		if (out_value)
> +			*out_value = pdu_val;

Why not just returning if the type is TEXT ?
Something like :

	const unsigned char *pdu_val = wsp_header_iter_get_val(iter);
	unsigned int val;
	unsigned int val_len;
	unsigned int i;

+	if (wsp_header_iter_get_val_type(iter) == WSP_VALUE_TYPE_TEXT) {
+		if (out_value)
+			*out_value = pdu_val;
+
+		return TRUE;
+	}
+
	/*
	 * Well-known field values MUST be encoded using the
	 * compact binary formats
	 */
	if (wsp_header_iter_get_val_type(iter) == WSP_VALUE_TYPE_SHORT) {


I think it does the same thing but more readable (you don't break the 80 
col. limit).

Best regards,

Ronald


>   	} else {
> -		val_len = wsp_header_iter_get_val_len(iter);
> +		unsigned int val;
>
> -		if (val_len>  2)
> -			return FALSE;
> +		/*
> +		 * Well-known field values MUST be encoded using the
> +		 * compact binary formats
> +		 */
> +		if (wsp_header_iter_get_val_type(iter) == WSP_VALUE_TYPE_SHORT) {
> +			val = *pdu_val&  0x7f;
> +		} else  {
> +			unsigned int val_len;
> +			unsigned int i;
>
> -		for (i = 0, val = 0; i<  val_len&&  i<  sizeof(val); i++)
> -			val = (val<<  8) | pdu_val[i];
> -	}
> +			val_len = wsp_header_iter_get_val_len(iter);
>
> -	if (out_value)
> -		*out_value = get_text_entry(val, app_id);
> +			if (val_len>  2)
> +				return FALSE;
> +
> +			for (i = 0, val = 0; i<  val_len&&  i<  sizeof(val); i++)
> +				val = (val<<  8) | pdu_val[i];
> +		}
> +
> +		if (out_value)
> +			*out_value = get_text_entry(val, app_id);
> +	}
>
>   	return TRUE;
>   }

  reply	other threads:[~2012-05-21 16:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21 10:54 [PATCH] Add WSP_VALUE_TYPE_TEXT support in wsp_decode_application_id() Jens Rehsack
2012-05-21 16:23 ` Ronald Tessier [this message]
2012-05-22  8:09   ` Jens Rehsack
2012-05-30  7:11     ` Jens Rehsack
  -- strict thread matches above, loose matches on Subject: below --
2012-05-30  8:59 Jens Rehsack
2012-05-30 13:49 ` Denis Kenzior
2012-05-16 14:03 Jens Rehsack
2012-05-16 15:45 ` Ronald Tessier
2012-05-16 16:18   ` Jens Rehsack
2012-05-18 12:59     ` Ronald Tessier

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=4FBA6C04.1060303@linux.intel.com \
    --to=ronald.tessier@linux.intel.com \
    --cc=ofono@ofono.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox