Comment 25 for bug 305176

Revision history for this message
Colin Watson (cjwatson) wrote :

I agree that this warning is sometimes excessive and inconvenient, particularly for logging writes which are, as you put it, "fire and forget".

Notwithstanding that, though, I would note that it *is* good practice to check non-logging writes. Contrary to popular belief, write() is not guaranteed to write everything you give it, and it doesn't take particularly unusual circumstances to cause it not to do so: if your code might ever be interrupted by a signal (for example if it uses subprocesses, or is a daemon that might be reloaded using SIGHUP, or all sorts of other situations), then write() can write less data than you asked for. This change *has* exposed a lot of real reliability bugs that we needed to fix anyway.

It seems particularly unfortunate that a (void) cast does not silence this warning. You can, however, do this:

  if (write(...)) { }