From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.zx2c4.com (lists.zx2c4.com [165.227.139.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B05FC433F5 for ; Wed, 1 Jun 2022 09:36:13 +0000 (UTC) Received: by lists.zx2c4.com (OpenSMTPD) with ESMTP id 9daa76cd; Wed, 1 Jun 2022 09:33:55 +0000 (UTC) Received: from sym2.noone.org (sym.noone.org [178.63.92.236]) by lists.zx2c4.com (OpenSMTPD) with ESMTPS id 734c0e85 (TLSv1.2:ECDHE-ECDSA-AES256-GCM-SHA384:256:NO) for ; Wed, 1 Jun 2022 09:33:54 +0000 (UTC) Received: by sym2.noone.org (Postfix, from userid 1002) id 4LCkVV38s1zvjhV; Wed, 1 Jun 2022 11:33:54 +0200 (CEST) From: Tobias Klauser To: wireguard@lists.zx2c4.com Subject: [PATCH wireguard-go] tun: use ByteSliceToString from golang.org/x/sys/unix Date: Wed, 1 Jun 2022 11:33:54 +0200 Message-Id: <20220601093354.30833-1-tklauser@distanz.ch> X-Mailer: git-send-email 2.11.0 X-BeenThere: wireguard@lists.zx2c4.com X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: Development discussion of WireGuard List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: wireguard-bounces@lists.zx2c4.com Sender: "WireGuard" Use unix.ByteSliceToString in (*NativeTun).nameSloce to convert the TUNGETIFF ioctl result []byte to a string. Signed-off-by: Tobias Klauser --- tun/tun_linux.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tun/tun_linux.go b/tun/tun_linux.go index 89b716d9c70b..fbb8585ff449 100644 --- a/tun/tun_linux.go +++ b/tun/tun_linux.go @@ -9,7 +9,6 @@ package tun */ import ( - "bytes" "errors" "fmt" "os" @@ -321,11 +320,7 @@ func (tun *NativeTun) nameSlow() (string, error) { if errno != 0 { return "", fmt.Errorf("failed to get name of TUN device: %w", errno) } - name := ifr[:] - if i := bytes.IndexByte(name, 0); i != -1 { - name = name[:i] - } - return string(name), nil + return unix.ByteSliceToString(ifr[:]), nil } func (tun *NativeTun) Write(buf []byte, offset int) (int, error) { -- 2.36.1