Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index bugfix and papercuts #224

Closed
wants to merge 7 commits into from

Conversation

evelikov
Copy link
Collaborator

@evelikov evelikov commented Nov 4, 2024

While looking at how to make the index API properly handle error conditions, I noticed that we completely broke the API.

The first commit fixes that + reintroduces earlier proposal of mine. The initial counter argument had a good point but was a bit absolute (aka thinking of a extreme case, that isn't applicable to us).

The rest are bunch of paper cuts, that I've accumulated as part of the initial goal.

/cc @stoeckmann can you check the first commit? can I offer some 🍪 for adding an in-tree test?

Random notes:

  • there is only one external user (AFAICT) of the regressed API 😅
  • a "test-needed" label to tag PRs (merged or not) would be awesome
    • cannot create labels or I would have done it already 😢
  • index_value::priority is ignored when dumping... unlike the depmod equivalent
  • de-duplicating and dog-fooding the dumping API across libkmod and depmod
    • introduce new one and deprecate the old?

@evelikov evelikov marked this pull request as draft November 4, 2024 15:21
@evelikov
Copy link
Collaborator Author

evelikov commented Nov 4, 2024

Some brown paperbag fixes 🤦

@evelikov evelikov marked this pull request as ready for review November 4, 2024 15:32
libkmod/libkmod-index.c Outdated Show resolved Hide resolved
libkmod/libkmod-index.c Outdated Show resolved Hide resolved
libkmod/libkmod-index.c Outdated Show resolved Hide resolved
libkmod/libkmod-index.c Show resolved Hide resolved
libkmod/libkmod.c Show resolved Hide resolved
For non-alias indexes prefix is an empty string, where
strbuf_pushchars() returns the number of characters added to the strbuf.

Since those are zero, we end up completely skipping the dump process.

Cc: Tobias Stoeckmann <[email protected]>
Fixes: 889d02b ("libkmod: check strbuf return values")
Signed-off-by: Emil Velikov <[email protected]>
As seen with previous commit, the way we pass an empty string to
index_{,mm_}dump() is very error prone.

Swap that with a bool, which makes things a lot more obvious.

Signed-off-by: Emil Velikov <[email protected]>
The compiler already creates an empty string as applicable, drop the
extra variable.

Signed-off-by: Emil Velikov <[email protected]>
Create a simple helper and reuse it instead of duplicating code.

Signed-off-by: Emil Velikov <[email protected]>
The callers are interested if the file is within the list of builtins or
not. So change the return type and push the free() down the stack.

Signed-off-by: Emil Velikov <[email protected]>
The index_mm_{search,read,dump}* API does not mutate the index_mm
struct. So let's annotate it as constant.

Signed-off-by: Emil Velikov <[email protected]>
libkmod/libkmod.c Show resolved Hide resolved
@lucasdemarchi
Copy link
Contributor

@stoeckmann are you ok with this version?

@stoeckmann
Copy link
Contributor

@stoeckmann are you ok with this version?

Won't stop merge process. I'd prefer _cleanup_free_ but it's not like this is the only function which does it manually.

lucasdemarchi pushed a commit that referenced this pull request Nov 7, 2024
For non-alias indexes prefix is an empty string, where
strbuf_pushchars() returns the number of characters added to the strbuf.

Since those are zero, we end up completely skipping the dump process.

Cc: Tobias Stoeckmann <[email protected]>
Fixes: 889d02b ("libkmod: check strbuf return values")
Signed-off-by: Emil Velikov <[email protected]>
Link: #224
Signed-off-by: Lucas De Marchi <[email protected]>
lucasdemarchi pushed a commit that referenced this pull request Nov 7, 2024
As seen with previous commit, the way we pass an empty string to
index_{,mm_}dump() is very error prone.

Swap that with a bool, which makes things a lot more obvious.

Signed-off-by: Emil Velikov <[email protected]>
Link: #224
Signed-off-by: Lucas De Marchi <[email protected]>
lucasdemarchi pushed a commit that referenced this pull request Nov 7, 2024
Signed-off-by: Emil Velikov <[email protected]>
Link: #224
Signed-off-by: Lucas De Marchi <[email protected]>
lucasdemarchi pushed a commit that referenced this pull request Nov 7, 2024
The compiler already creates an empty string as applicable, drop the
extra variable.

Signed-off-by: Emil Velikov <[email protected]>
Link: #224
Signed-off-by: Lucas De Marchi <[email protected]>
lucasdemarchi pushed a commit that referenced this pull request Nov 7, 2024
Create a simple helper and reuse it instead of duplicating code.

Signed-off-by: Emil Velikov <[email protected]>
Link: #224
Signed-off-by: Lucas De Marchi <[email protected]>
lucasdemarchi pushed a commit that referenced this pull request Nov 7, 2024
The callers are interested if the file is within the list of builtins or
not. So change the return type and push the free() down the stack.

Signed-off-by: Emil Velikov <[email protected]>
Link: #224
Signed-off-by: Lucas De Marchi <[email protected]>
lucasdemarchi pushed a commit that referenced this pull request Nov 7, 2024
The index_mm_{search,read,dump}* API does not mutate the index_mm
struct. So let's annotate it as constant.

Signed-off-by: Emil Velikov <[email protected]>
Link: #224
Signed-off-by: Lucas De Marchi <[email protected]>
@lucasdemarchi
Copy link
Contributor

@stoeckmann agreed. I created #233 so we don't forget. Let's see what is the clang-analyzer situation with that. Applied, thanks.

@evelikov
Copy link
Collaborator Author

We need tests for kmod_dump_index with all the different indexen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants