[PATCH] Fix -Wunused-but-set-variable compiler warnings in tevent_signal.c

Stefan (metze) Metzmacher metze at samba.org
Thu Nov 10 01:18:18 MST 2011


Hi Martin,

I'm getting this:

git am ../tmp.patch.eml
Applying: Fix -Wunused-but-set-variable compiler warnings in tevent_signal.c
fatal: corrupt patch at line 6
Patch failed at 0001 Fix -Wunused-but-set-variable compiler warnings in
tevent_signal.c
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".

Could you resend this as attachment?

metze

Am 10.11.2011 01:09, schrieb Martin Schwenke:
> The results of some read(2) and write(2) calls are assigned into a
> variable that is never used.  Presumably this used to avoid compiler
> warnings or similar.
> 
> However, from (approximately) GCC 4.6 this produces some warnings:
> 
>   [ 609/3910] Compiling lib/tevent/tevent_signal.c
>   ../lib/tevent/tevent_signal.c: In function
>   ‘tevent_common_signal_handler’: ../lib/tevent/tevent_signal.c:85:10:
>   warning: variable ‘res’ set but not used
>   [-Wunused-but-set-variable] ../lib/tevent/tevent_signal.c: In
>   function ‘signal_pipe_handler’: ../lib/tevent/tevent_signal.c:183:10:
>   warning: variable ‘res’ set but not used [-Wunused-but-set-variable]
> 
> The simplest thing to do is remove the variables and cast the function
> return to void.  There is already a comment above each call.
> 
> Signed-off-by: Martin Schwenke <martin at meltin.net>
> 
> diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c
> index b790859..fabe72c 100644
> --- a/lib/tevent/tevent_signal.c
> +++ b/lib/tevent/tevent_signal.c
> @@ -82,7 +82,6 @@ static uint32_t tevent_sig_count(struct
> tevent_sigcounter s) static void tevent_common_signal_handler(int
> signum) {
>  	char c = 0;
> -	ssize_t res;
>  	struct tevent_common_signal_list *sl;
>  	struct tevent_context *ev = NULL;
>  	int saved_errno = errno;
> @@ -95,7 +94,7 @@ static void tevent_common_signal_handler(int signum)
>  		if (sl->se->event_ctx && sl->se->event_ctx != ev) {
>  			ev = sl->se->event_ctx;
>  			/* doesn't matter if this pipe overflows */
> -			res = write(ev->pipe_fds[1], &c, 1);
> +			(void) write(ev->pipe_fds[1], &c, 1);
>  		}
>  	}
>  
> @@ -180,9 +179,8 @@ static void signal_pipe_handler(struct
> tevent_context *ev, struct tevent_fd *fde uint16_t flags, void
> *_private) {
>  	char c[16];
> -	ssize_t res;
>  	/* its non-blocking, doesn't matter if we read too much */
> -	res = read(fde->fd, c, sizeof(c));
> +	(void) read(fde->fd, c, sizeof(c));
>  }
>  
>  /*
> 
> 
> peace & happiness,
> martin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20111110/e5fa7bca/attachment.pgp>


More information about the samba-technical mailing list