linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mikel Astiz <mikel.astiz.oss@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Mikel Astiz <mikel.astiz@bmw-carit.de>
Subject: [RFC BlueZ v0 2/5] Use defines instead of magic numbers
Date: Mon, 14 May 2012 17:33:01 +0200	[thread overview]
Message-ID: <1337009584-17181-3-git-send-email-mikel.astiz.oss@gmail.com> (raw)
In-Reply-To: <1337009584-17181-1-git-send-email-mikel.astiz.oss@gmail.com>

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

The error-handling code should use the defines instead of magic numbers.
---
 src/device.c |   42 +++++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/device.c b/src/device.c
index 2a8812e..82dc2ca 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2303,48 +2303,48 @@ static DBusMessage *new_authentication_return(DBusMessage *msg, int status)
 	case 0x00: /* success */
 		return dbus_message_new_method_return(msg);
 
-	case 0x04: /* page timeout */
+	case HCI_PAGE_TIMEOUT:
 		return dbus_message_new_error(msg,
 				ERROR_INTERFACE ".ConnectionAttemptFailed",
 				"Page Timeout");
-	case 0x08: /* connection timeout */
+	case HCI_CONNECTION_TIMEOUT:
 		return dbus_message_new_error(msg,
 				ERROR_INTERFACE ".ConnectionAttemptFailed",
 				"Connection Timeout");
-	case 0x10: /* connection accept timeout */
-	case 0x22: /* LMP response timeout */
-	case 0x28: /* instant passed - is this a timeout? */
+	case HCI_HOST_TIMEOUT:
+	case HCI_LMP_RESPONSE_TIMEOUT:
+	case HCI_INSTANT_PASSED: /* is this a timeout? */
 		return dbus_message_new_error(msg,
 					ERROR_INTERFACE ".AuthenticationTimeout",
 					"Authentication Timeout");
-	case 0x17: /* too frequent pairing attempts */
+	case HCI_REPEATED_ATTEMPTS: /* too frequent pairing attempts */
 		return dbus_message_new_error(msg,
 					ERROR_INTERFACE ".RepeatedAttempts",
 					"Repeated Attempts");
 
-	case 0x06:
-	case 0x18: /* pairing not allowed (e.g. gw rejected attempt) */
+	case HCI_PIN_OR_KEY_MISSING:
+	case HCI_PAIRING_NOT_ALLOWED: /* e.g. gw rejected attempt */
 		return dbus_message_new_error(msg,
 					ERROR_INTERFACE ".AuthenticationRejected",
 					"Authentication Rejected");
 
-	case 0x07: /* memory capacity */
-	case 0x09: /* connection limit */
-	case 0x0a: /* synchronous connection limit */
-	case 0x0d: /* limited resources */
-	case 0x13: /* user ended the connection */
-	case 0x14: /* terminated due to low resources */
-	case 0x16: /* connection terminated */
+	case HCI_MEMORY_FULL:
+	case HCI_MAX_NUMBER_OF_CONNECTIONS:
+	case HCI_MAX_NUMBER_OF_SCO_CONNECTIONS:
+	case HCI_REJECTED_LIMITED_RESOURCES:
+	case HCI_OE_USER_ENDED_CONNECTION:
+	case HCI_OE_LOW_RESOURCES:
+	case HCI_CONNECTION_TERMINATED:
 		return dbus_message_new_error(msg,
 					ERROR_INTERFACE ".AuthenticationCanceled",
 					"Authentication Canceled");
 
-	case 0x05: /* authentication failure */
-	case 0x0E: /* rejected due to security reasons - is this auth failure? */
-	case 0x25: /* encryption mode not acceptable - is this auth failure? */
-	case 0x26: /* link key cannot be changed - is this auth failure? */
-	case 0x29: /* pairing with unit key unsupported - is this auth failure? */
-	case 0x2f: /* insufficient security - is this auth failure? */
+	case HCI_AUTHENTICATION_FAILURE:
+	case HCI_REJECTED_SECURITY: /* is this auth failure? */
+	case HCI_ENCRYPTION_MODE_NOT_ACCEPTED: /* is this auth failure? */
+	case HCI_UNIT_LINK_KEY_USED: /* is this auth failure? */
+	case HCI_PAIRING_NOT_SUPPORTED: /* is this auth failure? */
+	case HCI_INSUFFICIENT_SECURITY: /* is this auth failure? */
 	default:
 		return dbus_message_new_error(msg,
 					ERROR_INTERFACE ".AuthenticationFailed",
-- 
1.7.7.6


  parent reply	other threads:[~2012-05-14 15:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-14 15:32 [RFC BlueZ v0 0/5] ACL disconnect reason Mikel Astiz
2012-05-14 15:33 ` [RFC BlueZ v0 1/5] doc: Add D-Bus signal to provide " Mikel Astiz
2012-05-14 15:33 ` Mikel Astiz [this message]
2012-07-18 11:49   ` [RFC BlueZ v0 2/5] Use defines instead of magic numbers Mikel Astiz
2012-07-18 12:23     ` Johan Hedberg
2012-05-14 15:33 ` [RFC BlueZ v0 3/5] Propagate disconnect reason to adapter Mikel Astiz
2012-05-14 15:33 ` [RFC BlueZ v0 4/5] Propagate disconnect reason to device Mikel Astiz
2012-05-14 15:33 ` [RFC BlueZ v0 5/5] Send D-Bus signal to propagate disconnect reason Mikel Astiz
2012-05-14 17:00 ` [RFC BlueZ v0 0/5] ACL " Luiz Augusto von Dentz
2012-05-15  6:46   ` Mikel Astiz
2012-05-15  8:10     ` Luiz Augusto von Dentz
2012-05-15  8:45       ` Mikel Astiz
2012-05-15  9:58         ` Luiz Augusto von Dentz
2012-05-16  7:12           ` Mikel Astiz
2012-05-16 14:28             ` Mike
2012-05-17 13:41               ` Luiz Augusto von Dentz
2012-05-17 14:00                 ` Mike

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=1337009584-17181-3-git-send-email-mikel.astiz.oss@gmail.com \
    --to=mikel.astiz.oss@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=mikel.astiz@bmw-carit.de \
    /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).