[vlc-devel] [PATCH] misc/gnutls: do not declare variable if not needed

Filip Roséen filip at atch.se
Wed Mar 15 19:18:30 CET 2017


Hi Hugo,

On 2017-03-15 19:16, Hugo Beauzée-Luyssen wrote:

> On Wed, Mar 15, 2017, at 10:07 AM, Filip Roséen wrote:
> > The variable in question is only needed within the preprocessor-if
> > that follows, as such it makes more sense to declare only declare it
> > if that is actually reached (while also supressing a warning
> > diagnostic related to the variable being unused).
> > 
> > An empty statement has been added after the label in order to comply
> > with the ISO C Standard, which mandates that a label preceedes a
> > statement (which a variable declaration is not).
> > ---
> >  modules/misc/gnutls.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/modules/misc/gnutls.c b/modules/misc/gnutls.c
> > index 3b83a9b84b..f3e5d44ccb 100644
> > --- a/modules/misc/gnutls.c
> > +++ b/modules/misc/gnutls.c
> > @@ -348,10 +348,11 @@ static int gnutls_ContinueHandshake(vlc_tls_creds_t
> > *crd,
> >      msg_Err(crd, "TLS handshake error: %s", gnutls_strerror (val));
> >      return -1;
> >  
> > -    unsigned flags;
> >  done:
> >  #if (GNUTLS_VERSION_NUMBER >= 0x030500)
> > -    flags = gnutls_session_get_flags(session);
> > +    /* intentionally left blank */;
> > +
> > +    unsigned flags = gnutls_session_get_flags(session);
> >  
> >      if (flags & GNUTLS_SFLAGS_SAFE_RENEGOTIATION)
> >          msg_Dbg(crd, " - safe renegotiation (RFC5746) enabled");
> > -- 
> > 2.12.0
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> 
> I'm not entirely convinced this improves the code readability, I'll
> gladly take some other opinions before applying/rejecting.

I mostly wanted to silence the unused-variable warning on systems
where the version of *gnuls* is less than the check. I guess I should
have mentioned that in the commit message, sorry about that.

Best Regards,\
Filip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170315/92ca6730/attachment.html>


More information about the vlc-devel mailing list