Return-Path: From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= To: linux-bluetooth@vger.kernel.org Cc: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Subject: [PATCH BlueZ v2 02/14] mgmt: print error message when start_discovery fails Date: Wed, 15 Aug 2012 11:50:41 -0300 Message-Id: <1345042253-15053-3-git-send-email-jprvita@openbossa.org> In-Reply-To: <1345042253-15053-1-git-send-email-jprvita@openbossa.org> References: <1345042253-15053-1-git-send-email-jprvita@openbossa.org> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: If we fail to communicate with the MGMT socket is better to print the error message on the mgmtops plugin, where it really happened, instead of leaving this job to its users. --- src/adapter.c | 6 +----- src/mgmt.c | 7 +++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 8709a91..2ceac5c 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -1002,13 +1002,9 @@ struct btd_device *adapter_get_device(DBusConnection *conn, static gboolean discovery_cb(gpointer user_data) { struct btd_adapter *adapter = user_data; - int err; adapter->discov_id = 0; - - err = mgmt_start_discovery(adapter->dev_id); - if (err < 0) - error("start_discovery: %s (%d)", strerror(-err), -err); + mgmt_start_discovery(adapter->dev_id); return FALSE; } diff --git a/src/mgmt.c b/src/mgmt.c index b3ae776..38b102b 100644 --- a/src/mgmt.c +++ b/src/mgmt.c @@ -1990,8 +1990,11 @@ int mgmt_start_discovery(int index) cp->type = info->discov_type; - if (write(mgmt_sock, buf, sizeof(buf)) < 0) - return -errno; + if (write(mgmt_sock, buf, sizeof(buf)) < 0) { + int err = -errno; + error("failed to write to MGMT socket: %s", strerror(-err)); + return err; + } return 0; } -- 1.7.11.2