Commit be54b24
committed
[C++] fix a handful of compiler warnings
Context: dotnet/java-interop#703
This commit fixes a handful of warnings reported by GCC and clang when
building for different platforms.
monodroid-glue.cc:1609:8: warning: declaration shadows a static data member of 'xamarin::android::internal::MonodroidRuntime' [-Wshadow]
void *api_dso_handle = nullptr;
^
monodroid-glue.cc:102:25: note: previous declaration is here
void *MonodroidRuntime::api_dso_handle = nullptr;
Fix by renaming the local variable. No functionality changes result
from this fix.
MinGW builds report:
xa-internal-api.cc: In member function ‘virtual mono_bool xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_up_state(const char*, mono_bool*)’:
xa-internal-api.cc:24:86: warning: unused parameter ‘ifname’ [-Wunused-parameter]
24 | MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_up_state (const char *ifname, mono_bool *is_up)
| ~~~~~~~~~~~~^~~~~~
xa-internal-api.cc:24:105: warning: unused parameter ‘is_up’ [-Wunused-parameter]
24 | MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_up_state (const char *ifname, mono_bool *is_up)
| ~~~~~~~~~~~^~~~~
xa-internal-api.cc: In member function ‘virtual mono_bool xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_supports_multicast(const char*, mono_bool*)’:
xa-internal-api.cc:34:96: warning: unused parameter ‘ifname’ [-Wunused-parameter]
34 | MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_supports_multicast (const char *ifname, mono_bool *supports_multicast)
| ~~~~~~~~~~~~^~~~~~
xa-internal-api.cc:34:115: warning: unused parameter ‘supports_multicast’ [-Wunused-parameter]
34 | MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_supports_multicast (const char *ifname, mono_bool *supports_multicast)
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
xa-internal-api.cc: In member function ‘virtual int xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_get_dns_servers(void**)’:
xa-internal-api.cc:44:66: warning: unused parameter ‘dns_servers_array’ [-Wunused-parameter]
44 | MonoAndroidInternalCalls_Impl::monodroid_get_dns_servers (void **dns_servers_array)
| ~~~~~~~^~~~~~~~~~~~~~~~~
xa-internal-api.cc: In member function ‘virtual int xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_getifaddrs(_monodroid_ifaddrs**)’:
xa-internal-api.cc:54:82: warning: unused parameter ‘ifap’ [-Wunused-parameter]
54 | MonoAndroidInternalCalls_Impl::monodroid_getifaddrs (struct _monodroid_ifaddrs **ifap)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
xa-internal-api.cc: In member function ‘virtual void xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_freeifaddrs(_monodroid_ifaddrs*)’:
xa-internal-api.cc:64:82: warning: unused parameter ‘ifa’ [-Wunused-parameter]
64 | MonoAndroidInternalCalls_Impl::monodroid_freeifaddrs (struct _monodroid_ifaddrs *ifa)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
The fix is to ignore the unused parameters only during Windows builds
by using the C++17 attribute `[[maybe_unused]]`
Another Windows-only warning:
embedded-assemblies.cc: In static member function ‘static ssize_t xamarin::android::internal::EmbeddedAssemblies::do_read(int, void*, size_t)’:
embedded-assemblies.cc:663:26: warning: conversion from ‘size_t’ {aka ‘long long unsigned int’} to ‘unsigned int’ may change value [-Wconversion]
663 | ret = ::read (fd, buf, count);
|
It is caused by `read(2)` declared in MinGW headers with the third
parameter using `unsigned int` type instead of the standard `size_t`.
Fixed by casting properly on Windows builds.1 parent 9c62618 commit be54b24
File tree
6 files changed
+31
-17
lines changed- external
- src
- Xamarin.Android.Build.Tasks
- monodroid/jni
6 files changed
+31
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
Submodule Java.Interop updated 124 files
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
663 | | - | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
664 | 672 | | |
665 | 673 | | |
666 | 674 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1606 | 1606 | | |
1607 | 1607 | | |
1608 | 1608 | | |
1609 | | - | |
| 1609 | + | |
1610 | 1610 | | |
1611 | 1611 | | |
1612 | 1612 | | |
1613 | 1613 | | |
1614 | 1614 | | |
1615 | | - | |
| 1615 | + | |
1616 | 1616 | | |
1617 | 1617 | | |
1618 | 1618 | | |
1619 | 1619 | | |
1620 | 1620 | | |
1621 | 1621 | | |
1622 | 1622 | | |
1623 | | - | |
| 1623 | + | |
1624 | 1624 | | |
1625 | | - | |
| 1625 | + | |
1626 | 1626 | | |
1627 | 1627 | | |
1628 | | - | |
1629 | | - | |
1630 | | - | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
1631 | 1631 | | |
1632 | 1632 | | |
1633 | 1633 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| |||
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
24 | | - | |
| 30 | + | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
| |||
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
34 | | - | |
| 40 | + | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
| |||
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
44 | | - | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| |||
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
54 | | - | |
| 60 | + | |
55 | 61 | | |
56 | 62 | | |
57 | 63 | | |
| |||
61 | 67 | | |
62 | 68 | | |
63 | 69 | | |
64 | | - | |
| 70 | + | |
65 | 71 | | |
66 | 72 | | |
67 | 73 | | |
| |||
0 commit comments