Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!bionet!ames!lll-winken!uunet!mcvax!kth!sunic!liuida!prodix!isadora!hacker From: hacker@isadora.ikp.liu.se (Goran Larsson [Hacker of Hackefors]) Newsgroups: comp.lang.c Subject: Re: lint won't verify printf formatting against variable types?? Keywords: lint, cc Message-ID: <414@isadora.ikp.liu.se> Date: 5 Jul 89 11:17:31 GMT References: <328@tree.UUCP> <417@siswat.UUCP> <105@borabora.omni.com> <411@isadora.ikp.liu.se> <11038@ihlpl.ATT.COM> Organization: Hackers Home, Hackefors, Linkoping, Sweden Lines: 28 In article <11038@ihlpl.ATT.COM> knudsen@ihlpl.ATT.COM (Knudsen) writes: >In article <411@isadora.ikp.liu.se>, hacker@isadora.ikp.liu.se (Goran Larsson [Hacker of Hackefors]) writes: >> It's your own fault -- you should have written it as >> if ( condition ) { >> action; >> } >> to reduce the risk of errors! >Yes, but suppose you make the same typo and get > if ( condition ); { /* extra semicolon */ > action; > } >Isn't this still legal C (with the same bug), since compound blocks >may be started anywhere? The problem is that "if ( condition )" feels like a function call to your fingers and when your brain orders a new line, one of your fingers will automagically add the semicolon. If you add the opening curly brace before ordering a new line then your fingers will realize that the semicolon is inapropriate. Have you ever seen "if ( condition ); {" in a program? -- ! _ ! ! Goran Larsson [The Hacker of Hackefors] --+-! Hackefors, Linkoping, SWEDEN (See) +46 13-155535 (Hear) !-+-- ...!uunet!sunic!liuida!prodix!isadora!hacker (UUCP) ! ! hacker@isadora.ikp.liu.se (Internet) _ !