Hi,
On Fri, Jun 22, 2018 at 10:48 AM, Antonio Quartulli <a...@unstable.cc> wrote:
> Hi,
>
> On 22/06/18 22:45, Selva Nair wrote:
> [cut]
> >> --- a/src/openvpn/route.c
> >> +++ b/src/openvpn/route.c
> >> @@ -1616,7 +1616,7 @@ add_route(struct route_ipv4 *r, const struct
> tuntap
> > *tt, unsigned int flags,
> >> if (is_on_link(is_local_route, flags, rgi))
> >> {
> >> ai = rgi->adapter_index;
> >> - argv_printf_cat(&argv, "IF %lu", ai);
> >> + argv_printf_cat(&argv, "IF %u", ai);
> >> }
> >>
> >> argv_msg(D_ROUTE, &argv);
> >
> > Thanks for cleaning up my mistake (commit
> > 06ad53e067d9a8be571a27f44005fa7e8038f69e introduced this). One
> > purpose of that commit was to get rid of -Wformat warnings as those
> > are not always benign. But this will re-introduce a warning as "ai" is
> > unsigned long even though its the same size as unsigned.
> >
> > Currently we do support building with -Werror=format (see
> > https://patchwork.openvpn.net/patch/234/#463), so I suggest either
> > cast to (unsigned) which we know is safe here, or add "%lu" to
> > argv_printf_arglist().
> >
> > I would prefer the latter as its easy to overlook the fact that
> > argv_printf_cat() can't handle %lu which is commonly used
> > on Windows.
>
> I was just about to test a v2 of this patch with the explicit cast to
> "unsigned int". I was leaning towards the explicit cast because we
> already print DWORD variables in several spots and we always cast them
> to int or unsigned int.
>
We used to have some printed with even %d and no cast. The last time we
cleaned up the offending ones and removed a few casts nearby.
However, if we believe supporting %lu can be more useful, I can do that.
>
> Last opinion? :)
>
I prefer "%lu" and no cast and have been replacing %u by %lu elsewhere in
the code given a chance.
There are a lots DWORD to (unsigned) in tun.c and elsewhere but there is no
compelling reason to change them. We should get rid of casts to (int) when
possible, though.
Selva
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel