From cd3a4f473164b9ef478232f0358b22bef6018609 Mon Sep 17 00:00:00 2001
From: Rosen Penev <rosenp@gmail.com>
Date: Thu, 16 Jul 2020 14:11:17 -0700
Subject: [PATCH] zerotier: fix compilation with GCC10

Patch taken from upstream.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 net/zerotier/Makefile                |  2 +-
 net/zerotier/patches/030-gcc10.patch | 39 ++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 net/zerotier/patches/030-gcc10.patch

diff --git a/net/zerotier/Makefile b/net/zerotier/Makefile
index 4baee00d3..72712473a 100644
--- a/net/zerotier/Makefile
+++ b/net/zerotier/Makefile
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=zerotier
 PKG_VERSION:=1.4.6
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/zerotier/ZeroTierOne/tar.gz/$(PKG_VERSION)?
diff --git a/net/zerotier/patches/030-gcc10.patch b/net/zerotier/patches/030-gcc10.patch
new file mode 100644
index 000000000..f55270db0
--- /dev/null
+++ b/net/zerotier/patches/030-gcc10.patch
@@ -0,0 +1,39 @@
+From cce4fa719d447c55d93458b25fa92717a2d61a60 Mon Sep 17 00:00:00 2001
+From: Jonas Witschel <diabonas@archlinux.org>
+Date: Tue, 14 Jul 2020 14:20:16 +0200
+Subject: [PATCH] Fix compilation with GCC 10 by providing explicit cast of
+ _bindingCount
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Compilation with GCC 10 fails with the following error:
+
+service/../osdep/Binder.hpp: In member function ‘void ZeroTier::Binder::refresh(ZeroTier::Phy<PHY_HANDLER_TYPE>&, unsigned int*, unsigned int, std::vector<ZeroTier::InetAddress>, INTERFACE_CHECKER&)’:
+service/../osdep/Binder.hpp:376:30: internal compiler error: unexpected expression ‘(std::__atomic_base<unsigned int>::__int_type)((ZeroTier::Binder*)this)->ZeroTier::Binder::_bindingCount’ of kind implicit_conv_expr
+  376 |       _bindings[_bindingCount].udpSock = udps;
+      |                              ^
+
+Help the compiler by providing an explicit cast to the appropriate type like it
+is already done in l. 338 of the same file.
+---
+ osdep/Binder.hpp | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/osdep/Binder.hpp b/osdep/Binder.hpp
+index 660e6f0c..a5bc85c9 100644
+--- a/osdep/Binder.hpp
++++ b/osdep/Binder.hpp
+@@ -373,9 +373,9 @@ class Binder
+ 					}
+ #endif // __LINUX__
+ 					if (_bindingCount < ZT_BINDER_MAX_BINDINGS) {
+-						_bindings[_bindingCount].udpSock = udps;
+-						_bindings[_bindingCount].tcpListenSock = tcps;
+-						_bindings[_bindingCount].address = ii->first;
++						_bindings[(unsigned int)_bindingCount].udpSock = udps;
++						_bindings[(unsigned int)_bindingCount].tcpListenSock = tcps;
++						_bindings[(unsigned int)_bindingCount].address = ii->first;
+ 						phy.setIfName(udps,(char*)ii->second.c_str(),(int)ii->second.length());
+ 						++_bindingCount;
+ 					}