unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Avoid warnings in sockets.c when HAVE_SIN6_SCOPE_ID is unavailable
@ 2016-07-16 17:16 Eli Zaretskii
  2016-07-22  7:16 ` Eli Zaretskii
  2016-07-23 20:55 ` Andy Wingo
  0 siblings, 2 replies; 6+ messages in thread
From: Eli Zaretskii @ 2016-07-16 17:16 UTC (permalink / raw)
  To: guile-devel

    CC       libguile_2.0_la-socket.lo
  socket.c: In function 'scm_fill_sockaddr':
  socket.c:747:16: warning: variable 'scope_id' set but not used [-Wunused-but-set-variable]
    unsigned long scope_id = 0;
		  ^

The patch to avoid this warning is below.  OK to commit?

--- libguile/socket.c~0	2016-01-02 16:24:55.000000000 +0200
+++ libguile/socket.c	2016-07-15 19:17:40.023250000 +0300
@@ -744,7 +744,9 @@ scm_fill_sockaddr (int fam, SCM address,
 	int port;
 	struct sockaddr_in6 *soka;
 	unsigned long flowinfo = 0;
+#ifdef HAVE_SIN6_SCOPE_ID
 	unsigned long scope_id = 0;
+#endif
 
 	SCM_VALIDATE_CONS (which_arg + 1, *args);
 	port = scm_to_int (SCM_CAR (*args));
@@ -755,8 +757,10 @@ scm_fill_sockaddr (int fam, SCM address,
 	    *args = SCM_CDR (*args);
 	    if (scm_is_pair (*args))
 	      {
+#ifdef HAVE_SIN6_SCOPE_ID
 		SCM_VALIDATE_ULONG_COPY (which_arg + 3, SCM_CAR (*args),
 					 scope_id);
+#endif
 		*args = SCM_CDR (*args);
 	      }
 	  }



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Avoid warnings in sockets.c when HAVE_SIN6_SCOPE_ID is unavailable
  2016-07-16 17:16 Avoid warnings in sockets.c when HAVE_SIN6_SCOPE_ID is unavailable Eli Zaretskii
@ 2016-07-22  7:16 ` Eli Zaretskii
  2016-08-10  6:49   ` Mark H Weaver
  2016-07-23 20:55 ` Andy Wingo
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2016-07-22  7:16 UTC (permalink / raw)
  To: guile-devel

Ping!

> Date: Sat, 16 Jul 2016 20:16:35 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> 
>     CC       libguile_2.0_la-socket.lo
>   socket.c: In function 'scm_fill_sockaddr':
>   socket.c:747:16: warning: variable 'scope_id' set but not used [-Wunused-but-set-variable]
>     unsigned long scope_id = 0;
> 		  ^
> 
> The patch to avoid this warning is below.  OK to commit?
> 
> --- libguile/socket.c~0	2016-01-02 16:24:55.000000000 +0200
> +++ libguile/socket.c	2016-07-15 19:17:40.023250000 +0300
> @@ -744,7 +744,9 @@ scm_fill_sockaddr (int fam, SCM address,
>  	int port;
>  	struct sockaddr_in6 *soka;
>  	unsigned long flowinfo = 0;
> +#ifdef HAVE_SIN6_SCOPE_ID
>  	unsigned long scope_id = 0;
> +#endif
>  
>  	SCM_VALIDATE_CONS (which_arg + 1, *args);
>  	port = scm_to_int (SCM_CAR (*args));
> @@ -755,8 +757,10 @@ scm_fill_sockaddr (int fam, SCM address,
>  	    *args = SCM_CDR (*args);
>  	    if (scm_is_pair (*args))
>  	      {
> +#ifdef HAVE_SIN6_SCOPE_ID
>  		SCM_VALIDATE_ULONG_COPY (which_arg + 3, SCM_CAR (*args),
>  					 scope_id);
> +#endif
>  		*args = SCM_CDR (*args);
>  	      }
>  	  }
> 
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Avoid warnings in sockets.c when HAVE_SIN6_SCOPE_ID is unavailable
  2016-07-16 17:16 Avoid warnings in sockets.c when HAVE_SIN6_SCOPE_ID is unavailable Eli Zaretskii
  2016-07-22  7:16 ` Eli Zaretskii
@ 2016-07-23 20:55 ` Andy Wingo
  2016-07-24 14:35   ` Eli Zaretskii
  1 sibling, 1 reply; 6+ messages in thread
From: Andy Wingo @ 2016-07-23 20:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: guile-devel

Hi :)

On Sat 16 Jul 2016 19:16, Eli Zaretskii <eliz@gnu.org> writes:

>     CC       libguile_2.0_la-socket.lo
>   socket.c: In function 'scm_fill_sockaddr':
>   socket.c:747:16: warning: variable 'scope_id' set but not used [-Wunused-but-set-variable]
>     unsigned long scope_id = 0;
> 		  ^
>
> The patch to avoid this warning is below.  OK to commit?

I don't think so -- whether the underlying system has scope_id or no, we
need this assert to happen:

> +#ifdef HAVE_SIN6_SCOPE_ID
>  		SCM_VALIDATE_ULONG_COPY (which_arg + 3, SCM_CAR (*args),
>  					 scope_id);
> +#endif

Not sure what the right solution is.

Andy



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Avoid warnings in sockets.c when HAVE_SIN6_SCOPE_ID is unavailable
  2016-07-23 20:55 ` Andy Wingo
@ 2016-07-24 14:35   ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2016-07-24 14:35 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-devel

> From: Andy Wingo <wingo@pobox.com>
> Cc: guile-devel@gnu.org
> Date: Sat, 23 Jul 2016 22:55:50 +0200
> 
> >     CC       libguile_2.0_la-socket.lo
> >   socket.c: In function 'scm_fill_sockaddr':
> >   socket.c:747:16: warning: variable 'scope_id' set but not used 
> > [-Wunused-but-set-variable]
> >     unsigned long scope_id = 0;
> >                 ^
> >
> > The patch to avoid this warning is below.  OK to commit?
> 
> I don't think so -- whether the underlying system has scope_id or no, we
> need this assert to happen:
> 
> > +#ifdef HAVE_SIN6_SCOPE_ID
> >               SCM_VALIDATE_ULONG_COPY (which_arg + 3, SCM_CAR (*args),
> >                                        scope_id);
> > +#endif
> 
> Not sure what the right solution is.

How about something this instead:

#ifdef HAVE_SIN6_SCOPE_ID
             SCM_VALIDATE_ULONG_COPY (which_arg + 3, SCM_CAR (*args),
                                      scope_id);
#else
             (void)SCM_NUM2ULONG (which_arg + 3, SCM_CAR (*args));
#endif



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Avoid warnings in sockets.c when HAVE_SIN6_SCOPE_ID is unavailable
  2016-07-22  7:16 ` Eli Zaretskii
@ 2016-08-10  6:49   ` Mark H Weaver
  2016-08-13  7:17     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Mark H Weaver @ 2016-08-10  6:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: guile-devel

Hi Eli,

Eli Zaretskii <eliz@gnu.org> writes:

>     CC       libguile_2.0_la-socket.lo
>   socket.c: In function 'scm_fill_sockaddr':
>   socket.c:747:16: warning: variable 'scope_id' set but not used [-Wunused-but-set-variable]
>     unsigned long scope_id = 0;
> 		  ^

How about this?

--8<---------------cut here---------------start------------->8---
diff --git a/libguile/socket.c b/libguile/socket.c
index 3229ac8..beff305 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -744,7 +744,7 @@ scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg,
 	int port;
 	struct sockaddr_in6 *soka;
 	unsigned long flowinfo = 0;
-	unsigned long scope_id = 0;
+	unsigned long scope_id SCM_UNUSED = 0;
 
 	SCM_VALIDATE_CONS (which_arg + 1, *args);
 	port = scm_to_int (SCM_CAR (*args));
--8<---------------cut here---------------end--------------->8---

See the definition of SCM_UNUSED in __scm.h.

What do you think?

      Mark



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: Avoid warnings in sockets.c when HAVE_SIN6_SCOPE_ID is unavailable
  2016-08-10  6:49   ` Mark H Weaver
@ 2016-08-13  7:17     ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2016-08-13  7:17 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guile-devel

> From: Mark H Weaver <mhw@netris.org>
> Cc: guile-devel@gnu.org
> Date: Wed, 10 Aug 2016 02:49:08 -0400
> 
> Hi Eli,
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >     CC       libguile_2.0_la-socket.lo
> >   socket.c: In function 'scm_fill_sockaddr':
> >   socket.c:747:16: warning: variable 'scope_id' set but not used [-Wunused-but-set-variable]
> >     unsigned long scope_id = 0;
> > 		  ^
> 
> How about this?
> 
> --8<---------------cut here---------------start------------->8---
> diff --git a/libguile/socket.c b/libguile/socket.c
> index 3229ac8..beff305 100644
> --- a/libguile/socket.c
> +++ b/libguile/socket.c
> @@ -744,7 +744,7 @@ scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg,
>  	int port;
>  	struct sockaddr_in6 *soka;
>  	unsigned long flowinfo = 0;
> -	unsigned long scope_id = 0;
> +	unsigned long scope_id SCM_UNUSED = 0;
>  
>  	SCM_VALIDATE_CONS (which_arg + 1, *args);
>  	port = scm_to_int (SCM_CAR (*args));
> --8<---------------cut here---------------end--------------->8---
> 
> See the definition of SCM_UNUSED in __scm.h.

Works for me (no warning after applying the patch), but couldn't this
be harmful for builds that do use the variable, by omitting real
warnings?  If it could, maybe make the use of SCM_UNUSED be
conditional on HAVE_SIN6_SCOPE_ID being defined?

Thanks.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-08-13  7:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-16 17:16 Avoid warnings in sockets.c when HAVE_SIN6_SCOPE_ID is unavailable Eli Zaretskii
2016-07-22  7:16 ` Eli Zaretskii
2016-08-10  6:49   ` Mark H Weaver
2016-08-13  7:17     ` Eli Zaretskii
2016-07-23 20:55 ` Andy Wingo
2016-07-24 14:35   ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).