From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 27 Mar 2012 14:50:17 +0300 From: Johan Hedberg To: Jefferson Delfes Cc: linux-bluetooth@vger.kernel.org Subject: Re: [PATCH BlueZ] gatttool: Update interactive prompt if connection is lost Message-ID: <20120327115017.GH14481@x220> References: <1332516126-6665-1-git-send-email-jefferson.delfes@openbossa.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <1332516126-6665-1-git-send-email-jefferson.delfes@openbossa.org> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: Hi Jefferson, On Fri, Mar 23, 2012, Jefferson Delfes wrote: > In interactive mode, when connection is lost, the prompt used to remain > in "connected" state. This patch fixes that case, by always showing the > actual connection state. > --- > attrib/interactive.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/attrib/interactive.c b/attrib/interactive.c > index be81424..47ddcf6 100644 > --- a/attrib/interactive.c > +++ b/attrib/interactive.c > @@ -56,6 +56,7 @@ struct characteristic_data { > }; > > static void cmd_help(int argcp, char **argvp); > +static void cmd_disconnect(int argcp, char **argvp); We should really try to avoid forward declarations when possible and the cmd_* functions should be reserved for real user entered commands and not as generic helpers as you're trying to do. So I'd factor out code from cmd_disconnect into a static helper function somewhere above both cmd_disconnect and cmd_connect, call it e.g. disconnect_io(). > +static gboolean channel_watcher(GIOChannel *chan, GIOCondition cond, > + gpointer user_data) > +{ > + cmd_disconnect(0, NULL); > + > + return TRUE; > +} Shouldn't this be returning FALSE instead of TRUE so that the watch doesn't get left hanging around GLibs watch lists wasting memory? Johan