golang/xenlight: Use the most generic pointer for xennoollog
diff mbox series

Message ID 20190718213319.4036-1-george.dunlap@citrix.com
State New
Headers show
Series
  • golang/xenlight: Use the most generic pointer for xennoollog
Related show

Commit Message

George Dunlap July 18, 2019, 9:33 p.m. UTC
From: Nicolas Belouin <nicolas.belouin@gandi.net>

It makes more sense for Ctx to contain the generic C.xentoollog_logger
type, rather than the specific type we end up assigning to it.  This
also allows one fewer cast.

Signed-off-by: Nicolas Belouin <nicolas.belouin@gandi.net>
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
---

Nicolas' submitted a patch fixing casts as well as making this change,
at my suggestion; but I ended up checking in an earlier patch that
fixed casts but didn't make this change.

CC: Ian Jackson <ian.jackson@citrix.com>
CC: Wei Liu <wl@xen.org>
CC: Nicolas Belouin <nicolas.belouin@gandi.net>
---
 tools/golang/xenlight/xenlight.go | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go
index f5d171c2d5..a2af6f6ef9 100644
--- a/tools/golang/xenlight/xenlight.go
+++ b/tools/golang/xenlight/xenlight.go
@@ -122,7 +122,7 @@  type Uuid C.libxl_uuid
 
 type Context struct {
 	ctx    *C.libxl_ctx
-	logger *C.xentoollog_logger_stdiostream
+	logger *C.xentoollog_logger
 }
 
 type Hwcap []C.uint32_t
@@ -847,14 +847,15 @@  func (Ctx *Context) Open() (err error) {
 		return
 	}
 
-	Ctx.logger = C.xtl_createlogger_stdiostream(C.stderr, C.XTL_ERROR, 0)
+	Ctx.logger = (*C.xentoollog_logger)(unsafe.Pointer(
+		C.xtl_createlogger_stdiostream(C.stderr, C.XTL_ERROR, 0)))
 	if Ctx.logger == nil {
 		err = fmt.Errorf("Cannot open stdiostream")
 		return
 	}
 
 	ret := C.libxl_ctx_alloc(&Ctx.ctx, C.LIBXL_VERSION,
-		0, (*C.xentoollog_logger)(unsafe.Pointer(Ctx.logger)))
+		0, Ctx.logger)
 
 	if ret != 0 {
 		err = Error(-ret)
@@ -869,7 +870,7 @@  func (Ctx *Context) Close() (err error) {
 	if ret != 0 {
 		err = Error(-ret)
 	}
-	C.xtl_logger_destroy((*C.xentoollog_logger)(unsafe.Pointer(Ctx.logger)))
+	C.xtl_logger_destroy(Ctx.logger)
 	return
 }