On Tuesday, March 11, 2025 3:03:13 PM CET Greg Kurz wrote: > On Tue, 11 Mar 2025 12:13:06 +0100 > Christian Schoenebeck <qemu_...@crudebyte.com> wrote: > > > On Monday, March 10, 2025 6:10:59 PM CET Greg Kurz wrote: [...] > > Follow-up on previous patch, this could be reduced to: > > > > static int local_fid_fd(int fid_type, V9fsFidOpenState *fs) > > { > > if (fid_type == P9_FID_DIR && fs->dir.stream != NULL) { > > return dirfd(fs->dir.stream); > > } else if (fid_type == P9_FID_FILE) { > > return fs->fd; > > } > > return -1; /* POSIX invalid file handle */ > > } > > > > or even: > > > > static int local_fid_fd(int fid_type, V9fsFidOpenState *fs) > > { > > return (fid_type == P9_FID_DIR && fs->dir.stream != NULL) ? > > dirfd(fs->dir.stream) : > > (fid_type == P9_FID_FILE) ? fs->fd : > > -1; /* POSIX invalid file handle */ > > } > > > > Yuck, I'll stick to the `if` version ;-) > > No sure to understand the meaning of `/* POSIX invalid file handle */` > though...
"invalid file descriptor" rather than "invalid file handle". What I mean is that outside of the Unix world -1 is not necessarily the predefined and reserved value for "invalid file descriptor". But no big deal. /Christian