Skip to content

Commit f555d23

Browse files
committed
Fix warnings on Android about unused variables/methods
Add the things we do not use to the print message to avoid ifdefs around the otherwise unused variables. Change-Id: I33d1d04b59c62e87ab61d768a7201124ccdabd07 Signed-off-by: Arne Schwabe <[email protected]>
1 parent 6db186e commit f555d23

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
-DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=28 \
5959
-DCMAKE_ANDROID_ARCH_ABI=${{ matrix.abi }} \
6060
-DOPENSSL_ROOT_DIR=${VCPKG_INSTALLED_DIR}/${{ matrix.vcpkg_triplet }} \
61-
-DENABLE_PKCS11=false -DBUILD_TESTING=true -DENABLE_LZO=false -DUSE_WERROR=no
61+
-DENABLE_PKCS11=false -DBUILD_TESTING=true -DENABLE_LZO=false
6262
- name: Build OpenVPN Android binary with cmake
6363
run: cmake --build openvpn-build
6464

src/openvpn/route.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ print_bypass_addresses(const struct route_bypass *rb)
102102
#define RTA_SUCCESS 1 /* route addition succeeded */
103103
#define RTA_EEXIST 2 /* route not added as it already exists */
104104

105+
#ifndef TARGET_ANDROID
105106
static bool
106107
add_bypass_address(struct route_bypass *rb, const in_addr_t a)
107108
{
@@ -123,6 +124,7 @@ add_bypass_address(struct route_bypass *rb, const in_addr_t a)
123124
return false;
124125
}
125126
}
127+
#endif
126128

127129
struct route_option_list *
128130
new_route_option_list(struct gc_arena *a)
@@ -2035,9 +2037,7 @@ delete_route(struct route_ipv4 *r, const struct tuntap *tt, unsigned int flags,
20352037
#if !defined(TARGET_AIX)
20362038
const char *netmask;
20372039
#endif
2038-
#if !defined(TARGET_ANDROID)
20392040
const char *gateway;
2040-
#endif
20412041
#else /* if !defined(TARGET_LINUX) */
20422042
int metric;
20432043
#endif
@@ -2056,9 +2056,7 @@ delete_route(struct route_ipv4 *r, const struct tuntap *tt, unsigned int flags,
20562056
#if !defined(TARGET_AIX)
20572057
netmask = print_in_addr_t(r->netmask, 0, &gc);
20582058
#endif
2059-
#if !defined(TARGET_ANDROID)
20602059
gateway = print_in_addr_t(r->gateway, 0, &gc);
2061-
#endif
20622060
#endif
20632061

20642062
is_local_route = local_route(r->network, r->netmask, r->gateway, rgi);
@@ -2165,9 +2163,13 @@ delete_route(struct route_ipv4 *r, const struct tuntap *tt, unsigned int flags,
21652163
openvpn_execve_check(&argv, es, 0, "ERROR: OpenBSD/NetBSD route delete command failed");
21662164

21672165
#elif defined(TARGET_ANDROID)
2166+
/* Avoids the unused variables warnings that all other platforms use
2167+
* by adding them to the error message. */
21682168
msg(D_ROUTE_DEBUG, "Deleting routes on Android is not possible/not "
21692169
"needed. The VpnService API allows routes to be set "
2170-
"on connect only and will clean up automatically.");
2170+
"on connect only and will clean up automatically. "
2171+
"Tried to delete route %s netmask %s gateway %s",
2172+
network, netmask, gateway);
21712173
#elif defined(TARGET_AIX)
21722174

21732175
{
@@ -2349,7 +2351,10 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt, const st
23492351
#elif defined(TARGET_ANDROID)
23502352
msg(D_ROUTE_DEBUG, "Deleting routes on Android is not possible/not "
23512353
"needed. The VpnService API allows routes to be set "
2352-
"on connect only and will clean up automatically.");
2354+
"on connect only and will clean up automatically. "
2355+
"Tried to delete %s gateway %s",
2356+
network,
2357+
gateway_needed ? gateway : "(not needed)");
23532358
#elif defined(TARGET_HAIKU)
23542359

23552360
/* ex: route delete /dev/net/ipro1000/0 inet6 :: gw beef::cafe prefixlen 64 */

src/openvpn/tun.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,7 @@ tun_dco_enabled(struct tuntap *tt)
18061806
#endif
18071807

18081808

1809-
#if !(defined(_WIN32) || defined(TARGET_LINUX) || defined(TARGET_SOLARIS))
1809+
#if !(defined(_WIN32) || defined(TARGET_LINUX) || defined(TARGET_SOLARIS) || defined(TARGET_ANDROID))
18101810
static void
18111811
open_tun_generic(const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt)
18121812
{
@@ -1973,7 +1973,6 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
19731973
openvpn_net_ctx_t *ctx)
19741974
{
19751975
#define ANDROID_TUNNAME "vpnservice-tun"
1976-
struct user_pass up;
19771976
struct gc_arena gc = gc_new();
19781977
bool opentun;
19791978

0 commit comments

Comments
 (0)