Die on a failed zephyr_zwrite; don't silently ignore it
Fix some undefined behavior in filter.c, caught by clang scan-build