On Wed, Jun 28, 2000 at 11:31:55AM +1000, Bruce Evans wrote: > 1) Don't "comment out" dead code. Remove it. > 2) Use only #if 0 to "comment out code. Comments are unsuitable for > "commenting out" code in general, because the code might contain > comments, and they are harder to edit and read. > > Bruce Okay .. the style(9) may like the diff now :-) Besides the original bogus style, is there any side effect/potential risk along with the code ? Regards, Clive -- CirX - This site doesnt' exist. 9c k9o h9 s1bg s1f, 7v .y xqx a sj m8r ffg1 vg5 a6 asox tmul h38 . ant sj m8r ob ? 1fj mwby a1 tao vg5. soq df v ' .a. CirX.
--- badsect.c~ Tue Jun 27 22:30:57 2000 +++ badsect.c Wed Jun 28 17:20:55 2000 @@ -118,11 +118,17 @@ err(3, "%s", name); name_dir_end = name + strlen(name); while ((dp = readdir(dirp)) != NULL) { + /* + * Opening of a mounted on device is not allowed. + * Attempt to open the raw device instead. + */ + if (dp->d_name[0] != 'r') + continue ; strcpy(name_dir_end, dp->d_name); if (lstat(name, &devstat) < 0) err(4, "%s", name); if (stbuf.st_dev == devstat.st_rdev && - (devstat.st_mode & IFMT) == IFBLK) + (devstat.st_mode & IFMT) == IFCHR) break; } closedir(dirp); @@ -131,12 +137,6 @@ (u_long)stbuf.st_rdev, argv[1]); exit(5); } - /* - * Opening of a mounted on device is not allowed. - * Attempt to open the raw device instead. - */ - memcpy(name_dir_end + 1, name_dir_end, strlen(name_dir_end) + 1); - *name_dir_end = 'r'; if ((fsi = open(name, O_RDONLY)) < 0) err(6, "%s", name); fs = &sblock;