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

Fix return values attribute writes #2

Merged

Conversation

gizero
Copy link
Contributor

@gizero gizero commented Jul 28, 2014

This patchset makes a bunch of functions compliant with their interface as defined in iio.h. Those functions are supposed to return 0 on success, while their current implementation returns the number of bytes written instead.

The patch was verified against a previously failing scenario which uses iio_device_attr_write_longlong() only, but the same resolution should apply cleanly to all other affected functions.

Patches to different families of functions has been kept separate for clarity. Feel free to squash them down if this is more convenient for the repository commit policy.

make these functions return 0 on success instead of the number of
bytes written in accordance with the API
make these functions return 0 on success instead of the number of
bytes written, in accordance with the API
make the functions return 0 on success instead of the number of
bytes written, in accordance with the API
lclausen-adi pushed a commit that referenced this pull request Jul 30, 2014
@lclausen-adi lclausen-adi merged commit f6c0ba5 into analogdevicesinc:master Jul 30, 2014
@gizero gizero deleted the fix-return-values-attribute-writes branch July 31, 2014 06:03
pcercuei pushed a commit that referenced this pull request Apr 15, 2016
Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
@rgetz rgetz mentioned this pull request Oct 26, 2016
pcercuei added a commit that referenced this pull request Dec 12, 2016
rgetz added a commit that referenced this pull request Dec 16, 2016
rgetz added a commit that referenced this pull request Dec 27, 2016
rgetz added a commit that referenced this pull request Dec 28, 2016
rgetz added a commit that referenced this pull request Jan 10, 2017
rgetz added a commit that referenced this pull request Feb 7, 2017
rgetz added a commit that referenced this pull request Apr 3, 2020
CID 355432 (#2 of 2): Resource leak (RESOURCE_LEAK)
3. leaked_storage: Variable ddata going out of scope leaks the storage it points to.

Ensure we free anything that was allocated

Signed-off-by: Robin Getz <robin.getz@analog.com>
rgetz added a commit that referenced this pull request Mar 3, 2022
rgetz added a commit that referenced this pull request Mar 7, 2022
rgetz added a commit that referenced this pull request Mar 8, 2022
rgetz added a commit that referenced this pull request Mar 8, 2022
rgetz added a commit to rgetz/libiio that referenced this pull request Nov 10, 2023
In the past, we were only checking hostname, as a way to see if the
network was ready, but unfortunately - that doesn't work. The kernel
really only needs to have a hostname set for uname() to work, which is
what glibc and uclibc implement in gethostname().

So - now we check there is a working, configured ethernet card,
that supports mdns (ie. multicast) that is up before moving on to making
sure there is a hostname.

We also don't allow "none" or "(none)" to be the hostname until after
things time out (3 min).

This fixes analogdevicesinc#1072 and turns:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on (none)._iio._tcp.local." rclass 0x1 ttl 10 length 17
into:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16

and when you have multiple on network (with same name):
192.168.1.110:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16
192.168.1.110:5353 : answer pluto.local. A 192.168.1.110
192.168.1.115:5353 : answer _iio._tcp.local. PTR "iiod on pluto analogdevicesinc#2._iio._tcp.local." rclass 0x1 ttl 10 length 19
192.168.1.115:5353 : answer pluto-2.local. A 192.168.1.115

Signed-off-by: Robin Getz <rgetz@mathworks.com>
rgetz added a commit to rgetz/libiio that referenced this pull request Nov 10, 2023
In the past, we were only checking hostname, as a way to see if the
network was ready, but unfortunately - that doesn't work. The kernel
really only needs to have a hostname set for uname() to work, which is
what glibc and uclibc implement in gethostname().

So - now we check there is a working, configured ethernet card,
that supports mdns (ie. multicast) that is up before moving on to making
sure there is a hostname.

We also don't allow "none" or "(none)" to be the hostname until after
things time out (3 min).

This fixes analogdevicesinc#1072 and turns:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on (none)._iio._tcp.local." rclass 0x1 ttl 10 length 17
into:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16

and when you have multiple on network (with same name):
192.168.1.110:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16
192.168.1.110:5353 : answer pluto.local. A 192.168.1.110
192.168.1.115:5353 : answer _iio._tcp.local. PTR "iiod on pluto analogdevicesinc#2._iio._tcp.local." rclass 0x1 ttl 10 length 19
192.168.1.115:5353 : answer pluto-2.local. A 192.168.1.115

Signed-off-by: Robin Getz <rgetz@mathworks.com>
rgetz added a commit to rgetz/libiio that referenced this pull request Nov 10, 2023
In the past, we were only checking hostname, as a way to see if the
network was ready, but unfortunately - that doesn't work. The kernel
really only needs to have a hostname set for uname() to work, which is
what glibc and uclibc implement in gethostname().

So - now we check there is a working, configured ethernet card,
that supports mdns (ie. multicast) that is up before moving on to making
sure there is a hostname.

We also don't allow "none" or "(none)" to be the hostname until after
things time out (3 min).

This fixes analogdevicesinc#1072 and turns:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on (none)._iio._tcp.local." rclass 0x1 ttl 10 length 17
into:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16

and when you have multiple on network (with same name):
192.168.1.110:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16
192.168.1.110:5353 : answer pluto.local. A 192.168.1.110
192.168.1.115:5353 : answer _iio._tcp.local. PTR "iiod on pluto analogdevicesinc#2._iio._tcp.local." rclass 0x1 ttl 10 length 19
192.168.1.115:5353 : answer pluto-2.local. A 192.168.1.115

Signed-off-by: Robin Getz <rgetz@mathworks.com>
pcercuei pushed a commit that referenced this pull request Nov 13, 2023
In the past, we were only checking hostname, as a way to see if the
network was ready, but unfortunately - that doesn't work. The kernel
really only needs to have a hostname set for uname() to work, which is
what glibc and uclibc implement in gethostname().

So - now we check there is a working, configured ethernet card,
that supports mdns (ie. multicast) that is up before moving on to making
sure there is a hostname.

We also don't allow "none" or "(none)" to be the hostname until after
things time out (3 min).

This fixes #1072 and turns:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on (none)._iio._tcp.local." rclass 0x1 ttl 10 length 17
into:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16

and when you have multiple on network (with same name):
192.168.1.110:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16
192.168.1.110:5353 : answer pluto.local. A 192.168.1.110
192.168.1.115:5353 : answer _iio._tcp.local. PTR "iiod on pluto #2._iio._tcp.local." rclass 0x1 ttl 10 length 19
192.168.1.115:5353 : answer pluto-2.local. A 192.168.1.115

Signed-off-by: Robin Getz <rgetz@mathworks.com>
pcercuei pushed a commit that referenced this pull request Nov 13, 2023
In the past, we were only checking hostname, as a way to see if the
network was ready, but unfortunately - that doesn't work. The kernel
really only needs to have a hostname set for uname() to work, which is
what glibc and uclibc implement in gethostname().

So - now we check there is a working, configured ethernet card,
that supports mdns (ie. multicast) that is up before moving on to making
sure there is a hostname.

We also don't allow "none" or "(none)" to be the hostname until after
things time out (3 min).

This fixes #1072 and turns:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on (none)._iio._tcp.local." rclass 0x1 ttl 10 length 17
into:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16

and when you have multiple on network (with same name):
192.168.1.110:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16
192.168.1.110:5353 : answer pluto.local. A 192.168.1.110
192.168.1.115:5353 : answer _iio._tcp.local. PTR "iiod on pluto #2._iio._tcp.local." rclass 0x1 ttl 10 length 19
192.168.1.115:5353 : answer pluto-2.local. A 192.168.1.115

Signed-off-by: Robin Getz <rgetz@mathworks.com>
[pcercuei: change %d to %ld in print format string]
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
pcercuei pushed a commit that referenced this pull request Nov 13, 2023
In the past, we were only checking hostname, as a way to see if the
network was ready, but unfortunately - that doesn't work. The kernel
really only needs to have a hostname set for uname() to work, which is
what glibc and uclibc implement in gethostname().

So - now we check there is a working, configured ethernet card,
that supports mdns (ie. multicast) that is up before moving on to making
sure there is a hostname.

We also don't allow "none" or "(none)" to be the hostname until after
things time out (3 min).

This fixes #1072 and turns:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on (none)._iio._tcp.local." rclass 0x1 ttl 10 length 17
into:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16

and when you have multiple on network (with same name):
192.168.1.110:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16
192.168.1.110:5353 : answer pluto.local. A 192.168.1.110
192.168.1.115:5353 : answer _iio._tcp.local. PTR "iiod on pluto #2._iio._tcp.local." rclass 0x1 ttl 10 length 19
192.168.1.115:5353 : answer pluto-2.local. A 192.168.1.115

Signed-off-by: Robin Getz <rgetz@mathworks.com>
[pcercuei: change %d to %ld in print format string]
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
SRaus pushed a commit that referenced this pull request Feb 27, 2024
In the past, we were only checking hostname, as a way to see if the
network was ready, but unfortunately - that doesn't work. The kernel
really only needs to have a hostname set for uname() to work, which is
what glibc and uclibc implement in gethostname().

So - now we check there is a working, configured ethernet card,
that supports mdns (ie. multicast) that is up before moving on to making
sure there is a hostname.

We also don't allow "none" or "(none)" to be the hostname until after
things time out (3 min).

This fixes #1072 and turns:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on (none)._iio._tcp.local." rclass 0x1 ttl 10 length 17
into:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16

and when you have multiple on network (with same name):
192.168.1.110:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16
192.168.1.110:5353 : answer pluto.local. A 192.168.1.110
192.168.1.115:5353 : answer _iio._tcp.local. PTR "iiod on pluto #2._iio._tcp.local." rclass 0x1 ttl 10 length 19
192.168.1.115:5353 : answer pluto-2.local. A 192.168.1.115

Signed-off-by: Robin Getz <rgetz@mathworks.com>
[pcercuei: change %d to %ld in print format string]
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
(cherry picked from commit 38483f3)
SRaus pushed a commit that referenced this pull request Feb 28, 2024
In the past, we were only checking hostname, as a way to see if the
network was ready, but unfortunately - that doesn't work. The kernel
really only needs to have a hostname set for uname() to work, which is
what glibc and uclibc implement in gethostname().

So - now we check there is a working, configured ethernet card,
that supports mdns (ie. multicast) that is up before moving on to making
sure there is a hostname.

We also don't allow "none" or "(none)" to be the hostname until after
things time out (3 min).

This fixes #1072 and turns:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on (none)._iio._tcp.local." rclass 0x1 ttl 10 length 17
into:
192.168.2.1:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16

and when you have multiple on network (with same name):
192.168.1.110:5353 : answer _iio._tcp.local. PTR "iiod on pluto._iio._tcp.local." rclass 0x1 ttl 10 length 16
192.168.1.110:5353 : answer pluto.local. A 192.168.1.110
192.168.1.115:5353 : answer _iio._tcp.local. PTR "iiod on pluto #2._iio._tcp.local." rclass 0x1 ttl 10 length 19
192.168.1.115:5353 : answer pluto-2.local. A 192.168.1.115

Signed-off-by: Robin Getz <rgetz@mathworks.com>
[pcercuei: change %d to %ld in print format string]
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
(cherry picked from commit 38483f3)
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