Thread (5 messages) 5 messages, 2 authors, 2013-05-08

Re: [RFC] Fix the kmod internal list behavior?

From: Lucas De Marchi <hidden>
Date: 2013-05-07 15:14:59

On Tue, May 7, 2013 at 10:54 AM, Yang Chengwei [off-list ref] wrote:
Hi List,

I just found that there are some minor issues in kmod iternal list
implementation implemented by libkmod-list.c.

Say
        1. list_node_append() is identical with list_node_insert_before(),
        so somehow the list_node_append() in fact does "prepend" operation.
To append to a circular list, you insert it *before* the first node.
So what's wrong here?
        2. just the same as list_node_append(), kmod_list_append() which
        invokes the former just do "prepend" operation rather than "append".
like I said, it's expected, since it's circular. kmod_list_append()
expect you to pass the head of the list, so to append to the list you
prepend to the first node, but you don't return it as the new head
unless it's the first one - check the return code.
I'd like to fix these internal APIs to do the operation suggested by its
name like
        1. drop list_node_append()
        2. call list_node_insert_after() to do "append" operation
        3. call list_mode_insert_before() to do "prepend" operation

Since the list here is circular linked, so I think these changes should
not break things except the test cases.

Any comments are appreciated.
Are you analyzing the source code or are you seeing a real problem?
It'd be nice to write a small test showing the problem - you can use
the testsuite for this... take test-alias as an example (i.e. you need
to link to the private lib).

regards
Lucas De Marchi
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help