Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

OSR Seminars

Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 2  
09 Jul 18 11:35
Peter Viscarola
Join Date:
Posts To This List: 6243
List Moderator
RE: RE: RE: RE: Re: [BULK] Re: Modern C++ Features in Kernel Mode Drivers

<quote> > if(status) goto done; > Which of them do you think is easier to read and maintain??? I have seen code like this before. I personally prefer nested if's to facilitate cleanup lining up clearly through horizontal indentation. Both approaches I think are ugly. It's a developer decision. </quote> Like so many things in my engineering life, my opinion on these topics has changed over the years. For many years, I favored the "early out" pattern of multiple return points from a function... because this was the most common pattern seen in Windows kernel mode "back in the day". I *really* don't like if NT_SUCCESS() ... if NT_SUCCESS() ... if NT_SUCCESS()... indent. I find this to be both ugly and confusing. To ME, the logic gets lost in the error handling. Then again, I still insist on code being no wider than 80 columns. A few years back, just about everyone here at OSR has uniformly switched to the "goto done" model, and this has proved *very* satisfactory. I find the code easy to follow, and indents from the left follow the code *logic* not the success path for function invocation. But, as Mr. Kreamer said, "it's a developer decision"... every man should be able to select his own tools. Peter OSR @OSRDrivers
  Message 2 of 2  
09 Jul 18 12:06
Prokash Sinha
Join Date: 23 Feb 2000
Posts To This List: 1087
RE: RE: RE: RE: Re: [BULK] Re: Modern C++ Features in Kernel Mode Drivers

I used std::lock_guard in quite a few places, but in UM. Not in KM. I certainly don???t hate it, and see the benefit. There are so many things, like RAII, f(???.) const etc., that have been around for long, but driver/kernel community of all platforms using just C, in most cases. Look at linux, os x etc. -Pro > On Jul 9, 2018, at 8:23 AM, <> wrote: > >> I don't like hiding stuff when in kernel mode, so I spend as >> less time as possible in kernel debugging > > The problem is, one person's "hiding" is another's safety. Do RAII patterns "hide" things, in your view? > > Take std::lock_guard as an example. Do you hate this? > > I, for one, *love* this paradigm for locking... You're not *hiding* the lock release, it's just implicit as part of the acquisition. Take the time and write a few comments if clarity concerns you, for goodness sakes. <...excess quoted lines suppressed...>
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 19:25.

Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license