On Sat, 2 Dec 2006, Shawn Walker wrote:
There is a special place in hell for programmers who do things like
    foo = malloc (bar);
    if (foo == 0)
        return;
Oh really? What is this in your code?
 void *block = malloc (size ? size : (size_t) 1);
 if (!block) fatal ("Out of memory");

You apparently missed the point.

The code that reads
   foo = malloc (bar);
   if (foo == 0)
       return;
simply returns from the function, making no attempt to do anything about the error, record that the error happened, or even consider the consequences of proceeding (the program in question subsequently corrupted its database, which is why I ended up looking at it).

The code that reads
  void *block = malloc (size ? size : (size_t) 1);
  if (!block) fatal ("Out of memory");
reports the fault and terminates the application immediately.

That's also bad practice, if something failed on the consistency check, just return error of "invalid parameter" or "invalid data", etc and let the application deal with the error of either not process whatever it was doing and inform the user of the error.

"Invalid parameter"/"invalid data" have nothing to do with internal consistency checks. Such things are done with checks of the arguments of system calls.

An internal consistency check is a self-check within the program itself for being corrupted, either in the code or the data. Another term which is used is "assert"; and if you look at assert.h you'll see that it calls
abort().

Wow, so let's contact Linus Torvalds, Bill Gates and Steve Jobs that they need to change the kernel to just panic when a driver or application does something bad. Let's see how far your logic will fly.

Linux, Windows, and Mac OS all are quite capable of doing a panic when a driver or application does something bad. Most BSODs from Windows are due to the misbehavior of a non-Microsoft driver, since the NT kernel itself is fairly well debugged. I have a two-line program which will crash any Mac OS X system.

But this is not what we are talking about. We are talking about internal consistency checks. Linux, Windows, and Mac OS all panic when an internal consistency check in the kernel detects corruption in the data structure. None of these kernels proceed if they detect that they have been hosed.

If you really feel that c-client is so "badly written", then I respectfully suggest that you write your own mailbox handling code.

-- Mark --

http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.
_______________________________________________
Imap-uw mailing list
Imap-uw@u.washington.edu
https://mailman1.u.washington.edu/mailman/listinfo/imap-uw

Reply via email to