[ros-dev] Error handling

(•) Thomas Larsen (•) sikker2004 at yahoo.com
Mon Apr 11 22:58:43 CEST 2005


NTSTATUS DoSomething()
{
   NSTATUS Status;
   ...

   Status = NtXXX();
   if (!NT_SUCCESS(Status))
     goto done;

   Status = NtYYY();
   if (!NT_SUCCESS(Status))
     goto cleanXXX;

   Status = NtZZZ();
   if (!NT_SUCCESS(Status))
     goto cleanYYY;

cleanZZZ:
   cleanupZZZ();
cleanYYY:
   cleanupYYY();
cleanXXX:
   cleanupXXX();
done:
   return Status;
}Thomas

NTSTATUS DoSomething()
{
   NSTATUS Status = NtXXX();
   if (NT_SUCCESS(Status)) {
       Status = NtYYY();
       if (!NT_SUCCESS(Status))
           cleanupXXX();
       Status = NtZZZ();
       if (!NT_SUCCESS(Status))
           cleanupYYY();

   }
   return Status;
}

i think thats the most simple and easy to read
but in the end is´ent it not a littel waste of time
discusse old functions their need rewrite anyway..?

Thomas


More information about the Ros-dev mailing list