Linux bluetooth development
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Waldemar.Rymarkiewicz@tieto.com
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v4 2/6] Sim Access Profile Server
Date: Wed, 16 Mar 2011 11:40:03 +0200	[thread overview]
Message-ID: <20110316094003.GA11136@jh-x301> (raw)
In-Reply-To: <99B09243E1A5DA4898CDD8B70011144810830AA84A@EXMB04.eu.tieto.com>

Hi Waldek,

On Wed, Mar 16, 2011, Waldemar.Rymarkiewicz@tieto.com wrote:
> >I've pushed the first two patches in this set, but it's gonna 
> >take quite a bit longer to properly review the rest (at a 
> >quick glance I noticed at least some coding style stuff with 
> >over 80-character lines).
> 
> Yes, I guess you refer  to eg.
> 
> case SAP_SET_TRANSPORT_PROTOCOL_REQ:
> 	if (msg->nparam == 0x01 &&
> 			msg->param->id == SAP_PARAM_ID_TRANSPORT_PROTOCOL &&
> 			ntohs(msg->param->len) == SAP_PARAM_ID_TRANSPORT_PROTOCOL_LEN &&
> 			(*msg->param->val  == SAP_TRANSPORT_PROTOCOL_T0 ||
> 			*msg->param->val == SAP_TRANSPORT_PROTOCOL_T1))
> 		return 0;
> 
> Well, I didn't know how to spit up something like
> "ntohs(msg->param->len) == SAP_PARAM_ID_TRANSPORT_PROTOCOL_LEN &&"
> correctly.  Any sugestion?

Use shorter define names (since they really are quite long), move the
checks into separate functions, e.g. validate_set_transport_protocol_req(),
or redo the if-statement to something like:

	if (msg->nparam != 0x01)
		return -EBADMSG;
	if (msg->param->id != SAP_PARAM_ID_TRANSPORT_PROTOCOL)
		return -EBADMSG;
	if (ntohs(msg->param->len) != SAP_PARAM_ID_TRANSPORT_PROTOCOL_LEN)
		return -EBADMSG;
        ...
	return 0;

It becomes much easier for a human to parse it that way since you get to
process the individual conditions clearly one at a time.

Take your pick ;)

Johan

  reply	other threads:[~2011-03-16  9:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-15 16:43 [PATCH v4 0/6] SIM Access Profile v4 Waldemar Rymarkiewicz
2011-03-15 16:43 ` [PATCH v4 1/6] Adjust sap/server.c license text to the rest of the code Waldemar Rymarkiewicz
2011-03-15 16:43 ` [PATCH v4 2/6] Sim Access Profile Server Waldemar Rymarkiewicz
2011-03-15 17:54   ` Johan Hedberg
2011-03-16  8:49     ` Waldemar.Rymarkiewicz
2011-03-16  9:40       ` Johan Hedberg [this message]
2011-03-16 11:04         ` Waldemar.Rymarkiewicz
2011-03-15 16:43 ` [PATCH v4 3/6] Sim Access Profile connect/disconnect procedures Waldemar Rymarkiewicz
2011-03-15 16:43 ` [PATCH v4 4/6] Add support for SAP protocol Waldemar Rymarkiewicz
2011-03-15 16:43 ` [PATCH v4 5/6] Sim Access Profile dummy driver Waldemar Rymarkiewicz
2011-03-15 16:43 ` [PATCH v4 6/6] Sim Access Profile test scripts Waldemar Rymarkiewicz

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=20110316094003.GA11136@jh-x301 \
    --to=johan.hedberg@gmail.com \
    --cc=Waldemar.Rymarkiewicz@tieto.com \
    --cc=linux-bluetooth@vger.kernel.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