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

pylibfdt/libfdt.i: fix backwards compatibility of return values #160

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

blmaier
Copy link
Contributor

@blmaier blmaier commented Nov 24, 2024

When our Python functions wrap fdt_getprop() they return a list containing [*data, length].

In SWIG v4.2 and earlier SWIG would discard *data if it is NULL/None. Causing the return value to just be length.

But starting in SWIG v4.3 it no longer discards *data. So the return value is now [None, length].

Handle this compatibility issue in libfdt.i by checking if the return value looks like the older 4.2 return value, and casting it to the newer style.

See swig/swig#2907
Fixes #159

When our Python functions wrap `fdt_getprop()` they return a list
containing `[*data, length]`.

In SWIG v4.2 and earlier SWIG would discard `*data` if it is NULL/None.
Causing the return value to just be `length`.

But starting in SWIG v4.3 it no longer discards `*data`. So the return
value is now `[None, length]`.

Handle this compatibility issue in libfdt.i by checking if the return
value looks like the older 4.2 return value, and casting it to the newer
style.

See swig/swig#2907

Signed-off-by: Brandon Maier <[email protected]>
@dgibson dgibson merged commit 9a969f3 into dgibson:main Nov 25, 2024
10 of 12 checks passed
@blmaier blmaier deleted the swig-4.3-fix branch November 25, 2024 02:37
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.

pylibfdt tests fail with SWIG 4.3.0
2 participants