Larry Osterman's WebLog

Confessions of an Old Fogey
Blog - Title

What's wrong with this code, part 10

What's wrong with this code, part 10

  • Comments 64
Ok, time for another "what's wrong with this code".  This one's trivial from a code standpoint, but it's tricky...

// ----------------------------------------------------------------------
// Function:
// CThing1::OnSomethingHappening()
// Description:
// Called when something happens
// Return:
// S_OK if successful
// ----------------------------------------------------------------------
HRESULT CThing1::OnSomethingHappening()
    HRESULT hr;

    <Do Some Stuff>
    // Perform some operation...
    hr = PerformAnOperation();
    if (FAILED(hr))
    IF_FAILED_JUMP(hr, Error);

    return hr;

    goto Exit;

Not much code, no?  So what's wrong with it?

As usual, answers and kudos tomorrow.

  • Actually I don't think there are any currently defined HREULTs with FACILITY_NULL.
  • Skywing. What about S_FALSE? That's an HRESULT with FACILITY_NULL
  • 3/16/2005 7:20 AM Larry Osterman

    > Kyle: ERROR_NOT_SUPPORTED is a perfectly
    > legal HRESULT - it's just not an error code
    > (it's a success code).

    Then it should be called S_NOT_SUPPORTED just like S_FALSE.

    Calling it ERROR_NOT_SUPPORTED makes it look like ERROR_SUCCESS, lending support to the impression that all errors are successes and all WIN32 success codes are COM success hresults.
  • PingBack from

Page 5 of 5 (64 items) 12345