Changeset 26186 in vbox for trunk/src/VBox/Main/glue
- Timestamp:
- Feb 3, 2010 1:07:12 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57205
- Location:
- trunk/src/VBox/Main/glue
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/ErrorInfo.cpp
r21878 r26186 145 145 void ErrorInfo::init (IUnknown *aI, const GUID &aIID, bool aKeepObj /* = false */) 146 146 { 147 Assert 147 Assert(aI); 148 148 if (!aI) 149 149 return; … … 210 210 { 211 211 mNext.reset (new ErrorInfo (next)); 212 Assert 212 Assert(mNext.get()); 213 213 if (!mNext.get()) 214 214 rc = E_OUTOFMEMORY; … … 235 235 ErrorInfo (false /* aDummy */) 236 236 { 237 Assert 237 Assert(progress); 238 238 if (!progress) 239 239 return; -
trunk/src/VBox/Main/glue/EventQueue.cpp
r23128 r26186 485 485 BOOL EventQueue::waitForEvent (Event **event) 486 486 { 487 Assert 487 Assert(event); 488 488 if (!event) 489 489 return FALSE; … … 518 518 rc = mEventQ->WaitForEvent (&ev); 519 519 // check for error 520 if (FAILED 520 if (FAILED(rc)) 521 521 return FALSE; 522 522 // check for EINTR signal … … 545 545 BOOL EventQueue::handleEvent (Event *event) 546 546 { 547 Assert 547 Assert(event); 548 548 if (!event) 549 549 return FALSE; -
trunk/src/VBox/Main/glue/SupportErrorInfo.cpp
r26177 r26186 50 50 { 51 51 sCounter = RTTlsAlloc(); 52 AssertReturnVoid 52 AssertReturnVoid(sCounter != NIL_RTTLS); 53 53 } 54 54 55 uintptr_t counter = (uintptr_t) RTTlsGet(sCounter);56 ++ 57 RTTlsSet (sCounter, (void *)counter);55 uintptr_t counter = (uintptr_t)RTTlsGet(sCounter); 56 ++counter; 57 RTTlsSet(sCounter, (void*)counter); 58 58 } 59 59 … … 61 61 void MultiResult::decCounter() 62 62 { 63 uintptr_t counter = (uintptr_t) RTTlsGet(sCounter);64 AssertReturnVoid 65 -- 66 RTTlsSet (sCounter, (void *)counter);63 uintptr_t counter = (uintptr_t)RTTlsGet(sCounter); 64 AssertReturnVoid(counter != 0); 65 --counter; 66 RTTlsSet(sCounter, (void*)counter); 67 67 } 68 68 … … 106 106 { 107 107 /* whether multi-error mode is turned on */ 108 bool preserve = ((uintptr_t) RTTlsGet(MultiResult::sCounter)) > 0;108 bool preserve = ((uintptr_t)RTTlsGet(MultiResult::sCounter)) > 0; 109 109 110 110 LogRel(("ERROR [COM]: aRC=%#08x aIID={%RTuuid} aComponent={%s} aText={%s} aWarning=%RTbool, aInfo=%p, preserve=%RTbool\n", … … 120 120 { 121 121 /* these are mandatory, others -- not */ 122 AssertReturn((!aWarning && FAILED 122 AssertReturn((!aWarning && FAILED(aResultCode)) || 123 123 (aWarning && aResultCode != S_OK), 124 124 E_FAIL); … … 143 143 /* get the current error info if any */ 144 144 ComPtr<IErrorInfo> err; 145 rc = ::GetErrorInfo 145 rc = ::GetErrorInfo(0, err.asOutParam()); 146 146 if (FAILED(rc)) break; 147 147 rc = err.queryInterfaceTo(curInfo.asOutParam()); 148 if (FAILED 148 if (FAILED(rc)) 149 149 { 150 150 /* create a IVirtualBoxErrorInfo wrapper for the native … … 154 154 if (SUCCEEDED(rc)) 155 155 { 156 rc = wrapper->init 156 rc = wrapper->init(err); 157 157 if (SUCCEEDED(rc)) 158 158 curInfo = wrapper; … … 176 176 if (FAILED(rc)) break; 177 177 178 rc = infoObj->init 178 rc = infoObj->init(aInfo, curInfo); 179 179 if (FAILED(rc)) break; 180 180 … … 183 183 184 184 /* we want to return the head's result code */ 185 rc = info->COMGETTER(ResultCode) 185 rc = info->COMGETTER(ResultCode)(&aResultCode); 186 186 if (FAILED(rc)) break; 187 187 } … … 192 192 if (FAILED(rc)) break; 193 193 194 rc = infoObj->init 194 rc = infoObj->init(aResultCode, aIID, aComponent, strText.c_str(), curInfo); 195 195 if (FAILED(rc)) break; 196 196 … … 201 201 rc = info.queryInterfaceTo(err.asOutParam()); 202 202 if (SUCCEEDED(rc)) 203 rc = ::SetErrorInfo 203 rc = ::SetErrorInfo(0, err); 204 204 205 205 #else // !defined (VBOX_WITH_XPCOM) 206 206 207 207 nsCOMPtr <nsIExceptionService> es; 208 es = do_GetService 208 es = do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID, &rc); 209 209 if (NS_SUCCEEDED(rc)) 210 210 { 211 211 nsCOMPtr <nsIExceptionManager> em; 212 rc = es->GetCurrentExceptionManager (getter_AddRefs(em));212 rc = es->GetCurrentExceptionManager(getter_AddRefs(em)); 213 213 if (FAILED(rc)) break; 214 214 … … 218 218 /* get the current error info if any */ 219 219 ComPtr<nsIException> ex; 220 rc = em->GetCurrentException 220 rc = em->GetCurrentException(ex.asOutParam()); 221 221 if (FAILED(rc)) break; 222 222 rc = ex.queryInterfaceTo(curInfo.asOutParam()); 223 if (FAILED 223 if (FAILED(rc)) 224 224 { 225 225 /* create a IVirtualBoxErrorInfo wrapper for the native … … 229 229 if (SUCCEEDED(rc)) 230 230 { 231 rc = wrapper->init 231 rc = wrapper->init(ex); 232 232 if (SUCCEEDED(rc)) 233 233 curInfo = wrapper; … … 236 236 } 237 237 /* On failure, curInfo will stay null */ 238 Assert 238 Assert(SUCCEEDED(rc) || curInfo.isNull()); 239 239 240 240 /* set the current error info and preserve the previous one if any */ … … 251 251 if (FAILED(rc)) break; 252 252 253 rc = infoObj->init 253 rc = infoObj->init(aInfo, curInfo); 254 254 if (FAILED(rc)) break; 255 255 … … 259 259 /* we want to return the head's result code */ 260 260 PRInt32 lrc; 261 rc = info->COMGETTER(ResultCode) 261 rc = info->COMGETTER(ResultCode)(&lrc); aResultCode = lrc; 262 262 if (FAILED(rc)) break; 263 263 } … … 277 277 rc = info.queryInterfaceTo(ex.asOutParam()); 278 278 if (SUCCEEDED(rc)) 279 rc = em->SetCurrentException 279 rc = em->SetCurrentException(ex); 280 280 } 281 281 else if (rc == NS_ERROR_UNEXPECTED) … … 301 301 while (0); 302 302 303 AssertComRC 303 AssertComRC(rc); 304 304 305 305 return SUCCEEDED(rc) ? aResultCode : rc; … … 307 307 308 308 /* static */ 309 HRESULT SupportErrorInfoBase::setError 310 311 312 { 313 va_list args; 314 va_start 315 HRESULT rc = setErrorV 316 va_end 309 HRESULT SupportErrorInfoBase::setError(HRESULT aResultCode, const GUID &aIID, 310 const char *aComponent, const char *aText, 311 ...) 312 { 313 va_list args; 314 va_start(args, aText); 315 HRESULT rc = setErrorV(aResultCode, aIID, aComponent, aText, args); 316 va_end(args); 317 317 return rc; 318 318 } 319 319 320 320 /* static */ 321 HRESULT SupportErrorInfoBase::setWarning 322 323 324 { 325 va_list args; 326 va_start 327 HRESULT rc = setWarningV 328 va_end 329 return rc; 330 } 331 332 HRESULT SupportErrorInfoBase::setError 333 { 334 va_list args; 335 va_start 336 HRESULT rc = setErrorV 337 338 va_end 339 return rc; 340 } 341 342 HRESULT SupportErrorInfoBase::setError 321 HRESULT SupportErrorInfoBase::setWarning(HRESULT aResultCode, const GUID &aIID, 322 const char *aComponent, const char *aText, 323 ...) 324 { 325 va_list args; 326 va_start(args, aText); 327 HRESULT rc = setWarningV(aResultCode, aIID, aComponent, aText, args); 328 va_end(args); 329 return rc; 330 } 331 332 HRESULT SupportErrorInfoBase::setError(HRESULT aResultCode, const char *aText, ...) 333 { 334 va_list args; 335 va_start(args, aText); 336 HRESULT rc = setErrorV(aResultCode, mainInterfaceID(), componentName(), 337 aText, args); 338 va_end(args); 339 return rc; 340 } 341 342 HRESULT SupportErrorInfoBase::setError(HRESULT aResultCode, const Utf8Str &strText) 343 343 { 344 344 HRESULT rc = setError(aResultCode, … … 349 349 } 350 350 351 HRESULT SupportErrorInfoBase::setWarning 352 { 353 va_list args; 354 va_start 355 HRESULT rc = setWarningV 356 357 va_end 358 return rc; 359 } 360 361 HRESULT SupportErrorInfoBase::setError 362 363 { 364 va_list args; 365 va_start 366 HRESULT rc = setErrorV 367 va_end 368 return rc; 369 } 370 371 HRESULT SupportErrorInfoBase::setWarning 372 373 { 374 va_list args; 375 va_start 376 HRESULT rc = setWarningV 377 va_end 351 HRESULT SupportErrorInfoBase::setWarning(HRESULT aResultCode, const char *aText, ...) 352 { 353 va_list args; 354 va_start(args, aText); 355 HRESULT rc = setWarningV(aResultCode, mainInterfaceID(), componentName(), 356 aText, args); 357 va_end(args); 358 return rc; 359 } 360 361 HRESULT SupportErrorInfoBase::setError(HRESULT aResultCode, const GUID &aIID, 362 const char *aText, ...) 363 { 364 va_list args; 365 va_start(args, aText); 366 HRESULT rc = setErrorV(aResultCode, aIID, componentName(), aText, args); 367 va_end(args); 368 return rc; 369 } 370 371 HRESULT SupportErrorInfoBase::setWarning(HRESULT aResultCode, const GUID &aIID, 372 const char *aText, ...) 373 { 374 va_list args; 375 va_start(args, aText); 376 HRESULT rc = setWarningV(aResultCode, aIID, componentName(), aText, args); 377 va_end(args); 378 378 return rc; 379 379 } -
trunk/src/VBox/Main/glue/initterm.cpp
r25942 r26186 444 444 /* Use RTPathAppPrivateArch() first */ 445 445 vrc = RTPathAppPrivateArch(szAppHomeDir, sizeof(szAppHomeDir)); 446 AssertRC 446 AssertRC(vrc); 447 447 } 448 448 else … … 450 450 /* Iterate over all other paths */ 451 451 szAppHomeDir[RTPATH_MAX - 1] = '\0'; 452 strncpy(szAppHomeDir, kAppPathsToProbe 452 strncpy(szAppHomeDir, kAppPathsToProbe[i], RTPATH_MAX - 1); 453 453 vrc = VINF_SUCCESS; 454 454 } -
trunk/src/VBox/Main/glue/string.cpp
r21588 r26186 77 77 }; 78 78 79 void Utf8StrFmt::init 79 void Utf8StrFmt::init(const char *format, va_list args) 80 80 { 81 81 if (!format) … … 83 83 84 84 // assume an extra byte for a terminating zero 85 size_t fmtlen = strlen 85 size_t fmtlen = strlen(format) + 1; 86 86 87 87 FormatData data; … … 90 90 data.size += fmtlen; 91 91 data.pos = 0; 92 data.cache = (char *) ::RTMemTmpAllocZ(data.size);92 data.cache = (char*)::RTMemTmpAllocZ(data.size); 93 93 94 size_t n = ::RTStrFormatV 94 size_t n = ::RTStrFormatV(strOutput, &data, NULL, NULL, format, args); 95 95 96 AssertMsg (n == data.pos, 97 ("The number of bytes formatted doesn't match: %d and %d!", 98 n, data.pos)); 99 NOREF (n); 96 AssertMsg(n == data.pos, 97 ("The number of bytes formatted doesn't match: %d and %d!", n, data.pos)); 98 NOREF(n); 100 99 101 100 // finalize formatting 102 data.cache 103 (*static_cast <Utf8Str *>(this)) = data.cache;104 ::RTMemTmpFree 101 data.cache[data.pos] = 0; 102 (*static_cast<Utf8Str*>(this)) = data.cache; 103 ::RTMemTmpFree(data.cache); 105 104 } 106 105 107 106 // static 108 DECLCALLBACK(size_t) Utf8StrFmt::strOutput 109 107 DECLCALLBACK(size_t) Utf8StrFmt::strOutput(void *pvArg, const char *pachChars, 108 size_t cbChars) 110 109 { 111 Assert 110 Assert(pvArg); 112 111 FormatData &data = *(FormatData *) pvArg; 113 112 114 113 if (!(pachChars == NULL && cbChars == 0)) 115 114 { 116 Assert 115 Assert(pachChars); 117 116 118 117 // append to cache (always assume an extra byte for a terminating zero) … … 123 122 if (needed >= FormatData::CacheIncrement) 124 123 data.size += needed; 125 data.cache = (char *) ::RTMemRealloc(data.cache, data.size);124 data.cache = (char*)::RTMemRealloc(data.cache, data.size); 126 125 } 127 strncpy 126 strncpy(data.cache + data.pos, pachChars, cbChars); 128 127 data.pos += cbChars; 129 128 }
Note:
See TracChangeset
for help on using the changeset viewer.