On Tue, May 30, 2023 at 11:23:42AM +0200, Peter Zijlstra wrote: > Yes, it's a wee bit more involved, but I'm thinking it gives a fair > amount of flexibility and we don't need to ret rid of > -Wdeclaration-after-statement. One other thing I forgot to point put; it allows things like: int store_fd(int fd) { ptr_guard(fdput, f) = fdget(fd); void *ret; if (!f.file) return -EBADF; ret = xa_store(&xarray, f.file->private, f); if (xa_is_err(ret)) return xa_err(ret); f = null_ptr(fdput); // xarray now owns f return 0; } Where we can assign null_ptr() to clear the guard and inhibit the cleanup function to pass ownership around.