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

Why a null pointer here? #109

Open
MaSven opened this issue Dec 17, 2022 · 0 comments
Open

Why a null pointer here? #109

MaSven opened this issue Dec 17, 2022 · 0 comments

Comments

@MaSven
Copy link

MaSven commented Dec 17, 2022

I was reading the code and had the same question and found the source for this. This is because, that after the status and length of the array gets sent, saned also sends if the pointer to the struct is null.

The codeflow for this begins here
https://gitlab.com/sane-project/backends/-/blob/master/sanei/sanei_net.c#L77
This function calls sanei_w_word to send the array length here https://gitlab.com/sane-project/backends/-/blob/master/sanei/sanei_wire.c#L193. After that for each element in the array, it calls sanei_w_device_ptr which we can see here https://gitlab.com/sane-project/backends/-/blob/master/sanei/sanei_wire.c#L237. And in this function, we can see here https://gitlab.com/sane-project/backends/-/blob/master/sanei/sanei_wire.c#L276, that saned also sents, if the pointer which they want to sent in null or not. So, that is why there comes also a null pointer.

I hope this helps.
Btw good code clear to read.

In the docs, this is documented as follow

A pointer is encoded by a word that indicates whether the pointer is a NULL-pointer which is then followed by the value that the pointer points to (in the case of a non-NULL pointer; in the case of a NULL pointer, no bytes are encoded for the pointer value).
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

No branches or pull requests

1 participant