[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 6/9] golang/xenlight: Errors are negative


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: George Dunlap <george.dunlap@xxxxxxxxxx>
  • Date: Fri, 27 Dec 2019 16:32:21 +0000
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@xxxxxxxxxx; spf=Pass smtp.mailfrom=George.Dunlap@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>
  • Delivery-date: Fri, 27 Dec 2019 16:32:51 +0000
  • Ironport-sdr: ddYDGCptShwUPMFvFwd0FVHAjid1Wf8+QxNzn/RShDzsWiG30IpjVkO+uPQ3C2wiFxHaVZRbEi sSqUs4Hm92Kh6+PEQGZ1JHRbNADYbKDLXT7y76vk4ajOaZJd361c1MV3T9BKgJyK2jLrdiHe5K qYFW1gvkaXd1M1mFT7A6iQ0JO6MjrqDUw69imNksj6mUWgWp/+C7Es0c7SkSenkxWqtgTQEIJU GKTHJHe+CIM/dPJPW3E/j6t2CsAmLNXe3ykWZ7O+nehjjaRYhdLGNyLwjnKANclLOrxHZkad1q ilU=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.dunlap@xxxxxxxxxx>
---
CC: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.