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

stream: Support zephyr/net_buf.h #9

Merged
merged 1 commit into from
Dec 5, 2024
Merged

stream: Support zephyr/net_buf.h #9

merged 1 commit into from
Dec 5, 2024

Conversation

M1cha
Copy link

@M1cha M1cha commented Dec 5, 2024

No description provided.

@M1cha M1cha requested a review from spanceac December 5, 2024 06:31
#include <ncs_version.h>
#endif

#if KERNEL_VERSION_NUMBER < 0x30300
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be 0x30100

#include <net/buf.h>
#else
#elif NCS_VERSION_NUMBER < 0x20800 && KERNEL_VERSION_NUMBER < 0x40000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even if there's no NCS_VERSION_NUMBER defined, as long as 3.1.0 <= KERNEL_VERSION_NUMBER < 4.0.0 this header should be included.

I also don't get the reason on why NRF SDK version should be involved in this. Does the NRF SDK modify the nebuf header path?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the nrf sdk cherry picks major changes into previous versions of zephyr. So currently, their zephyr version reports 3.7.99, but they already moved that header file because they cherry picked 4.0.0 stuff.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now, this approach can make things confusing. Please add this info in the commit description

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem correct for the case where NCS_VERSION_NUMBER is not defined.
IMO, the whole thing should look like:

#ifdef NCS_VERSION_NUMBER
// do checks based on NCS_VERSION_NUMBER
#else
// do checks based on KERNEL_VERSION_NUMBER
#endif

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not? if it's not defined it evaluates to 0 and 0 is smaller than 0x20800, effectively removing the check due to the &&

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but <zephyr/net/buf.h> is the header you want to include if kernel is <4.0.0(and also > than 3.1.0). If expression evaluates to 0 because NCS_VERSION_NUMBER is not defined, then you will include <zephyr/net_buf.h>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure?

  NCS_VERSION_NUMBER < 0x20800 && KERNEL_VERSION_NUMBER < 0x40000
= 0                  < 0x20800 && 0x30700               < 0x40000
= 1                            && 1
= 1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right. I was under the wrong impression that (NCS_VERSION_NUMBER < 0x20800) evaluates to 0 if NCS_VERSION_NUMBER is not defined. But you already explained above. Sorry!

While at it, also simplify the existing check.

We have to check sdk-nrf versions separately, because they cherry-pick
breaking changes into their zephyr-fork.
@M1cha M1cha merged commit bd3749d into main Dec 5, 2024
2 checks passed
@M1cha M1cha deleted the zephyr-4.0.0 branch December 5, 2024 10:03
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.

2 participants