tools/xenpm: fix FreeBSD build
PATCH 1/1 tools/xenpm: fix FreeBSD build
ENODATA is not defined on FreeBSD:
xenpm.c:1380:17: error: use of undeclared identifier 'ENODATA'
1380 | errno = ENODATA;
| ^
1 error generated.
--- tools/misc/xenpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/misc/xenpm.c +1 -1
@@ -1377,7 +1377,7 @@ static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te {case 0 :/* This CPU isn't online or can't query this MSR */ - errno =ENODATA ; + errno =ENODEV ;return -1 ;case 1 :
Signature · 1 line
2.53.0
Quoted 9 lines · Roger Pau Monne
ENODATA is not defined on FreeBSD:
xenpm.c:1380:17: error: use of undeclared identifier 'ENODATA'
1380 | errno = ENODATA;
| ^
1 error generated.Fixes edb657887a60 ("xenpm: Add get-core-temp subcommand")Signed-off-by Roger Pau Monné <[email protected]>
Quoted 18 lines · Roger Pau Monne
ENODATA is not defined on FreeBSD:
xenpm.c:1380:17: error: use of undeclared identifier 'ENODATA'
1380 | errno = ENODATA;
| ^
1 error generated.Fixes edb657887a60 ("xenpm: Add get-core-temp subcommand")Signed-off-by Roger Pau Monné <[email protected]>--- tools/misc/xenpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/misc/xenpm.c +0
-0
tools/misc/xenpm.c static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te · line 1381
Quoted 6 lines
tools/misc/xenpm.c +1
-1@@ -1377,7 +1377,7 @@ static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te {case 0 :/* This CPU isn't online or can't query this MSR */ - errno =ENODATA ; + errno =ENODEV ;return -1 ;
"No such device", however, isn't quite what we want to convey here. If no better error code can be found that's available on FreeBSD and Linux, I'm inclined to suggest that we stick to ENODATA where available.
Jan
Quoted 14 lines · Jan Beulich
Quoted 13 lines · Roger Pau Monne
ENODATA is not defined on FreeBSD:
xenpm.c:1380:17: error: use of undeclared identifier 'ENODATA'
1380 | errno = ENODATA;
| ^
1 error generated.Fixes edb657887a60 ("xenpm: Add get-core-temp subcommand")Signed-off-by Roger Pau Monné <[email protected]>--- tools/misc/xenpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
tools/misc/xenpm.c static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te · line 1381
Quoted 11 lines
tools/misc/xenpm.c +1
-1@@ -1377,7 +1377,7 @@ static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te {case 0 :/* This CPU isn't online or can't query this MSR */ - errno =ENODATA ; + errno =ENODEV ;return -1 ;"No such device", however, isn't quite what we want to convey here. If no better error code can be found that's available on FreeBSD and Linux, I'm inclined to suggest that we stick to ENODATA where available.
Seems like a lot of complexity, for very limited usefulness. The only usage of errno is to be printed in the error message, and for the purposes of this function ENODEV is already unique in the function, as ENODATA was.
FWIW, I think ENODEV is not that far fetched: the CPU being offline or the MSR not being present seems like what you would convey by using ENODEV.
Thanks, Roger.
Quoted 16 lines · Roger Pau Monné
Quoted 14 lines · Jan Beulich
tools/misc/xenpm.c static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te · line 1381
Quoted 9 lines · Roger Pau Monne
tools/misc/xenpm.c +1
-1@@ -1377,7 +1377,7 @@ static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te {case 0 :/* This CPU isn't online or can't query this MSR */ - errno =ENODATA ; + errno =ENODEV ;return -1 ;"No such device", however, isn't quite what we want to convey here. If no better error code can be found that's available on FreeBSD and Linux, I'm inclined to suggest that we stick to ENODATA where available.
Quoted 1 line
Seems like a lot of complexity, for very limited usefulness.
What's complex about
#ifndef ENODATA
# define ENODATA ENODEV #endif
(perhaps with a brief comment)?
Quoted 4 lines
The only
usage of errno is to be printed in the error message, and for the purposes of this function ENODEV is already unique in the function, as ENODATA was.
Right, but "No data available" is more precise than "No such device".
Quoted 3 lines
FWIW, I think ENODEV is not that far fetched: the CPU being offline or the MSR not being present seems like what you would convey by using ENODEV.
Yes, there is a connection. Hence I'm not outright opposed, yet I think we can do better.
Formally Anthony is the maintainer of the file, so in a case like this one maybe he ought to have the final say?
Jan
Quoted 19 lines · Jan Beulich
Quoted 16 lines · Roger Pau Monné
Quoted 14 lines · Jan Beulich
tools/misc/xenpm.c static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te · line 1381
Quoted 9 lines · Roger Pau Monne
tools/misc/xenpm.c +1
-1@@ -1377,7 +1377,7 @@ static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te {case 0 :/* This CPU isn't online or can't query this MSR */ - errno =ENODATA ; + errno =ENODEV ;return -1 ;"No such device", however, isn't quite what we want to convey here. If no better error code can be found that's available on FreeBSD and Linux, I'm inclined to suggest that we stick to ENODATA where available.
Quoted 1 line
Seems like a lot of complexity, for very limited usefulness.
Quoted 7 lines
What's complex about
#ifndef ENODATA
# define ENODATA ENODEV #endif(perhaps with a brief comment)?
IMO it's best if we can avoid instances of ENODATA in the toolstack code base, specially if it's individual ones like this that can be fixed. Otherwise new instances might appear elsewhere, and we don't want to be adding this bodge everywhere if avoidable.
If we had a sizable usage of ENODATA in the code base I would indeed recommend such define approach.
Quoted 11 lines
Quoted 4 lines
The only
usage of errno is to be printed in the error message, and for the purposes of this function ENODEV is already unique in the function, as ENODATA was.Right, but "No data available" is more precise than "No such device".
Quoted 3 lines
FWIW, I think ENODEV is not that far fetched: the CPU being offline or the MSR not being present seems like what you would convey by using ENODEV.
Quoted 5 lines
Yes, there is a connection. Hence I'm not outright opposed, yet I think we can do better.
Formally Anthony is the maintainer of the file, so in a case like this one maybe he ought to have the final say?
I'm fine with letting Anthony resolve.
Thanks, Roger.
Anthony PERARD
Acked-byQuoted 28 lines · Roger Pau Monné
Quoted 19 lines · Jan Beulich
Quoted 16 lines · Roger Pau Monné
Quoted 14 lines · Jan Beulich
tools/misc/xenpm.c static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te · line 1381
Quoted 9 lines · Roger Pau Monne
tools/misc/xenpm.c +1
-1@@ -1377,7 +1377,7 @@ static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te {case 0 :/* This CPU isn't online or can't query this MSR */ - errno =ENODATA ; + errno =ENODEV ;return -1 ;"No such device", however, isn't quite what we want to convey here. If no better error code can be found that's available on FreeBSD and Linux, I'm inclined to suggest that we stick to ENODATA where available.
Quoted 1 line
Seems like a lot of complexity, for very limited usefulness.
Quoted 7 lines
What's complex about
#ifndef ENODATA
# define ENODATA ENODEV #endif(perhaps with a brief comment)?
Quoted 7 lines
IMO it's best if we can avoid instances of ENODATA in the toolstack code base, specially if it's individual ones like this that can be fixed. Otherwise new instances might appear elsewhere, and we don't want to be adding this bodge everywhere if avoidable.
If we had a sizable usage of ENODATA in the code base I would indeed recommend such define approach.
Yeah, let's just use ENODEV on every platform in this case.
We already have ENODATA translated to ENOENT in libxl (for privcmd), so let's not add a different translation here.
So patch looks fine to me as is:
As for the error message, patch welcome ;-).
Thanks,
--
| Vates
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
Le 21/04/2026 à 17:36, Roger Pau Monne a écrit :
Quoted 18 lines
ENODATA is not defined on FreeBSD:
xenpm.c:1380:17: error: use of undeclared identifier 'ENODATA'
1380 | errno = ENODATA;
| ^
1 error generated.Fixes edb657887a60 ("xenpm: Add get-core-temp subcommand")Signed-off-by Roger Pau Monné <[email protected]>--- tools/misc/xenpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/misc/xenpm.c +0
-0
tools/misc/xenpm.c static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te · line 1383
Quoted 8 lines
tools/misc/xenpm.c +1
-1@@ -1377,7 +1377,7 @@ static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te {case 0 :/* This CPU isn't online or can't query this MSR */ - errno =ENODATA ; + errno =ENODEV ;return -1 ;case 1 :
I wasn't aware ENODATA wasn't available on some BSDs. Even though it's supposed to be a part of POSIX.
Regardless,
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
Quoted 26 lines · Teddy Astie
Le 21/04/2026 à 17:36, Roger Pau Monne a écrit :
Quoted 25 lines
ENODATA is not defined on FreeBSD:
xenpm.c:1380:17: error: use of undeclared identifier 'ENODATA'
1380 | errno = ENODATA;
| ^
1 error generated.Fixes edb657887a60 ("xenpm: Add get-core-temp subcommand")Signed-off-by Roger Pau Monné <[email protected]>--- tools/misc/xenpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/misc/xenpm.c +1
-1@@ -1377,7 +1377,7 @@ static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te {case 0 :/* This CPU isn't online or can't query this MSR */ - errno =ENODATA ; + errno =ENODEV ;return -1 ;
Quoted 4 lines
tools/misc/xenpm.c static int fetch_dts_temp(xc_interface *xch, uint32_t cpu, bool package, int *te · line 1383
Quoted 1 line
tools/misc/xenpm.c +0
-0case 1 :I wasn't aware ENODATA wasn't available on some BSDs. Even though it's supposed to be a part of POSIX.
Not in the last version I think?
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/errno.h.html
Regards, Roger.