"James Youngman" <[EMAIL PROTECTED]> wrote: > On Fri, Nov 28, 2008 at 7:19 PM, Jim Meyering <[EMAIL PROTECTED]> wrote: > > First, many thanks for looking at this! > > >> +/* Map the dirent.d_type value, DTYPE, to the corresponding stat.st_mode >> + S_IF* bit and set ST.st_mode, thus clearing all other bits in that >> field. */ >> +static void >> +set_stat_type (struct stat *st, unsigned int dtype) >> +{ >> + mode_t type; >> + switch (dtype) >> + { >> + case DT_BLK: >> + type = S_IFBLK; >> + break; >> + case DT_CHR: >> + type = S_IFCHR; >> + break; >> + case DT_DIR: >> + type = S_IFDIR; >> + break; >> + case DT_FIFO: >> + type = S_IFIFO; >> + break; >> + case DT_LNK: >> + type = S_IFLNK; >> + break; >> + case DT_REG: >> + type = S_IFREG; >> + break; >> + case DT_SOCK: >> + type = S_IFSOCK; >> + break; >> + default: >> + type = 0; >> + } >> + st->st_mode = dtype << s_ifmt_shift_bits (); >> +} > > As far as I can see, the variable type is assigned in the function > above, but never used. Did you mean to use "type" rather than > "dtype" in the expression which assigns to st->st_mode?
Whoa! I most certainly did. I'll fix that right away. Good catch. FYI, it passed find's own tests which do exercise those bits, so I guess I was lucky (unlucky) that the mapping is 1-to-1.