linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Santiago Carot-Nemesio <sancane@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 2/6] Parse final measurement indication
Date: Sat, 12 Nov 2011 20:37:53 +0200	[thread overview]
Message-ID: <20111112183753.GA17859@x220.Elisa> (raw)
In-Reply-To: <1320925022-21891-3-git-send-email-sancane@gmail.com>

Hi Santiago,

On Thu, Nov 10, 2011, Santiago Carot-Nemesio wrote:
> +struct measurement {
> +	gint16		exp;
> +	gint32		mant;
> +	guint64		time;
> +	gboolean	suptime;
> +	gchar		*unit;
> +	gchar		*type;
> +	gchar		*msmnt;

Is msmnt supposed to be short for measurement? Could you just spell it
out please since to me that short version is far from obvious. Or would
"value" be a more suitable name?

Also, please avoid usage of g* types where you're not directly accessing
some GLib API that expects them (even then it's mostly fine to go ahead
with uint16_t, char, etc). I can see that there are other places in
thermometer.c using the g types too which should be fixed in a separate
patch.

> +static gchar *temptype2str(uint8_t value)
> +{
> +	switch (value) {
> +	case 1: return "Armpit";
> +	case 2: return "Body";
> +	case 3: return "Ear";
> +	case 4: return "Finger";
> +	case 5: return "Intestines";
> +	case 6: return "Mouth";
> +	case 7: return "Rectum";
> +	case 8: return "Toe";
> +	case 9: return "Tympanum";
> +	default:
> +		error("Temperature type %d reserved for future use", value);
> +		return NULL;
> +	};

Please follow the coding style with switch statements. All those return
statements should be on their own line. However, in this case I think
it'd be just easier to make a lookup table for those values, i.e.

const char *temp_type[] {
	"<unknown>",
	"Armpit",
	"Body",
	...

And then in the temptype2str function:

	if (type > 0 && val < G_N_ELEMENTS(temp_type))
		return temp_type[type];


Johan

  parent reply	other threads:[~2011-11-12 18:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-10 11:36 Health Thermometer Profile (HTP) Santiago Carot-Nemesio
2011-11-10 11:36 ` [PATCH 1/6] Manage GATT attribute indications in handle callback Santiago Carot-Nemesio
2011-11-10 11:36   ` [PATCH 2/6] Parse final measurement indication Santiago Carot-Nemesio
2011-11-10 11:36     ` [PATCH 3/6] Add org.bluez.ThermometerWatcher interface to default policy Santiago Carot-Nemesio
2011-11-10 11:37       ` [PATCH 4/6] Implement EnableIntermediateMeasurement D-Bus method Santiago Carot-Nemesio
2011-11-10 11:37         ` [PATCH 5/6] Implement DisableIntermediateMeasurement " Santiago Carot-Nemesio
2011-11-10 11:37           ` [PATCH 6/6] Notify intermediate measurements Santiago Carot-Nemesio
2011-11-12 18:37     ` Johan Hedberg [this message]
2011-11-13  9:18       ` [PATCH 2/6] Parse final measurement indication Santiago Carot
  -- strict thread matches above, loose matches on Subject: below --
2011-11-14 12:11 Health Thermometer Profile (HTP) Santiago Carot-Nemesio
2011-11-14 12:11 ` [PATCH 1/6] Manage GATT attribute indications in handle callback Santiago Carot-Nemesio
2011-11-14 12:11   ` [PATCH 2/6] Parse final measurement indication Santiago Carot-Nemesio
2011-11-14 21:52     ` Johan Hedberg
2011-11-15 10:06       ` Santiago Carot
2011-11-09 10:51 Health Thermometer Profile (HTP) Santiago Carot-Nemesio
2011-11-09 10:51 ` [PATCH 1/6] Manage GATT attribute indications in handle callback Santiago Carot-Nemesio
2011-11-09 10:51   ` [PATCH 2/6] Parse final measurement indication Santiago Carot-Nemesio

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=20111112183753.GA17859@x220.Elisa \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=sancane@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).