From patchwork Fri Jun 28 08:31:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Belouin X-Patchwork-Id: 11021637 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B4FD01575 for ; Fri, 28 Jun 2019 08:33:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8263286A4 for ; Fri, 28 Jun 2019 08:33:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9859E28701; Fri, 28 Jun 2019 08:33:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 393FF286A4 for ; Fri, 28 Jun 2019 08:33:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hgmIk-00006G-D6; Fri, 28 Jun 2019 08:32:10 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hgmIj-000069-1K for xen-devel@lists.xenproject.org; Fri, 28 Jun 2019 08:32:09 +0000 X-Inumbo-ID: 36c7efde-997f-11e9-8980-bc764e045a96 Received: from gandi.net (unknown [217.70.182.73]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 36c7efde-997f-11e9-8980-bc764e045a96; Fri, 28 Jun 2019 08:32:07 +0000 (UTC) Received: from diconico07.dev (unknown [IPv6:2001:4b98:beef:a:e7c:1fb4:ff55:f4a9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by gandi.net (Postfix) with ESMTPSA id 9CC1C16032C; Fri, 28 Jun 2019 08:32:06 +0000 (UTC) From: Nicolas Belouin To: xen-devel@lists.xenproject.org Date: Fri, 28 Jun 2019 10:31:48 +0200 Message-Id: <20190628083148.1747-1-nicolas.belouin@gandi.net> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2] golang/xenlight: Fix type issues with recent Go version X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , Nicolas Belouin , George Dunlap , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Newer versions of Go have become stricter on enforcing the no implicit conversions policy when using CGo. Specifically, the following two conversions are no longer allowed: - unsafe.Pointer being automatically cast to any C pointer - A pointer type other than unsafe.Pointer being automatically cast to C void * Fix this by adding explicit casts where necessary. Signed-off-by: Nicolas Belouin Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 53534d047e..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, 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(unsafe.Pointer(Ctx.logger)) + C.xtl_logger_destroy(Ctx.logger) return } @@ -1170,7 +1171,7 @@ func (Ctx *Context) ConsoleGetTty(id Domid, consNum int, conType ConsoleType) (p err = Error(-ret) return } - defer C.free(cpath) + defer C.free(unsafe.Pointer(cpath)) path = C.GoString(cpath) return @@ -1190,7 +1191,7 @@ func (Ctx *Context) PrimaryConsoleGetTty(domid uint32) (path string, err error) err = Error(-ret) return } - defer C.free(cpath) + defer C.free(unsafe.Pointer(cpath)) path = C.GoString(cpath) return