As I said, I am irrationally prejudiced against for loops. I am rationally prejudiced against do loops however and that leaves only while loops - the good thing is that anything that can be done with the others can just as easily be done with a while - and when reviewing code in multiple languages and written for different execution environments, it is helpful to standardize on lexical convention that is invariant
When I say generic function pointers, I mean function pointers that conform to a typedef required by an API that has no knowledge of how a function implementation will operate. In KM, every dispatch function qualifies as well as numerous other call-backs
I am also bothered by the lack of recognition of the legitimate uses of goto. In my code, and the code that I review, it is standard practice to use goto as part of error handling sequences in functions - especially when allocating a series of related resources that must be used together. This reduces the chance of memory leaks and other errors by reducing duplicated code.
goto statements that go 'backwards’ within a function can be vital performance optimizations in certain kinds of algorithms, but always require close examination.
No dictum about loop semantics or the use of goto addresses the most common fault I see with code written by novice programmers - incorrect reclusive function calls. The number of infinite revulsion bugs that I have seen dwarfs the number of incorrect uses of go to.
All of this is of course a matter of style and I do not dispute that other styles exist that may be more appropriate for certain environments, but I share my conclusions wrought of many years of experience for the benefit of anyone who may deign to consider them valid
Sent from Surface Pro
From: Jamey Kirby
Sent: Friday, April 24, 2015 10:58 PM
To: Windows System Software Devs Interest List
for(; is the proper way. while(TRUE) or while(1) is convoluted. What is TRUE? What is 1? I consider it sloppy programming. I would rather see a goto than while (TRUE).
I think most projects I have worked on, developers use /w3. It drives me crazy. I have seen countless project where code ships with hundreds of warnings.
BTW: I prefer the word recalcitrant to cantankerous
On Fri, Apr 24, 2015 at 8:55 PM, Marion Bond wrote:
IMHO it is much easier to simply define the non-obvious MACRO while(true) to eliminate the warnings; but then I am irrationally prejudiced against for loops (except the .NET for each next kind)
The more annoying problem is casting function pointers because the signatures differ by const qualifiers. Generic function pointer types don’t include them, but often the actual function definition does and that causes a type mismatch. It seems wrong that the compiler should complain when a callee enforces a more rigorous contract than a caller demands
Sent from Surface Pro
From: Maxim S. Shatskih
Sent: Friday, April 24, 2015 6:25 PM
To: Windows System Software Devs Interest List
> I was pleased to see that the WDK defaults /W4. Many devs simply find /W4 too cantankerous to
>deal with.
I think /W4 /WX is a must beyound doubt, even if some stuff from it should be suppressed by #pragmas.
The Greek-like word of “cantankerous”, looking like a Bysantine emperor family name, surely enriches my English knowledge
>Unreferenced parameters,
So what? C has no C++ elegant way of dealing with them, but it has UNREFERENCED_PARAMETER() macro.
>and invariant expressions in a “while” statement
Use for(; instead.
–
Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com
—
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
—
NTDEV is sponsored by OSR
Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
OSR is HIRING!! See http://www.osr.com/careers
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
–
Jamey Kirby
Disrupting the establishment since 1964
This is a personal email account and as such, emails are not subject to archiving. Nothing else really matters.
— NTDEV is sponsored by OSR Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See http://www.osr.com/careers For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer