Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v3 06/10] shared/timeout-glib: Check 0 id when removing timeout
Date: Fri, 30 Nov 2018 12:20:09 +0200
Message-ID: <20181130102013.29023-6-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20181130102013.29023-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If the id is 0 that makes it is invalid already.
---
 src/shared/timeout-glib.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/shared/timeout-glib.c b/src/shared/timeout-glib.c
index 4163bced7..fd71ca430 100644
--- a/src/shared/timeout-glib.c
+++ b/src/shared/timeout-glib.c
@@ -71,8 +71,12 @@ unsigned int timeout_add(unsigned int timeout, timeout_func_t func,
 
 void timeout_remove(unsigned int id)
 {
-	GSource *source = g_main_context_find_source_by_id(NULL, id);
+	GSource *source;
 
+	if (!id)
+		return;
+
+	source = g_main_context_find_source_by_id(NULL, id);
 	if (source)
 		g_source_destroy(source);
 }
-- 
2.17.2


  parent reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-30 10:20 [PATCH v3 01/10] share/mainloop: Add handling of NOTIFY_SOCKET Luiz Augusto von Dentz
2018-11-30 10:20 ` [PATCH v3 02/10] share/mainloop: Add watchdog support Luiz Augusto von Dentz
2018-11-30 10:20 ` [PATCH v3 03/10] tool/btmon-logger: Use mainloop_notify instead of sd_notify Luiz Augusto von Dentz
2018-11-30 10:20 ` [PATCH v3 04/10] core: Use mainloop_sd_notify " Luiz Augusto von Dentz
2018-11-30 10:20 ` [PATCH v3 05/10] core: Remove old code related to sd_notify Luiz Augusto von Dentz
2018-11-30 10:20 ` Luiz Augusto von Dentz [this message]
2018-11-30 10:20 ` [PATCH v3 07/10] shared/mainloop: Add mainloop_run_with_signal Luiz Augusto von Dentz
2018-11-30 10:20 ` [PATCH v3 08/10] shared/mainloop: Remove mainloop_set_signal Luiz Augusto von Dentz
2018-11-30 10:20 ` [PATCH v3 09/10] core: Make use of mainloop_run_with_signal Luiz Augusto von Dentz
2018-11-30 10:20 ` [PATCH v3 10/10] shared/tester: " Luiz Augusto von Dentz
2018-12-05 12:09 ` [PATCH v3 01/10] share/mainloop: Add handling of NOTIFY_SOCKET Luiz Augusto von Dentz

Reply instructions:

You may reply publically 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=20181130102013.29023-6-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org linux-bluetooth@archiver.kernel.org
	public-inbox-index linux-bluetooth


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/ public-inbox