Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1269802ybh; Thu, 16 Jul 2020 07:42:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXJ3Ug9mvKcCyLyCixSi2EcRmcxpBTts9RGUSZA0TEQbXAIWwKphsIebjAtWZb9U95o3XU X-Received: by 2002:a17:906:4050:: with SMTP id y16mr4202104ejj.541.1594910539664; Thu, 16 Jul 2020 07:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594910539; cv=none; d=google.com; s=arc-20160816; b=kwBcv6+1kDKj6gy89mWEdMafwyZDWl4BT19uK0nKL7qCt319tKZsPB8DytwKBFEC9+ ojKF16SGbZB1f50teRAis383DU8jV223i9538SSYbCMcfgnWPXMf5EzpVhxvBkXpEMDA 87wlpUk9VH+8nmkmVABBHAa1azUeJ0WXcsMgmsymvCO5TKjagwI2OoH6TRmXaoSJ5kIM eodjeCyz8V44OoWZP6gPlsDjNvFqTCLP/HcLcDk1txJKVm6ivJDkE9HaxPPxsVsqfC9f Z1DDnZfhKNIhszWYB5SotWkYXe/Ac8iJ2G+adaRpy4/+mMOv4lNWeoO1T6GVQ+L4MBQI 5Liw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=N8p3p3jz0fMt2ToJBd+WDqmzt1ibgDa1nsYklIDRTio=; b=jwapB0W171J5POtG9S1XQzQiyTs6pHZA7d7Q+T2No8zo551K3sr8mSZoddE7likYLg M9FLcfc3kfanWC5+nV8unT7apbkSv2tXbxvF380vumv6SqtGT+K41r+vqiPOVkei2HXT ZF6f2u7oVQ7nHo1J0xuwwZgEZ1Swk3xUhkYD1mv55iG61WK1Ug0l9BDtSWItl06H863U J8YVxjg7rTdlm5UsJYWZiR5yVwS8k/AsVB6GfKLq4uo1KeM98+SY0xdGCnC/HCG7anh+ FVdnoNSpX63VLXYrtbYGEUZo9ka120iDYj2i7ij71y1P0v4ujLqVCy5n+GdZuq80YQtb zCYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZLoncI7Y; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si3226550edo.175.2020.07.16.07.41.33; Thu, 16 Jul 2020 07:42:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZLoncI7Y; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728787AbgGPOkM (ORCPT + 99 others); Thu, 16 Jul 2020 10:40:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:56532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728589AbgGPOkL (ORCPT ); Thu, 16 Jul 2020 10:40:11 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 83878206F4; Thu, 16 Jul 2020 14:40:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594910410; bh=ujNWegicnWC2dCz6IXVHu+Nito8lZ9bXxVj1ekSbGOI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZLoncI7YSBYprMk9rNo3VLbjTkx83nzUJtD4g/tPXoelyS0nCOnUoFWCYVYWIojnP dBXL0yedre4azI1E8s43qwulZPD2XG1/6AeOB+C3pmtecYqhGAWYCVQUY0R3yhqBq8 IVDDOAutDNjqBZZVFxJlr8v6a9TviTFpe+6oQOuw= Received: by pali.im (Postfix) id 62016E7A; Thu, 16 Jul 2020 16:40:08 +0200 (CEST) Date: Thu, 16 Jul 2020 16:40:08 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Szymon Janc Cc: linux-bluetooth@vger.kernel.org, Luiz Augusto von Dentz Subject: Re: [PATCH] sap: Improve error messages Message-ID: <20200716144008.fcgxcqmqfashnwam@pali> References: <20200604232433.4951-1-pali@kernel.org> <4237143.LvFx2qVVIh@ix> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4237143.LvFx2qVVIh@ix> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On Monday 15 June 2020 11:48:20 Szymon Janc wrote: > Hi, > > On Friday, 5 June 2020 01:24:33 CEST Pali Rohár wrote: > > When bluetoohd daemon is starting, it prints following error messages: > > > > bluetoothd[19117]: profiles/sap/server.c:sap_server_register() Sap driver > > initialization failed. bluetoothd[19117]: sap-server: Operation not > > permitted (1) > > > > Initialization is failing because sap server is enabled only when > > bluetoothd daemon is started with --experimental option. > > > > And "Operation not permitted" is result of returning error code -1. > > > > This patch improves error messages. When --experimental option is not used > > then bluetoothd prints more explaining error message. And in case function > > sap_init() fails then -EOPNOTSUPP "Operation not supported" is returned > > instead of -EPERM (-1). > > --- > > profiles/sap/server.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/profiles/sap/server.c b/profiles/sap/server.c > > index 5de682a33..99ff80297 100644 > > --- a/profiles/sap/server.c > > +++ b/profiles/sap/server.c > > @@ -1353,9 +1353,14 @@ int sap_server_register(struct btd_adapter *adapter) > > GIOChannel *io; > > struct sap_server *server; > > > > + if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) { > > + error("Sap driver is disabled without --experimental > option"); > > + return -EOPNOTSUPP; > > + } > > + > > Maybe just make sap_init() fail if experimental is not enabled in sap-dummy.c? I guess this is what is already happening. But failure of sap_init() means that bluetoothd daemon prints error message that initialization failed as I wrote in commit message. Therefore I added another check for experimental flag with printing different error message which contains information why it failed. > This driver is usable only for profile qualification tests and nothing more. > And TBH I'm not sure why distros are enabling SAP in first place... > > > if (sap_init() < 0) { > > error("Sap driver initialization failed."); > > - return -1; > > + return -EOPNOTSUPP; > > } > > > > record = create_sap_record(SAP_SERVER_CHANNEL); > > > -- > pozdrawiam > Szymon Janc > >