Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!brutus.cs.uiuc.edu!jarthur!bridge2!mips!prls!pyramid!ctnews!mitisft!dold From: dold@mitisft.Convergent.COM (Clarence Dold) Newsgroups: comp.lang.c Subject: Re: What is wrong with this code ? Message-ID: <1323@mitisft.Convergent.COM> Date: 11 Dec 89 05:05:35 GMT References: <1156@nsscb.UUCP> Organization: Convergent Technologies, San Jose, CA Lines: 32 in article <1156@nsscb.UUCP>, nrg@nsscb.UUCP (G.Narotham Reddy) says: Oh, so judgemental! Who says it's stupid precedence? True, we do need a couple of parens to make it work, "it" being this one line, but don't we also need some logic in the program? > if (nfile.st_mode & S_IFMT == S_IFREG) > else if (nfile.st_mode & S_IFMT == S_IEXEC) all these "else if" are self-defeating. Might argv[1] not point to a file that satisfies more than one? How will any of them ever display, if we else if the permissions against S_IFREG to begin with? (only for a special). Additionally, we don't want to mask permissions against S_IFMT. For that matter, we don't need to mask type against S_IFMT. Don't we really want if (nfile.st_mode & S_IFREG) printf(...); else if (nfile.st_mode & S_IFDIR) printf(...); followed by several if (nfile.st_mode & S_IWRITE) printf(...); if (nfile.st_mode & S_IREAD) printf(...); ... -- --- Clarence A Dold - dold@tsmiti.Convergent.COM (408) 435-5293 ...pyramid!ctnews!tsmiti!dold FAX (408) 435-3105 P.O.Box 6685, San Jose, CA 95150-6685 MS#10-007