[rsbackup] 777ebf44 Placate compiler.

Richard Kettlewell rjk at greenend.org.uk
Thu Oct 15 09:38:41 BST 2015


Richard Kettlewell <rjk at greenend.org.uk> writes, in greenend.commits:
>     Placate compiler.
>
> * Changes --------------------------------------------------------------
>
> diff --git a/src/EventLoop.cc b/src/EventLoop.cc
> index 88e6bcc..240c80f 100644
> --- a/src/EventLoop.cc
> +++ b/src/EventLoop.cc
> @@ -81,7 +81,8 @@ EventLoop::~EventLoop() {
>  
>  void EventLoop::signalled(int) {
>    int save_errno = errno;
> -  write(sigpipe[1], "", 1);
> +  ssize_t written = write(sigpipe[1], "", 1);
> +  (void)written;
>    errno = save_errno;
>  }

Specifically this is to placate -D_FORTIFY_SOURCE=2.  The surrounding
context is here:
  https://github.com/ewxrjk/rsbackup/blob/master/src/EventLoop.cc
  https://github.com/ewxrjk/rsbackup/blob/master/src/EventLoop.h

The logic for ignoring the error is that the expected cause is that pipe
is full (i.e. signals have been arriving at a hugely high rate).  But
the main event loop will keep waiting until there's nothing more to wait
for, so losing a few notifications is harmless (in fact IIRC some
kernels compress multiple identical signals into a single delivery
anyway).

Does anyone have any different approaches here?

-- 
http://www.greenend.org.uk/rjk/



More information about the sgo-software-discuss mailing list