ell.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] queue: Fix an l_queue_insert corner case
@ 2021-03-01 22:57 Andrew Zaborowski
  2021-03-02 15:03 ` Denis Kenzior
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Zaborowski @ 2021-03-01 22:57 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 910 bytes --]

The comment doc for the function says:

 * Inserts @data pointer at a position in the queue determined by the
 * compare @function.  @function should return > 0 if the @data (first
 * parameter) should be inserted after the current entry (second parameter).

however the function would insert @data after entries for which
@function returned a >= 0 value.  Change the check to > 0 to align with
the docs.
---
 ell/queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ell/queue.c b/ell/queue.c
index 86c52ed..b28eecf 100644
--- a/ell/queue.c
+++ b/ell/queue.c
@@ -299,7 +299,7 @@ LIB_EXPORT bool l_queue_insert(struct l_queue *queue, void *data,
 	for (prev = NULL, cur = queue->head; cur; prev = cur, cur = cur->next) {
 		cmp = function(entry->data, cur->data, user_data);
 
-		if (cmp >= 0)
+		if (cmp > 0)
 			continue;
 
 		if (prev == NULL) {
-- 
2.27.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-02 16:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 22:57 [PATCH] queue: Fix an l_queue_insert corner case Andrew Zaborowski
2021-03-02 15:03 ` Denis Kenzior
2021-03-02 15:21   ` Andrew Zaborowski
2021-03-02 16:30     ` Denis Kenzior

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).