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

uci: auto-load package in ctx.foreach() and ctx.get_first() #126

Merged
merged 1 commit into from
Nov 23, 2022

Conversation

jow-
Copy link
Owner

@jow- jow- commented Nov 23, 2022

Functions that use uci_lookup_ptr() internally, such as ctx.get(), ctx.set() or ctx.delete(), implicitly load the given configuration name while the higher level functions ctx.foreach() or ctx.get_first() do not.

This behaviour violates the principle of least surprise and might lead to non-deterministic program behavior as the outcome of these functions depends on prior uci operations performed on the cursor.

Fix this issue by invoking uci_load() internally in case the given uci package name cannot be found in the cursor's package cache.

Signed-off-by: Jo-Philipp Wich jo@mein.io

Functions that use `uci_lookup_ptr()` internally, such as `ctx.get()`,
`ctx.set()` or `ctx.delete()`, implicitly load the given configuration
name while the higher level functions `ctx.foreach()` or `ctx.get_first()`
do not.

This behaviour violates the principle of least surprise and might lead to
non-deterministic program behavior as the outcome of these functions
depends on prior uci operations performed on the cursor.

Fix this issue by invoking `uci_load()` internally in case the given
uci package name cannot be found in the cursor's package cache.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
@jow- jow- merged commit 191a536 into master Nov 23, 2022
@jow- jow- deleted the uci-autoload-package branch November 23, 2022 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant