tools/libs: don't set errno to negative values
cover tools/libs: don't set errno to negative values
There are a few places in the libs where errno is set to a negative value. Fix those.
Juergen Gross (4):
tools/libs/evtchn: don't set errno to negative values tools/libs/ctrl: don't set errno to a negative value tools/libs/guest: don't set errno to a negative value tools/libs/light: don't set errno to a negative value
tools/libs/ctrl/xc_domain.c | 4 +--- tools/libs/evtchn/freebsd.c | 2 +- tools/libs/evtchn/minios.c | 2 +- tools/libs/evtchn/netbsd.c | 2 +- tools/libs/evtchn/solaris.c | 2 +- tools/libs/guest/xg_dom_core.c | 2 +- tools/libs/light/libxl_linux.c | 2 +- 7 files changed, 7 insertions(+), 9 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/4 tools/libs/evtchn: don't set errno to negative values
Setting errno to a negative value makes no sense.
--- tools/libs/evtchn/freebsd.c | 2 +- tools/libs/evtchn/minios.c | 2 +- tools/libs/evtchn/netbsd.c | 2 +- tools/libs/evtchn/solaris.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
tools/libs/evtchn/freebsd.c +1 -1
@@ -58,7 +58,7 @@ int osdep_evtchn_close(xenevtchn_handle *xce)int osdep_evtchn_restrict (xenevtchn_handle *xce,domid_t domid) { - errno = -EOPNOTSUPP ; + errno =EOPNOTSUPP ;return -1 ; }
tools/libs/evtchn/minios.c +1 -1
@@ -143,7 +143,7 @@ int osdep_evtchn_close(xenevtchn_handle *xce)int osdep_evtchn_restrict (xenevtchn_handle *xce,domid_t domid) { - errno = -EOPNOTSUPP ; + errno =EOPNOTSUPP ;return -1 ; }
tools/libs/evtchn/netbsd.c +1 -1
@@ -53,7 +53,7 @@ int osdep_evtchn_close(xenevtchn_handle *xce)int osdep_evtchn_restrict (xenevtchn_handle *xce,domid_t domid) { - errno = -EOPNOTSUPP ; + errno =EOPNOTSUPP ;return -1 ; }
tools/libs/evtchn/solaris.c +1 -1
@@ -53,7 +53,7 @@ int osdep_evtchn_close(xenevtchn_handle *xce)int osdep_evtchn_restrict (xenevtchn_handle *xce,domid_t domid) { - errno = -EOPNOTSUPP ; + errno =EOPNOTSUPP ;return -1 ; }
Signature · 1 line
2.34.1
Re: [PATCH 1/4] tools/libs/evtchn: don't set errno to negative values
Quoted 1 line · Juergen Gross
Setting errno to a negative value makes no sense.
Quoted 1 line
Signed-off-by Juergen Gross <[email protected]>
PATCH 2/4 tools/libs/ctrl: don't set errno to a negative value
In reply to Juergen GrossThe claimed reason for setting errno to -1 is wrong. On x86 xc_domain_pod_target() will set errno to a sane value in the error case.
--- tools/libs/ctrl/xc_domain.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tools/libs/ctrl/xc_domain.c +1 -3
@@ -1293,9 +1293,7 @@ int xc_domain_get_pod_target(xc_interface *xch,uint64_t *pod_cache_pages, uint64_t *pod_entries) { -/* On x86 (above) xc_domain_pod_target will incorrectly return -1 -* with errno==-1 on error. Do the same for least surprise. */ - errno =-1 ; + errno =EOPNOTSUPP ;return -1 ; }#endif
Signature · 1 line
2.34.1
Re: [PATCH 2/4] tools/libs/ctrl: don't set errno to a negative value
Quoted 3 lines · Juergen Gross
The claimed reason for setting errno to -1 is wrong. On x86
xc_domain_pod_target()will set errno to a sane value in the error case.
Quoted 1 line
Signed-off-by Juergen Gross <[email protected]>
PATCH 3/4 tools/libs/guest: don't set errno to a negative value
In reply to Juergen GrossSetting errno to a negative error value makes no sense.
--- tools/libs/guest/xg_dom_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libs/guest/xg_dom_core.c +1 -1
@@ -855,7 +855,7 @@ int xc_dom_devicetree_file(struct xc_dom_image *dom, const char *filename)return -1 ;return 0 ;#else - errno = -EINVAL ; + errno =EINVAL ;return -1 ;#endif }
Signature · 1 line
2.34.1
Re: [PATCH 3/4] tools/libs/guest: don't set errno to a negative value
Quoted 1 line · Juergen Gross
Setting errno to a negative error value makes no sense.
Quoted 1 line
Signed-off-by Juergen Gross <[email protected]>
PATCH 4/4 tools/libs/light: don't set errno to a negative value
In reply to Juergen GrossSetting errno to a negative value makes no sense.
--- tools/libs/light/libxl_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libs/light/libxl_linux.c +1 -1
@@ -288,7 +288,7 @@ int libxl__pci_topology_init(libxl__gc *gc,if (i == num_devs) {LOG (ERROR ,"Too many devices" ); err =ERROR_FAIL ; - errno = -ENOSPC ; + errno =ENOSPC ; goto out; }
Signature · 1 line
2.34.1
Re: [PATCH 4/4] tools/libs/light: don't set errno to a negative value
Quoted 1 line · Juergen Gross
Setting errno to a negative value makes no sense.
Quoted 1 line
Signed-off-by Juergen Gross <[email protected]>
Re: [PATCH 4/4] tools/libs/light: don't set errno to a negative value
Quoted 8 lines · Andrew Cooper
Quoted 1 line · Juergen Gross
Setting errno to a negative value makes no sense.
Fixes e78e8b9bb649bQuoted 1 line
Signed-off-by Juergen Gross <[email protected]>Acked-by Andrew Cooper <[email protected]>
Do you want me to send the patches with the Fixes tags added?
TBH I didn't bother to do the research for those, as the wrong values don't seem to cause any harm today. I just stumbled over the issues and thought it would be a good idea to fix those.
Juergen
Re: [PATCH 4/4] tools/libs/light: don't set errno to a negative value
Quoted 8 lines · Juergen Gross
Quoted 7 lines · Andrew Cooper
Quoted 1 line · Juergen Gross
Setting errno to a negative value makes no sense.
Fixes e78e8b9bb649bQuoted 1 line
Signed-off-by Juergen Gross <[email protected]>
Quoted 7 lines
Quoted 1 line
Acked-by Andrew Cooper <[email protected]>Do you want me to send the patches with the Fixes tags added?
TBH I didn't bother to do the research for those, as the wrong values don't seem to cause any harm today. I just stumbled over the issues and thought it would be a good idea to fix those.
Given that there's nothing else to adjust, I was thinking of just fixing them on commit.
But we should backport these to all appropriate releases (cc Jan).
~Andrew