Jeff Hostetler <git@xxxxxxxxxxxxxxxxx> writes: >> + HANDLE osfilehandle; > > I'd be more comfortable initializing this variable to > INVALID_HANDLE_VALUE. Both directories/files branches assign, so it is not needed. >> + if (attrs & FILE_ATTRIBUTE_DIRECTORY) { >> + fh = 0; > > and here initializing fh = -1. This does make it safer. > And then this becomes: > > if (fh != -1) > close(fh) > else if (osfilehandle != INVALID_HANDLE_VALUE) > Closehandle(osfilehandle); Exactly.