Commit 871e51d2d4 changed the sign on the xenlight error types (making the values negative, same as the C-generated constants), but failed to flip the sign in the Error() string function. The result is that ErrorNonspecific.String() prints "libxl error: 1" rather than the human-readable error message.
Get the error message index by inverting the error number once. Also, always print the actual error value, rather than the inverted value, for clarity. Signed-off-by: George Dunlap <george.dun...@citrix.com> --- CC: Nick Rosbrook <rosbro...@ainfosec.com> --- tools/golang/xenlight/xenlight.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 99de68320b..c80f622e6b 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -65,13 +65,14 @@ var libxlErrors = [...]string{ } func (e Error) Error() string { - if 0 < int(e) && int(e) < len(libxlErrors) { - s := libxlErrors[e] + eidx := -int(e) + if 0 < eidx && eidx < len(libxlErrors) { + s := libxlErrors[eidx] if s != "" { return s } } - return fmt.Sprintf("libxl error: %d", -e) + return fmt.Sprintf("libxl error: %d", e) } // Context represents a libxl_ctx. -- 2.24.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel