[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luacom - use of un-initialized variable in tLuaControl.cpp line 756
- From: gary ng <garyng2000@...>
- Date: Thu, 2 Sep 2010 16:53:45 -0700 (PDT)
----- Original Message ----
> From: Nick Gammon <nick@gammon.com.au>
> To: Lua mailing list <lua-l@lists.lua.org>
> Sent: Thu, September 2, 2010 3:45:11 PM
> Subject: luacom - use of un-initialized variable in tLuaControl.cpp line 756
>
> Hi,
>
> I sent this privately to a possibly out-of-date email address. If this is a
>double-posting I apologise in advance.
>
> ...
>
> I downloaded luacom today (version 1.3) and when compiling I got this warning:
>
> tLuaControl.cpp(756) : warning C4700: local variable 'hr' used without having
>been initialized
>
>
> This seems to be correct:
>
>
> STDMETHODIMP tLuaControl::DoVerb(LONG lVerb, LPMSG pMsg, IOleClientSite
>*pActiveSite,
> LONG lIndex, HWND hwndParent, LPCRECT prcPosRect)
> {
> HRESULT hr;
>
> switch (lVerb) {
> case OLEIVERB_SHOW:
> case OLEIVERB_INPLACEACTIVATE:
> case OLEIVERB_UIACTIVATE:
> hr = InPlaceActivate(lVerb==OLEIVERB_UIACTIVATE);
> return (hr);
>
> case OLEIVERB_HIDE:
> UIDeactivate();
> if (m_fInPlaceVisible) SetInPlaceVisible(FALSE);
> return S_OK;
>
> default:
> // if it's a derived-control defined verb, pass it on to them
> //
> if (lVerb > 0) {
> if (hr == OLEOBJ_S_INVALIDVERB) { // <------------------ HERE!
>line 756
> // unrecognised verb -- just do the primary verb and
> // activate the sucker.
> //
> hr = InPlaceActivate(0);
> return (FAILED(hr)) ? hr : OLEOBJ_S_INVALIDVERB;
> } else
> return hr;
> } else {
> FAIL("Unrecognized Negative verb in DoVerb(). bad.");
> return E_NOTIMPL;
> }
> break;
> }
>
> // dead code
> FAIL("this should be dead code!");
> }
>
>
>
>
> Since hr is indeed undefined at this point, do you have a suggested fix?
>
>From the logic, I would just skip the test and blindly do the enclosed block as
that seems to be only reasonable path.