Re: [BULK] Re: Modern C++ Features in Kernel Mode Drivers

Back in the days, jumping around was the only means go get a loop or other construct like try_something(). So it was a natural , sequential improvement to have a goto, even non-local goto was given as setjmp(), longjmp()…

I used both goto, and not big of a do{ <…> }while(0);. Never used multilevel if (cold) more than two level ( this to me is a sign of getting tiered :slight_smile: ).

And in most cases, I have the 80 column bar on IDE, so I’m watchful there.

And there are many, when I said I don’t like too much hidden things in kernel, I really meant it. Small things like using c++ constructs for lock holding and releasing not much of a concern, but if I see memory being allocated, and freed behind my back because of some constructs, I would worry.

For those of us, who thinks OO is bad or ugly in the kernel , it is not really that bad. Apple I/O kit allows to do that ( public:, private, protected etc) are supported. Some 30+ odd years ago, MFC said forget multiple-inheritance and Apple I/O kit says the same thing - But still, IMO powerful construct.

Do driver developer need all of these ? Yeah, most drivers are 3K to 5K loc, so I would say, IMO no, no …

You look at the C++ book, from the horses mouth, he is encouraging situation when multiple inheritance is good.

Even ++X, and X++ require attention…

So the list goes on and on. But when it comes to handling exception ( that surely help handling error condition in a much more elegant way ), I don’t see a clear affirmative YES. Here it is, try it …

-Pro

On Jul 9, 2018, at 10:16 AM, xxxxx@gmail.com wrote:
>
> The Linux kernel has some 100,000 goto references. The Goto wars have been around since the late 60’s.
>
> I use them, but rarely. I don’t go out of my way to code around them. They just happen when they need to happen.
>
> This is a fun read: http://wiki.c2.com/?GotoConsideredHarmful http:
>
>
> On Mon, Jul 9, 2018 at 5:15 AM xxxxx@gmail.com mailto:xxxxx > wrote:
> > some people are just too dumb to see the advantages that goto statement offers
>
> Fair enough, but if you read the tone of my post I did not say goto never makes sense, just that I personally have never used it and that pretty much everyone seems to be taught goto is evil. Personally, I would be willing to entertain valid usages. I think it must exist in multiple languages for a reason.
>
> > 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. C++ Exceptions would solve this elegantly however.
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
> Details at http:>
>
> To unsubscribe, visit the List Server section of OSR Online at http:>
>
>
> –
> 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 online at: MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at To unsubscribe, visit the List Server section of OSR Online at</http:></http:></http:></mailto:xxxxx></http:>