C, Again

“Putting a label inside an if is ugly.
 
julia”
 
See Linux-Kernel Archive: Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()
Many years ago a respected C-programmer (actually one of C’s creators) wrote about why Pascal is not his favourite language. In this instance, we could write the same about C. C lets programmers get away with the silliest things so they do them. Sadly, FreePascal allows this silliness too but I still think a Pascal programmer would have more sense. In particular from ancient times we figured out that GOTO was the root of much evil and avoided it like the plague. Then if absolutely necessary, we only used it in the exceptional case so checking “err” twice is a tiny waste.

Still, in Pascal, I can write:
cat silly.pas
program silly;
label report;
var err:boolean;s:char;
begin
readln(s);
err:= s='c';
if err then goto report;
exit;
report: writeln('must not be ''c''')
end.

./silly
t
pogson@beast:~/pascal$ ./silly
c
must not be ‘c’
pogson@beast:~/pascal$

No “exit” in C? Pity. Can’t use “return”? Nope. The routine is a “void” function. Not even “break” or “continue” help. They are restricted to loops. Sad. Why do people use such a crude language as C?

😎

About Robert Pogson

I am a retired teacher in Canada. I taught in the subject areas where I have worked for almost forty years: maths, physics, chemistry and computers. I love hunting, fishing, picking berries and mushrooms, too.
This entry was posted in Linux in Education, Teaching, technology and tagged , , , . Bookmark the permalink.

48 Responses to C, Again

  1. DrLoser says:

    Re: With a link, if you please?

    Dr. Tosser BING not working?

    Not for paranoid imaginary beliefs, Dog-Brain, no. I would think that Google and the rest wouldn’t work for this pathetic purpose either. But who am I to judge?

    Watchdog timers are another item that can be added to any CPU that results in halt not being halt either.

    Care to Bing or Google or Yahoo or whatever an answer to my doubts on this one, Dog-Brain?

    As far as I can see, the only difference between you and Fifi is that Fifi somehow drags up tolerably relevant links, whereas you just bleat.

    I’d imagine you both look good in fish-net stockings beneath a wonky lamp-post, wearing a tight short red leather mini-dress. Why not try it, O Sabbatical One?

    My bet is that Fifi looks prettier.

    Shave yer legs!

  2. dougman says:

    Re: With a link, if you please?

    Dr. Tosser BING not working?

  3. DrLoser says:

    Watchdog timers are another item that can be added to any CPU that results in halt not being halt either.

    Care to explain that cretinism one more time, Fifi?

    With a link, if you please?

  4. DrLoser says:

    And back to a microwave cretin who doesn’t quite understand how C works on embedded systems.

    Sorry Deafspy the reality is a lot of things are based on platform. Even in the pascal embedded CPU listed there are cpu there that allow halt to be restart.

    Primary application can still call sub applications. Like starting code in untrusted from trusted or trusted from untrusted.

    Would you care to explain any bit of that, Fifi?

    Anything at all?

    Feel free to start with the concept of a “trusted” application in an embedded environment, for example. I pick that opportunity at random.

    Obviously, any other explanation that occurs to your fluffy little mind would also work for present purposes.

  5. Deaf Spy says:

    Indeed, Fifi, and your whole bubbling has nothing to do with the problem we’re discussing.

    exit / halt always return a value. Where there is an OS to register it is a completely different story. As usual, you are an incompetent fraud, who only wants to mud the conversation.

    Off to writeln(), Fraud!

  6. oiaohm says:

    Tell us, incompetent fraud. What happens on an embedded, bare-bone device without an OS, when the primary application you run on it exits?

    Depends on the platform. Exit state either triggers a complete halt or a system restart.

    If halt at hardware level equals halt is in fact hardware platform configuration.

    Sorry Deafspy the reality is a lot of things are based on platform. Even in the pascal embedded CPU listed there are cpu there that allow halt to be restart.

    Primary application can still call sub applications. Like starting code in untrusted from trusted or trusted from untrusted.

    Btw, did you bother to actually read the code sample in your very own link? It has the answer, little one.
    I did Deafspy idiot. Problem is I knew the CPU listed. So only half the story was in the cite. So much comes back to platform you are running on its not funny.

    Watchdog timers are another item that can be added to any CPU that results in halt not being halt either.

  7. DrLoser says:

    I presume that you are prepared to confess, in public, that you are an incompetent and ignorant old fraud when it comes to explaining how a random esoteric computer language — let us here stipulate, say, K&R C — functions on a random esoteric computer operating system — let us stipulate, say, Linux — Robert.

    Oh, and by the way, whilst you are in confessional mode. You didn’t even consider treating the Little Woman to a $99 Wintel Thin Client With Docking Station, did you?

    Not that you are an outrageously cheap and bigoted old miser, or anything.

    Demonstrably not so. In some as yet unspecified yet important way.

  8. DrLoser says:

    In particular from ancient times we figured out that GOTO was the root of much evil and avoided it like the plague. Then if absolutely necessary, we only used it in the exceptional case so checking “err” twice is a tiny waste.

    Somewhat entertainingly from the perspective of a producer rather than a consumer of this stuff, Pog:

    No producer gives a rat’s ass about this tiny two-times “err” waste.

    Now, as the self-admitted completely ignorant consumer of this … I’m a gonna help you out here, Pog, it’s a O(1) waste …

    How should those of us who work for a living, and would prefer to be paid for work, handle this “tiny waste?”

    I’ll give you a clue here, Robert Pogson.

    We will, for fairly obvious reasons, completely ignore you.

    There now. That wasn’t so hard, was it? You’ve just confessed that you are an ignorant moron. And I, in my professional capacity as somebody who is expected to judge algorithms (more or less) on their cost, have pointed out that you were being a moron.

    Better luck next time!

  9. DrLoser says:

    Do tell. Do cite. Do, Princess, link.
    DrMoron cannot follow links. TARGET_Embedded does exactly that builds pascal code on bare-bones embedded style no host OS or parent application to return an exist value to.

    Basically stop asking me to cite stuff I have already cited Dr Moron.

    Sure thing, Fifi. It must be really difficult to repeat a cite if the Microwaves in your head interfere.

    I’ve never heard it happen to anybody else, but what the heck. I have no wish to cause you any further pain after I have ground your stupid useless pathetic arguments into the ground.

    We’re as one, then. Let us not “asking each other to cite stuff.”

    Your cites are bollocks, Fifi.

    My cites are an honest attempt to remedy errors and so on, Fifi, but then again, Fifi, you are a miserable little bag of every sort of error imaginable.

    I forgive you. I will go so far as to help you on your way back to happiness.

    No more “citing sources.” Just calling each other names at random.

    Sounds like an opportune moment to call you a pointless ignorant little Queef, oiaohm.

  10. Deaf Spy says:

    DrMoron cannot follow links. TARGET_Embedded does exactly that builds pascal code on bare-bones embedded style no host OS or parent application to return an exist value to.

    Tell us, incompetent fraud. What happens on an embedded, bare-bone device without an OS, when the primary application you run on it exits?

    Btw, did you bother to actually read the code sample in your very own link? It has the answer, little one.

    Go back to writeln(), little lying fraud!

  11. oiaohm says:

    DrLoser secure embedded systems based on pascal or c or Forth does the example of non functional exit apply. Something executing in trusted zone cannot always send messages back to those operating non trusted. So exit value making to back to program that started it is a platform detail.

    As always, I assume you have some cretinous Google cite for this one, oiaohm.
    The prior man pages covered what happened child programs under Posix when parent process exits. Child becomes connect to parent of parent.

    http://wiki.freepascal.org/TARGET_Embedded

    It would also be possible to argue that Pascal compilers “build code” to run on barebones embedded syste.,.. BWAHAHAHAHAHAHAHAHAHA!

    Do tell. Do cite. Do, Princess, link.
    DrMoron cannot follow links. TARGET_Embedded does exactly that builds pascal code on bare-bones embedded style no host OS or parent application to return an exist value to.

    Basically stop asking me to cite stuff I have already cited Dr Moron.

  12. DrLoser says:

    If C exit or pascal halt goes exit value anywhere or will make to the parent application is nothing more than a platform detail.

    You seriously need to subscribe to a local course on TFEL, Fifi.

    But whilst you are trying to remedy your complete inability to speak the language … consider this small point.

    There isn’t actually a single real world example, either in C or in Pascal, where your following ludicrous contention applies, is there?

    Transcribed from the original gibberish, you are apparently claiming that the “exit value” can be discarded by some as yet unidentified “implementation.”

    ‘Fess up, Fifi. You’re blatantly lying here.

    BWAHAHAHAHAHAHAHAHAHAHA!

  13. DrLoser says:

    Look, I’m sorry about this. Let the rest of MrPogson/blog live a long and happy and fruitful life in 2016.

    But, this?

    Yes like to forget pascal compliers don’t have to build code to run on an OS.

    Pretty much defines Fifi’s total technical incompetence, as far as I can see.

    Word by word by word.

    Utterly indefensible.

  14. DrLoser says:

    Yes like to forget pascal compliers don’t have to build code to run on an OS.

    I presume it is possible to argue that Pascal compilers “build code” to run on thoroughbred Arabian Stallions, Princess. Perhaps you will favour us peons by sharing your photos thereof.

    It would also be possible to argue that Pascal compilers “build code” to run on barebones embedded syste.,.. BWAHAHAHAHAHAHAHAHAHA!

    Do tell. Do cite. Do, Princess, link.

  15. DrLoser says:

    I will give example ish.
    This is a posix possible flow pattern
    Program ID 1000 starts program 2000 that starts program 3000. Simple enough.
    Program 2000 exists. Now program 3000 is connected to program 1000 so when 3000 exits it messages program 1000 not 2000.

    As always, I assume you have some cretinous Google cite for this one, oiaohm.

    Because, as it stands, you make no sense whatsoever.

    Even the term “messages” makes no sense whatsoever. As it stands.

    But hey, little freaky microwave-zapped one. Do tell.

  16. DrLoser says:

    Something else in C Drloser do you know what on_exit and atexit allows you todo in POSIX.

    Indeed I do, Fifi. In fact, I specifically looked up the details whilst writing my post, just below yours.

    Your point being?

  17. DeafSpy says:

    the correct stuff was described in the man pages I provided.

    Hark, little lying fraud: the man pages you provided prove exactly what DrLoser wrote.

    Back to writeln(), little incompetent Fraud.

  18. oiaohm says:

    DrMoron. Exit and Halt only return a value to something if there is something to return a value to.

    What does a exit or halt do on a embedded system where the program is not running with a OS.
    http://www.freepascal.org/docs-html/rtl/system/halt.html
    Yep exactly as described in freepascal.
    –Stop program execution.–
    http://wiki.freepascal.org/TARGET_Embedded

    Yes like to forget pascal compliers don’t have to build code to run on an OS.

    The … C … exit() … function … stores … an … integer … value … in … the … program … context/environment* … and … then … returns … control … to … the … process … that … invoked … it … in … the … first … place

    Not how it works all the time. Exit allows code to set a return value but its a platform feature if the process that invoked it ever gets to see the value.

    Depending on exit values to message between applications can bring major tears at times. Reality of the Halt function in Pascal and the Exit function in C is what ever value you set by them may not make it.

    Something else in C Drloser do you know what on_exit and atexit allows you todo in POSIX. Good fun register an exit handler that allows you to change that exit(0) or exit(10) to what ever value the last exit handler decides to set the error value as. There is equal evil inside different Pascals.

    If C exit or pascal halt goes exit value anywhere or will make to the parent application is nothing more than a platform detail. So you should check the platform you are building for before presuming that the value is going to be what you are expecting.

    In a void function type in C using return without value is still valid. Void function using return with value is invalid. Issue is try catch handling is defined for pascal exit so it cleans up where return in C or C++ is not defined to make sure try catch is cleaned up if you use it.

    Something else the idea that the program returns to the process that invoked it is wrong.

    I will give example ish.
    This is a posix possible flow pattern
    Program ID 1000 starts program 2000 that starts program 3000. Simple enough.
    Program 2000 exists. Now program 3000 is connected to program 1000 so when 3000 exits it messages program 1000 not 2000.

    So the idea that the exit value is returned to the program that invoked it is wrong. The exit value will be attempts to be returned to some process maybe the process that invoked it maybe process that invoked that process or …. back up the tree until you get to first process on the system on Posix systems..

    DrLoser you moron has no clue how this works. Lot of bad documentation out there the correct stuff was described in the man pages I provided.

  19. DrLoser says:

    Dear Doctor, I believe the confusion comes from the fact that in Pascal, exit is the same as C’s return, and has nothing to do with C’s exit. (Now I can rant about how one returns a value from a function in Pascal, but that’s another story). Pascal’s analogue for it is halt.

    I thank you for that clarification, Deaf Spy. Rather surprising that Fifi didn’t manage it … what with knowing everything about everything.

    Oh well. Occasionally Mistress Fifi lapses. And I digress.

    This is actually a very useful clarification, for everybody involved.
    1) I was unaware of the analogue between Pascal’s Halt() and C’s exit().
    2) Possibly Robert was aware of that analogy. Regrettably his long-cherished pedagogical skills failed him utterly in that case, and he did not make the correlation explicit.
    3) In the case of halt/return/exit, there is an obvious issue here with mindless nominalism. It’s all too clear that Fifi, for example, lives her entire life in the unredeemed pursuit of rancid mindless nominalism … in Fifi’s case, one can substitute the term “Googling” for rancid mindless nominalism.

    It comes as something of a shock that a colossal Manitoban cultural icon of intellectual superiority — I refer to none other than The Pog — is apparently also a pathetic dweeb who somehow considers that one can “win” a discussion in Computer Science by trivial, nay, pathetic, mindless nominalist confusion between, say, halt(), exit() and return().

    Tut tut. Oh dear. Whoopsie. Etc.

    Rather entertainingly for those of us who are not predisposed to mindless nominalism, however …

    … This is actually a big part of the earlier discussion of Duck Typing.

    Why? Well, ahem. If “duck typing” is not reliant on nominalism, then what else is it there for?

  20. DrLoser says:

    Dear Doctor, I believe the confusion comes from the fact that in Pascal, exit is the same as C’s return, and has nothing to do with C’s exit.

    I was fumbling towards this conclusion myself the other night. Of course, it would help if Robert was capable of explaining his thinking, but sadly he is an ancient wretch without benefit of a Computer Science qualification.

    In this case, I think his inadvertent lack of qualification, added to incipient senility, has unfortunately clouded what little sense he made in the first place…

    … Without benefit of actual comment by Robert, and with a lot of hard thinking on my part, I think that you, Deaf Spy, and I will probably … although this is still arguable … agree that Robert’s original “think” or should I say “inadvertent quasi-senile thunk” was, apparently, that:

    1) You cannot call the equivalent of exit() from within a (*THIS IS APPARENTLY IMPORTANT) Pascal program. Supposedly this will cause the Rapture or the Grottification of the Kernel or something, but whatever, do not do it.
    2) You can call it from C. Thus causing grottification, etc.

    Well, this is completely absurd. And Robert has yet to show a defence.

    (*) I theorise, whilst attempting to parse Robert’s complete ignorance of C, Robert’s complete ignorance of operating systems, Robert’s complete ignorance of the Linux Kernel as it applies to a C program that calls exit() … and sundry other things … that this right here is Robert’s basic issue with C, as stated in his apologia pro senilitas suas:

    So, you’re going to terminate the Linux kernel to avoid an “if” statement?

    I am prepared to accept that Robert has some other meaning in mind. However, the only way I can understand this right now is that it is an assertion that C programs use exit() as a short-cut for a “Pascal return,” whatever the semantics of one of those might be.

    Of course, this would be easier for all of us if Robert were able to understand:
    1) Semantics
    2) Syntax
    3) Lexical analysis
    4) Anything at a lower level.

    But, and rather sadly, we are where we are. And where we are (quite remarkably, since it hasn’t really been much of an issue since at the latest 1990, Robert), is where we are.

    Which is this, Robert.

    Regrettably, and much as I admire you, your stance on the return value of C programs is fantastically, utterly, inadmissibly, ludicrously absurd.

    Go on, you’re a Seeker After Truth.

    Write a tiny little program in C and test your theories for yourself.

  21. Deaf Spy says:

    I mean, what on earth are you blethering on about?

    Dear Doctor, I believe the confusion comes from the fact that in Pascal, exit is the same as C’s return, and has nothing to do with C’s exit. (Now I can rant about how one returns a value from a function in Pascal, but that’s another story). Pascal’s analogue for it is halt.

  22. DrLoser says:

    So, you’re going to terminate the Linux kernel to avoid an “if” statement? That doesn’t sound like a good deal to me. “exit” in PASCAL, terminates the subroutine and returns to the calling routine, something far more useful.

    Who said anything about terminating a kernel? I’m going to say this very, very, slowly, Robert. Feel free to follow along with your finger whilst moving your lips for added comprehension.

    The … C … exit() … function … stores … an … integer … value … in … the … program … context/environment* … and … then … returns … control … to … the … process … that … invoked … it … in … the … first … place. [Well, done, Robert! Pant pant pant! Still with us?]

    This is precisely the behaviour you would expect, had you ever checked the status code in a bash script after calling a C program. It also — unsurprisingly — appears to be the defined behaviour of Free Pascal, although I concede that you are far more of an expert in Free Pascal than I, Robert.

    I mean, what on earth are you blethering on about?

    * Note that this is effectively, in a Posix environment, the equivalent of calling setenv(“$?”, “some integer value”) … with the proviso, obviously, that you cannot directly set the magic $? shell variable.

  23. DeafSpy says:

    You should offer Linus a patch immediately…

    Definitely not in this particular case. They use goto to jump to an error processing piece of the function, not to just leave the it quietly.

    Actually, I don’t mind gotos. I definitely discourage them, but sometimes, well, “sometimes you have to fight to be a man”.

  24. Deaf Spy wrote, “in C you can simply use
    return;”
    .

    Well, there it is, perhaps C isn’t complete cripple-ware. You should offer Linus a patch immediately…

  25. Deaf Spy says:

    So, you’re going to terminate the Linux kernel to avoid an “if” statement? That doesn’t sound like a good deal to me. “exit” in PASCAL, terminates the subroutine and returns to the calling routine, something far more useful.

    Robert, in C you can simply use
    return;
    and there you are, you're leaving a void function. Exactly the same as Pascal's exit.

    Have you ever used C, Robert?

  26. DrLoser wrote, “by one means or another the call to exit(), parameterised by an integer, causes the C program in question to terminate and thereby returns control to the run-time environment.”

    So, you’re going to terminate the Linux kernel to avoid an “if” statement? That doesn’t sound like a good deal to me. “exit” in PASCAL, terminates the subroutine and returns to the calling routine, something far more useful.

  27. DrLoser says:

    So, how does that work? C’s exit wants to send a signal but the kernel doesn’t want a signal… Oops!

    The way it works, Robert, is that by one means or another the call to exit(), parameterised by an integer, causes the C program in question to terminate and thereby returns control to the run-time environment. Said run-time environment duly continues on its merry way, having picked up that integer and used it as appropriate.

    In other words, exit() provides precisely the behaviour that you seem to believe is absent in C programs. Which leads me to believe that you have never actually written a C program in your life.

    The precise mechanism — be it a posix signal or some other detail of the OS — is of absolutely no interest whatsoever, unless of course you are Fifi and you want both to have your cake and eat it. (Yes, Fifi, well spotted: Robert’s cite is by no means a canonical, nor even a reliable, authority on the C language. Unlike you, Fifi, I decided to let that small and totally unimportant detail go.)

    Simply put, Robert: you claim that C behaves in a certain way. I refute your claim.

    You are wrong.

  28. DeafSpy says:

    Fifi, again you try to explain that the documentation of a certain technology is incorrect, and you know the said technology better than anyone else. Just like with FreePascal, writeln() and compiler magic. Just like with duck-typing / late-binding. Just like with NT kernel. Just like with anything else.

    You are an incompetent and lying fraud, little Fifi.

  29. oiaohm says:

    DrLoser
    The C library function void exit(int status) terminates the calling process immediately. Any open file descriptors belonging to the process are closed and any children of the process are inherited by process 1, init, and the process parent is sent a SIGCHLD signal.
    Quoting this proves you are a moron.

    SIGCHILD to PID 1 is a system Dependant behavior not a C behavior. Sending a SIGCHILD at all is a Posix behavour(note POSIX does not state it has to go to PID1). What do you think C programs running under Windows do when there are is no PID 1.

    Also a really really good question who receives the SIGCHILD message when PID 1 exits. Also there is a horible question on Solaris, Linux and BSD using Zones, Cgroups or Jails. What PID 1. Zones/Cgroups/Jails can run there own unique PID numbers to the everything else on system.

    This also gets more fun. Posix standard does not say you have to message PID1 when process ends.
    http://linux.die.net/man/3/exit
    Please read this correctly worded documentation on C library exist function.

    Only reason why PID1 gets Posix SIGCHLD messages is that is the first parent application on the system. PID1 parent of course is the kernel. So the kernel gets the SIGCHILD message from PID1. Also the POSIX C Library exit function may or may not send SIGCHILD why may or may not. SIGCHILD message on some Posix compatible kernels is triggered when Kernel terminates process not part of the C library exit function at all. If the kernel decided to start first process as lets say 1000 PID instead of 1 then 1000 would be the process getting the clean up job.

    Nothing in standard http://linux.die.net/man/2/setpgid orphaned parts has to go to PID1. Yes default under Linux is that they do so kernel does not have to bother about it. Note the word default. Not true inside a Cgroup in all cases. Not true on a lot of other Posix OS at all this include Windows.

    Basically DrLoser you incompetent you should have pulled Robert Pogson on quoting documentation written by a idiot. Of course DrLoser being the idiot you attempted to make a point by it.

    There are a lot of other mistakes in that tutorialspoint so call information about C libraries.

  30. DrLoser wrote, “the process parent is sent a SIGCHLD signal.”

    Yes, but, “The void type, in several programming languages derived from C and Algol68, is the type for the result of a function that returns normally, but does not provide a result value to its caller. Usually such functions are called for their side effects, such as performing some task or writing to their output parameters.”

    So, how does that work? C’s exit wants to send a signal but the kernel doesn’t want a signal… Oops!

  31. DrLoser says:

    Chuckle. This guy has been running a code-checker over all of Linux and finding little things to tweak… Meanwhile folks are trying to debug/secure/achieve better performance.

    On a more conciliatory note, perhaps, I will admit to being intrigued.

    Who is this Masked Man? What is his code-checker? Can we assign a continuous function that takes “little things” and measures the “tweakiness?”

    And good for those folks, say I. If only those folks had been present for the last twenty-odd years of Linux development!

    Oh wait … they were, weren’t they?

    I sense a really, really, vitally important post coming out of all that spurious gibberish that you hastily hacked together, Robert. In fact, I am looking forward to it.

  32. DrLoser says:

    DrLoser wrote, “Is this the sort of C you are talking about?”

    Nope. It’s a void function. Can’t return a status…

    Ah, I see. You’re not talking about C functions in general at all. You’re talking about the C Library Function exit(), apparently. Well, as usual, let us begin with Baby Steps, to whit, quoting your own cite:

    The C library function void exit(int status) terminates the calling process immediately. Any open file descriptors belonging to the process are closed and any children of the process are inherited by process 1, init, and the process parent is sent a SIGCHLD signal.

    So much for “not returning a status.”

    Have you ever, even once, read any of your cites, Robert? All the way to the bottom of the cite? Engaging brain whilst doing so?

    Or is all this stuff just pretty little verbal patterns to you?

    I mean, I’d like to believe that you actually engage your brain every now and again. But quite honestly the evidence for this, when it comes to the cites you come up with to “support” your claims, is practically nonexistent.

    If the words are shaped in happy happy terms, you’ll just go ahead and publish, won’t you?

  33. DrLoser wrote, “Is this the sort of C you are talking about?”

    Nope. It’s a void function. Can’t return a status

    see drivers/net/wireless/marvell/libertas/if_spi.c
    “static void if_spi_host_to_card_worker(struct work_struct *work)
    {
    int err;
    struct if_spi_card *card;
    u16 hiStatus;
    unsigned long flags;
    struct if_spi_packet *packet;
    struct lbs_private *priv;
    card = container_of(work, struct if_spi_card, packet_work);
    priv = card->priv;
    lbs_deb_enter(LBS_DEB_SPI);
    /*
    * Read the host interrupt status register to see what we
    * can do.
    */
    err = spu_read_u16(card, IF_SPI_HOST_INT_STATUS_REG,
    &hiStatus);
    if (err) {
    netdev_err(priv->dev, “I/O error\n”);
    goto err;
    }
    if (hiStatus & IF_SPI_HIST_CMD_UPLOAD_RDY) {
    err = if_spi_c2h_cmd(card);
    if (err)
    goto err;
    }
    if (hiStatus & IF_SPI_HIST_RX_UPLOAD_RDY) {
    err = if_spi_c2h_data(card);
    if (err)
    goto err;
    }
    /*
    * workaround: in PS mode, the card does not set the Command
    * Download Ready bit, but it sets TX Download Ready.
    */
    if (hiStatus & IF_SPI_HIST_CMD_DOWNLOAD_RDY ||
    (card->priv->psstate != PS_STATE_FULL_POWER &&
    (hiStatus & IF_SPI_HIST_TX_DOWNLOAD_RDY))) {
    /*
    * This means two things. First of all,
    * if there was a previous command sent, the card has
    * successfully received it.
    * Secondly, it is now ready to download another
    * command.
    */
    lbs_host_to_card_done(card->priv);
    /* Do we have any command packets from the host to send? */
    packet = NULL;
    spin_lock_irqsave(&card->buffer_lock, flags);
    if (!list_empty(&card->cmd_packet_list)) {
    packet = (struct if_spi_packet *)(card->
    cmd_packet_list.next);
    list_del(&packet->list);
    }
    spin_unlock_irqrestore(&card->buffer_lock, flags);
    if (packet)
    if_spi_h2c(card, packet, MVMS_CMD);
    }
    if (hiStatus & IF_SPI_HIST_TX_DOWNLOAD_RDY) {
    /* Do we have any data packets from the host to send? */
    packet = NULL;
    spin_lock_irqsave(&card->buffer_lock, flags);
    if (!list_empty(&card->data_packet_list)) {
    packet = (struct if_spi_packet *)(card->
    data_packet_list.next);
    list_del(&packet->list);
    }
    spin_unlock_irqrestore(&card->buffer_lock, flags);
    if (packet)
    if_spi_h2c(card, packet, MVMS_DAT);
    }
    if (hiStatus & IF_SPI_HIST_CARD_EVENT)
    if_spi_e2h(card);
    err:
    if (err)
    netdev_err(priv->dev, “%s: got error %d\n”, __func__, err);
    lbs_deb_leave(LBS_DEB_SPI);
    }”

    On a related matter, the authour of this patch has been offending hoary old developers on LKML for suggesting such slight tweaks:“And like David Miller and others just said, please don’t bother us with pointless patches such as this, if you keep it up, I’ll have to add you to my killfile as patches like this are a waste of everyone’s valuable time. greg k-h”

    Chuckle. This guy has been running a code-checker over all of Linux and finding little things to tweak… Meanwhile folks are trying to debug/secure/achieve better performance.

  34. DrLoser says:

    Just a minute. Hold your horses here, Robert. What on earth do you mean by the following?

    No “exit” in C? Pity. Can’t use “return”? Nope. The routine is a “void” function. Not even “break” or “continue” help. They are restricted to loops. Sad. Why do people use such a crude language as C?

    Fairly obviously, I am not on the same wavelength as you at all. Ignoring choice of syntactic sugar (“break,” “continue,” pick keyword of choice) — which you appear to believe is important, although as always I will concede that you may be joking here — what’s all this return/exit/void function stuff?

    We are, I assume, talking about the C language? The one that — after a long and painful battering of Fifi’s intransigence against the relevant wall, we have all finally admitted allows the following?

    #include "stdio.h"
    #include "stdlib.h"
    #include "stdarg.h"

    int main (int argc, char** argv)
    {
    printf ("Hello!\n");
    char* pFred = getenv("FRED");
    if (pFred)
    return -1;
    exit(1);
    }

    I’m a bit at a loss here. Is this the sort of C you are talking about?

  35. Deaf Spy says:

    For many purposes Pascal is about the same speed as C.

    And so is Java. And so is C#.

  36. Deaf Spy says:

    Python parallel programming and signaling in Linux:
    https://code.google.com/p/pypar/

    MPI, dear, dear… Some people can’t come out of the stone age.

  37. DrLoser says:

    How’s the overall control and signalling thing going for you, anyhoo?

    Gonna work real well on a HPC sort of deal when you have the well-known Python limitation of a GUL, innit?

    And before you start wittering about ways around that particular choice of locking strategy .,. there are none. Not using Python.

    Certainly none that are scalable across, say, 1000 cores, which you have led us to believe is your particular domain.

  38. DrLoser says:

    The slightest sliver of a reference, either direct or indirect, to that “come-from” allegation you imagine, ram?

    I’m convinced you have one. Now then, let’s see. A troll is defined as somebody who spends their time on a reputable site (such as Mr Pogson) by repeatedly spewing disinformation, I believe.

    Your interesting interjection, I believe, consists either of disinformation or of misrepresentation.

    Naturally, I am open to being corrected on either of these two points.

  39. ram says:

    The trolls on this site are probably especially fond of the “Computed ComeFrom” statement. Kinda like the Computed GoTo just in reverse ;-D

  40. DrLoser says:

    Unlike the sycophants of M$ etc., I don’t hold Linus to be God.

    This is indeed a fine New Year for us all, then Robert. I, as an unjustly accused “sycophant of M$,” do not project Linus to any sort of identifiable god-like position, either.

    On the other hand, I am not prepared to concede that he is Finnish, either, pace Luvr. Nor am I prepared to allow you to twist sideways and misadvert your supposed objection to goto simply by admitting that you do not regard Torvalds as “God.” (As if that mattered. Ad hominem, Robert. Or in this particular case, Non Ad Deum.)

    The rest of your answer was frankly rather long-winded and tedious. Excellent! You’re learning the odd thing from me, aren’t you, Robert?

  41. DrLoser wrote, “the opinions of Linus Torvald “.

    Unlike the sycophants of M$ etc., I don’t hold Linus to be God. Linus is not always right, just usually right. Of course, FreePascal isn’t exactly the standard Pascal Linus wrote about.

    I’ll give you my opinion of GoTo… Once upon a time in a galaxy not far away, I was given some boxes of punched cards. They represented the state of the art in analyzing the magnetic fields of cyclotrons for the purposes of understanding the vertical and horizontal focussing of the beam of charged particles being accelerated. The thing would not even compile on our mainframe. The main routine was 4K lines of code riddled with GoTos. It took me a month to figure out how it worked, often mysteriously. I then rewrote it in a week or so and it would run and compile on our VAX mini-computer…

    I kid you not. They were using “computed” GoTos instead of breaking the code up into reusable routines. It was absolutely bizarre. I think there wasn’t a single GoTo in what I wrote. They just weren’t necessary and really obfuscated the code. 4K of code was reduced to 1K in my version. The results were quite usable and served us well for years. Unfortunately, we discovered our cyclotron was the only one on the planet apparently designed to depolarize polarized H ion-beams… [SARCASM].

    $millions were spent on trying to fix that but to no avail. You see, our compact cyclotron had 4 poles because someone thought that was a good idea. Everyone else was using 3 or 5… If my code had been available during the design phase of the project this debacle might have been avoided but it was not. Back of the paper-bag estimates were used to build the magnet. The cyclotron was a great tool for doing low energy nuclear physics but not with polarized beams. At one point most of the nuclear physicists in Canada were educated or gained experience at our lab but that all moved on… Great fun, except for the taxpayers. Still, our mistakes were orders of magnitude smaller than other kinds of mistakes governments make.

    Just for fun I did a linux-4.4-rc7$ grep -R -i goto .|wc
    130634 398921 6340822

    Out of millions of lines of code, I wonder how many of those ~100K are necessary.

  42. DrLoser wrote, “I seriously recommend that you learn and apply Python.”

    At one stage of my life I used M$’s BASIC on my Ohio Scientific Super Board II… I haven’t used it since and I doubt Python is much better for my purposes. I like a compiled language, just for the efficiency. Beast can stand a little waste but he’s burdened with hundreds of processes. I don’t see the point of using an interpreter for much more than PHP or BASH where tiny lags don’t matter. The innermost loops of some of my number-crunching routines do matter. For many purposes Pascal is about the same speed as C.

  43. DrLoser says:

    Python for overall control and signaling…

    There goes what little credibility you ever had, ram.

    Signalling in what possible useful way, pray? Quite apart from the blatant fact that there are about a billion other better reasons to use Python. (Or quite possibly Perl. Or pick other language.)

    “Signalling?”

    Pfui.

  44. DrLoser says:

    In particular from ancient times we figured out that GOTO was the root of much evil and avoided it like the plague.

    If I were you, Robert, I would advert your tender eyes from the opinions of Linus Torvald (“World’s most popular Finn,” as the splendidly ignorant Luvr would have it) on the matter of “goto.”

    Seems to me that you haven’t yet spent much of your declining years avoiding the Linux kernel “like the plague.”

    Well, as they say. A foolish consistency is the hobgoblin of little minds. You are therefore forgiven, Mr P.

  45. DrLoser says:

    Sadly, FreePascal allows this silliness too but I still think a Pascal programmer would have more sense.

    An excellent and very pertinent comment, Robert, although I cannot see more than a scant dozen or so people adopting FreePascal as a Systems Language.

    Allow me to simplify the transition for you, then. If you actually need guarantees for object lifetimes, which will work across an arbitrary number of threads, then there is indeed a modern computer programming language that will give you such things.

    Regrettably, Robert, you are stuck with Free Pascal, I think. Because you have absolutely no chance whatsoever of handling Language X.

    (Which, since I am fair, is nothing like a Functional Language — say, the stuff you need to understand in order to write snippets of systemd initialisation. And it’s not like JavaScript and it’s not like D (wannabe successor to C++, which has some value) and it’s not like Scala. But anybody familiar with recently popular programming languages on the periphery of adoption will instantly recognise which one I mean.)

    Robert, being a bit of a clumsy dinosaur, almost certainly has no idea. Which is fine and dandy.

    Mr Pogson: for your own good, I seriously recommend that you learn and apply Python. I so recommend wholeheartedly and in the spirit of compassion.

  46. kurkosdr says:

    Why do people use such a crude language as C?

    You see, because of the boatloads of code already out there written in C, most programmers are forced to learn C. Some universities even teach it as a first language (mine did, switched to python as first language while I was in 4th year, with C following the next semester).

    And since C is a compact language, most programmers tend to stick to it, because learning complex tools is hard. Sad but true.

    But what I actually hate is programmers who absolutely have to use the hairiest, most moronic bits of C and act as if it’s normal and that everyone should play along (and spend a disproportionate amount of time trying to make sense of the mess) as if it’s normal. You know: ifdefs, nested ifdefs, labels, casting abuse of all kinds, intense pointer cha-cha, goto’s for anything else than quick exit, void* that shouldn’t be void*, and whatever else they come up with. In a commercial environment where the programmers get paid, this kind of behaviour can be regulated if the Management and supervisors care enough. In a FOSS project, where arogant volunteers with inflated egos are your only (unpaid) workforce, good luck.

    OpenGL for graphics
    So, OpenGL became a programming language instead of an API now? Did I miss an industry meeting or something? (note: you can make OpenGL calls from C, C++, Java and any other language someone has taken time to implement the API as a library).

  47. ram says:

    Personally I like FORTRAN90 or FORTRAN95. Not too good for graphics though 😉

    Fortunately in Linux with the GNU compilers one can write programs in a mixture of languages. FORTRAN for the heavy numeric computations, Python for overall control and signaling, C for hardware device drivers, OpenGL for graphics, and so on. Mixed language programing, one of the true strengths of GNU/Linux!

Leave a Reply