Skip to content

Why a null pointer here? #109

Description

@MaSven

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).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions