A more descriptive name than `ret` would make the code more obvious.  What about

```C
bool failed = fprintf(...) < 0;
if (failed) {
```