Skip to content

Commit

Permalink
TunBuilderCapture: avoid -Wconversion warning for prefix_length
Browse files Browse the repository at this point in the history
For some reason RouteBase uses unsigned char for prefix_length
while all other code uses int or unsigned int. For now just
cast it, prefix_length should be <= 128 anyway.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
  • Loading branch information
flichtenheld committed Oct 11, 2023
1 parent 40d987f commit 73624b8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions openvpn/tun/builder/capture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,14 @@ class TunBuilderCapture : public TunBuilderBase, public RC<thread_unsafe_refcoun
{
RouteAddress r;
r.address = address;
r.prefix_length = prefix_length;
r.prefix_length = static_cast<unsigned char>(prefix_length);
r.gateway = gateway;
r.ipv6 = ipv6;
r.net30 = net30;
if (ipv6)
tunnel_address_index_ipv6 = (int)tunnel_addresses.size();
tunnel_address_index_ipv6 = static_cast<int>(tunnel_addresses.size());
else
tunnel_address_index_ipv4 = (int)tunnel_addresses.size();
tunnel_address_index_ipv4 = static_cast<int>(tunnel_addresses.size());
tunnel_addresses.push_back(r);
return true;
}
Expand All @@ -488,7 +488,7 @@ class TunBuilderCapture : public TunBuilderBase, public RC<thread_unsafe_refcoun
{
Route r;
r.address = address;
r.prefix_length = prefix_length;
r.prefix_length = static_cast<unsigned char>(prefix_length);
r.metric = metric;
r.ipv6 = ipv6;
add_routes.push_back(r);
Expand All @@ -499,7 +499,7 @@ class TunBuilderCapture : public TunBuilderBase, public RC<thread_unsafe_refcoun
{
Route r;
r.address = address;
r.prefix_length = prefix_length;
r.prefix_length = static_cast<unsigned char>(prefix_length);
r.metric = metric;
r.ipv6 = ipv6;
exclude_routes.push_back(r);
Expand Down

0 comments on commit 73624b8

Please sign in to comment.