Changeset 98288 in vbox for trunk/src/VBox/Main/src-server/linux
- Timestamp:
- Jan 24, 2023 3:32:43 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155493
- Location:
- trunk/src/VBox/Main/src-server/linux
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/linux/HostDnsServiceLinux.cpp
r98103 r98288 185 185 */ 186 186 int aiStopPair[2]; 187 int rc = socketpair(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0, aiStopPair);187 int iRc = socketpair(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0, aiStopPair); 188 188 int iErr = errno; 189 AssertLogRelMsgReturn( rc == 0, ("socketpair: failed (%d: %s)\n", iErr, strerror(iErr)), RTErrConvertFromErrno(iErr));189 AssertLogRelMsgReturn(iRc == 0, ("socketpair: failed (%d: %s)\n", iErr, strerror(iErr)), RTErrConvertFromErrno(iErr)); 190 190 191 191 m_fdShutdown = aiStopPair[0]; … … 241 241 * Wait for something to happen. 242 242 */ 243 rc = poll(aFdPolls, RT_ELEMENTS(aFdPolls), -1 /*infinite timeout*/);244 if ( rc == -1)243 iRc = poll(aFdPolls, RT_ELEMENTS(aFdPolls), -1 /*infinite timeout*/); 244 if (iRc == -1) 245 245 { 246 246 if (errno != EINTR) 247 247 { 248 LogRelMax(32, ("HostDnsServiceLinux::monitorThreadProc: poll failed %d: errno=%d\n", rc, errno));248 LogRelMax(32, ("HostDnsServiceLinux::monitorThreadProc: poll failed %d: errno=%d\n", iRc, errno)); 249 249 RTThreadSleep(1); 250 250 } 251 251 continue; 252 252 } 253 Log5Func(("poll returns %d: [0]=%#x [1]=%#x\n", rc, aFdPolls[1].revents, aFdPolls[0].revents));253 Log5Func(("poll returns %d: [0]=%#x [1]=%#x\n", iRc, aFdPolls[1].revents, aFdPolls[0].revents)); 254 254 255 255 AssertMsgBreakStmt( (aFdPolls[0].revents & (POLLERR | POLLNVAL)) == 0 /* (ok for fd=-1 too, revents=0 then) */ … … 322 322 if (iWdFileNew != -1) 323 323 { 324 rc = inotify_rm_watch(iNotifyFd, iWdFileNew);325 AssertMsg( rc >= 0, ("%d/%d\n", rc, errno));324 iRc = inotify_rm_watch(iNotifyFd, iWdFileNew); 325 AssertMsg(iRc >= 0, ("%d/%d\n", iRc, errno)); 326 326 iWdFileNew = -1; 327 327 } … … 350 350 if (iWdFileNew >= 0) 351 351 { 352 rc = inotify_rm_watch(iNotifyFd, iWdFileNew);353 Log5Func(("dir: moved / created / deleted: dropped file watch (%d - rc=%d/err=%d)\n",354 iWdFileNew, rc, errno));352 iRc = inotify_rm_watch(iNotifyFd, iWdFileNew); 353 Log5Func(("dir: moved / created / deleted: dropped file watch (%d - iRc=%d/err=%d)\n", 354 iWdFileNew, iRc, errno)); 355 355 iWdFileNew = -1; 356 356 } 357 357 if (iWdSymDirNew >= 0) 358 358 { 359 rc = inotify_rm_watch(iNotifyFd, iWdSymDirNew);360 Log5Func(("dir: moved / created / deleted: dropped symlinked dir watch (%d - %s/%s - rc=%d/err=%d)\n",361 iWdSymDirNew, szRealResolvConf, &szRealResolvConf[offRealResolvConfName], rc, errno));359 iRc = inotify_rm_watch(iNotifyFd, iWdSymDirNew); 360 Log5Func(("dir: moved / created / deleted: dropped symlinked dir watch (%d - %s/%s - iRc=%d/err=%d)\n", 361 iWdSymDirNew, szRealResolvConf, &szRealResolvConf[offRealResolvConfName], iRc, errno)); 362 362 iWdSymDirNew = -1; 363 363 offRealResolvConfName = 0; … … 397 397 if (iWdFileNew >= 0) 398 398 { 399 rc = inotify_rm_watch(iNotifyFd, iWdFileNew);400 Log5Func(("symdir: moved / created / deleted: drop file watch (%d - rc=%d/err=%d)\n",401 iWdFileNew, rc, errno));399 iRc = inotify_rm_watch(iNotifyFd, iWdFileNew); 400 Log5Func(("symdir: moved / created / deleted: drop file watch (%d - iRc=%d/err=%d)\n", 401 iWdFileNew, iRc, errno)); 402 402 iWdFileNew = -1; 403 403 } -
trunk/src/VBox/Main/src-server/linux/HostHardwareLinux.cpp
r98103 r98288 148 148 AssertReturn(Number <= 7, false); 149 149 RTFILE File; 150 int rc = RTFileOpen(&File, pcszNode, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE | RTFILE_O_NON_BLOCK);151 if (RT_SUCCESS( rc))150 int vrc = RTFileOpen(&File, pcszNode, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE | RTFILE_O_NON_BLOCK); 151 if (RT_SUCCESS(vrc)) 152 152 { 153 153 int rcIoCtl; 154 rc = RTFileIoCtl(File, FDGETDRVTYP, pszName, 0, &rcIoCtl);154 vrc = RTFileIoCtl(File, FDGETDRVTYP, pszName, 0, &rcIoCtl); 155 155 RTFileClose(File); 156 if (RT_SUCCESS( rc) && rcIoCtl >= 0)156 if (RT_SUCCESS(vrc) && rcIoCtl >= 0) 157 157 return true; 158 158 } … … 310 310 311 311 RTFILE hFile = NIL_RTFILE; 312 int rc = RTFileOpen(&hFile, pcszNode, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE | RTFILE_O_NON_BLOCK);313 if (RT_SUCCESS( rc))312 int vrc = RTFileOpen(&hFile, pcszNode, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE | RTFILE_O_NON_BLOCK); 313 if (RT_SUCCESS(vrc)) 314 314 { 315 315 int rcIoCtl = 0; … … 323 323 CdromCommandReq.data_direction = CGC_DATA_READ; 324 324 CdromCommandReq.timeout = 5000; /* ms */ 325 rc = RTFileIoCtl(hFile, CDROM_SEND_PACKET, &CdromCommandReq, 0, &rcIoCtl);326 if (RT_SUCCESS( rc) && rcIoCtl < 0)327 rc = RTErrConvertFromErrno(-CdromCommandReq.stat);325 vrc = RTFileIoCtl(hFile, CDROM_SEND_PACKET, &CdromCommandReq, 0, &rcIoCtl); 326 if (RT_SUCCESS(vrc) && rcIoCtl < 0) 327 vrc = RTErrConvertFromErrno(-CdromCommandReq.stat); 328 328 RTFileClose(hFile); 329 329 330 if (RT_SUCCESS( rc))330 if (RT_SUCCESS(vrc)) 331 331 { 332 332 if (pbType) … … 347 347 } 348 348 } 349 LogRelFlowFunc(("returning %Rrc\n", rc));350 return rc;349 LogRelFlowFunc(("returning %Rrc\n", vrc)); 350 return vrc; 351 351 } 352 352 … … 432 432 AssertPtrReturn(pcszNode, false); 433 433 RTFILE File; 434 int rc = RTFileOpen(&File, pcszNode, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE | RTFILE_O_NON_BLOCK);435 if (RT_SUCCESS( rc))434 int vrc = RTFileOpen(&File, pcszNode, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE | RTFILE_O_NON_BLOCK); 435 if (RT_SUCCESS(vrc)) 436 436 { 437 437 int rcIoCtl; 438 rc = RTFileIoCtl(File, NVME_IOCTL_ID, NULL, 0, &rcIoCtl);438 vrc = RTFileIoCtl(File, NVME_IOCTL_ID, NULL, 0, &rcIoCtl); 439 439 RTFileClose(File); 440 if (RT_SUCCESS( rc) && rcIoCtl >= 0)440 if (RT_SUCCESS(vrc) && rcIoCtl >= 0) 441 441 return true; 442 442 } … … 520 520 { 521 521 LogFlowThisFunc(("entered\n")); 522 int rc;522 int vrc; 523 523 try 524 524 { … … 527 527 * environment variable. */ 528 528 bool fSuccess = false; /* Have we succeeded in finding anything yet? */ 529 rc = getDriveInfoFromEnv("VBOX_CDROM", &mDVDList, true /* isDVD */, &fSuccess);529 vrc = getDriveInfoFromEnv("VBOX_CDROM", &mDVDList, true /* isDVD */, &fSuccess); 530 530 setNoProbe(false); 531 if (RT_SUCCESS( rc) && (!fSuccess || testing()))532 rc = getDriveInfoFromSysfs(&mDVDList, DVD, &fSuccess);533 if (RT_SUCCESS( rc) && testing())531 if (RT_SUCCESS(vrc) && (!fSuccess || testing())) 532 vrc = getDriveInfoFromSysfs(&mDVDList, DVD, &fSuccess); 533 if (RT_SUCCESS(vrc) && testing()) 534 534 { 535 535 setNoProbe(true); 536 rc = getDriveInfoFromSysfs(&mDVDList, DVD, &fSuccess);536 vrc = getDriveInfoFromSysfs(&mDVDList, DVD, &fSuccess); 537 537 } 538 538 } 539 539 catch (std::bad_alloc &e) 540 540 { 541 rc = VERR_NO_MEMORY;542 } 543 LogFlowThisFunc((" rc=%Rrc\n",rc));544 return rc;541 vrc = VERR_NO_MEMORY; 542 } 543 LogFlowThisFunc(("vrc=%Rrc\n", vrc)); 544 return vrc; 545 545 } 546 546 … … 548 548 { 549 549 LogFlowThisFunc(("entered\n")); 550 int rc;550 int vrc; 551 551 try 552 552 { 553 553 mFloppyList.clear(); 554 554 bool fSuccess = false; /* Have we succeeded in finding anything yet? */ 555 rc = getDriveInfoFromEnv("VBOX_FLOPPY", &mFloppyList, false /* isDVD */, &fSuccess);555 vrc = getDriveInfoFromEnv("VBOX_FLOPPY", &mFloppyList, false /* isDVD */, &fSuccess); 556 556 setNoProbe(false); 557 if (RT_SUCCESS( rc) && (!fSuccess || testing()))558 rc = getDriveInfoFromSysfs(&mFloppyList, Floppy, &fSuccess);559 if (RT_SUCCESS( rc) && testing())557 if (RT_SUCCESS(vrc) && (!fSuccess || testing())) 558 vrc = getDriveInfoFromSysfs(&mFloppyList, Floppy, &fSuccess); 559 if (RT_SUCCESS(vrc) && testing()) 560 560 { 561 561 setNoProbe(true); 562 rc = getDriveInfoFromSysfs(&mFloppyList, Floppy, &fSuccess);562 vrc = getDriveInfoFromSysfs(&mFloppyList, Floppy, &fSuccess); 563 563 } 564 564 } 565 565 catch (std::bad_alloc &) 566 566 { 567 rc = VERR_NO_MEMORY;568 } 569 LogFlowThisFunc((" rc=%Rrc\n",rc));570 return rc;567 vrc = VERR_NO_MEMORY; 568 } 569 LogFlowThisFunc(("vrc=%Rrc\n", vrc)); 570 return vrc; 571 571 } 572 572 … … 617 617 AssertPtrNullReturn(pfSuccess, VERR_INVALID_POINTER); 618 618 LogFlowFunc(("pcszVar=%s, pList=%p, isDVD=%d, pfSuccess=%p\n", pcszVar, pList, isDVD, pfSuccess)); 619 int rc = VINF_SUCCESS;619 int vrc = VINF_SUCCESS; 620 620 bool success = false; 621 621 char *pszFreeMe = RTEnvDupEx(RTENV_DEFAULT, pcszVar); … … 645 645 catch (std::bad_alloc &) 646 646 { 647 rc = VERR_NO_MEMORY;647 vrc = VERR_NO_MEMORY; 648 648 } 649 649 RTStrFree(pszFreeMe); 650 LogFlowFunc((" rc=%Rrc, success=%d\n",rc, success));651 return rc;650 LogFlowFunc(("vrc=%Rrc, success=%d\n", vrc, success)); 651 return vrc; 652 652 } 653 653 … … 696 696 { 697 697 dev_t dev = 0; 698 int rc = RTLinuxSysFsReadDevNumFile(&dev, "block/%s/dev", mpcszName);699 if (RT_FAILURE( rc) || dev == 0)698 int vrc = RTLinuxSysFsReadDevNumFile(&dev, "block/%s/dev", mpcszName); 699 if (RT_FAILURE(vrc) || dev == 0) 700 700 { 701 701 misConsistent = false; 702 702 return false; 703 703 } 704 rc = RTLinuxCheckDevicePath(dev, RTFS_TYPE_DEV_BLOCK, mszNode, sizeof(mszNode), "%s", mpcszName);705 return RT_SUCCESS( rc);704 vrc = RTLinuxCheckDevicePath(dev, RTFS_TYPE_DEV_BLOCK, mszNode, sizeof(mszNode), "%s", mpcszName); 705 return RT_SUCCESS(vrc); 706 706 } 707 707 … … 714 714 { 715 715 int64_t type = 0; 716 int rc = RTLinuxSysFsReadIntFile(10, &type, "block/%s/device/type", mpcszName);717 if (RT_SUCCESS( rc) && type != TYPE_ROM)716 int vrc = RTLinuxSysFsReadIntFile(10, &type, "block/%s/device/type", mpcszName); 717 if (RT_SUCCESS(vrc) && type != TYPE_ROM) 718 718 return; 719 719 if (type == TYPE_ROM) 720 720 { 721 721 char szVendor[128]; 722 rc = RTLinuxSysFsReadStrFile(szVendor, sizeof(szVendor), NULL, "block/%s/device/vendor", mpcszName);723 if (RT_SUCCESS( rc))722 vrc = RTLinuxSysFsReadStrFile(szVendor, sizeof(szVendor), NULL, "block/%s/device/vendor", mpcszName); 723 if (RT_SUCCESS(vrc)) 724 724 { 725 725 char szModel[128]; 726 rc = RTLinuxSysFsReadStrFile(szModel, sizeof(szModel), NULL, "block/%s/device/model", mpcszName);727 if (RT_SUCCESS( rc))726 vrc = RTLinuxSysFsReadStrFile(szModel, sizeof(szModel), NULL, "block/%s/device/model", mpcszName); 727 if (RT_SUCCESS(vrc)) 728 728 { 729 729 misValid = true; … … 747 747 char szVendor[128] = ""; 748 748 char szModel[128] = ""; 749 int rc = cdromDoInquiry(mszNode, &bType, szVendor, sizeof(szVendor), szModel, sizeof(szModel));750 if (RT_SUCCESS( rc) && bType == TYPE_ROM)749 int vrc = cdromDoInquiry(mszNode, &bType, szVendor, sizeof(szVendor), szModel, sizeof(szModel)); 750 if (RT_SUCCESS(vrc) && bType == TYPE_ROM) 751 751 { 752 752 misValid = true; … … 772 772 if (!noProbe()) 773 773 fHaveName = floppyGetName(mszNode, mpcszName[2] - '0', szName); 774 int rc = RTLinuxSysFsGetLinkDest(szDriver, sizeof(szDriver), NULL, "block/%s/%s", 775 mpcszName, "device/driver"); 776 if (RT_SUCCESS(rc)) 774 int vrc = RTLinuxSysFsGetLinkDest(szDriver, sizeof(szDriver), NULL, "block/%s/%s", mpcszName, "device/driver"); 775 if (RT_SUCCESS(vrc)) 777 776 { 778 777 if (RTStrCmp(szDriver, "floppy")) … … 795 794 */ 796 795 int64_t type = 0; 797 int rc = RTLinuxSysFsReadIntFile(10, &type, "block/%s/device/type", mpcszName);798 if (!RT_SUCCESS( rc) || type != TYPE_DISK)796 int vrc = RTLinuxSysFsReadIntFile(10, &type, "block/%s/device/type", mpcszName); 797 if (!RT_SUCCESS(vrc) || type != TYPE_DISK) 799 798 { 800 799 if (noProbe() || !probeNVME(mszNode)) 801 800 { 802 801 char szDriver[16]; 803 rc = RTLinuxSysFsGetLinkDest(szDriver, sizeof(szDriver), NULL, "block/%s/%s", 804 mpcszName, "device/device/driver"); 805 if (RT_FAILURE(rc) || RTStrCmp(szDriver, "nvme")) 806 return; 802 vrc = RTLinuxSysFsGetLinkDest(szDriver, sizeof(szDriver), NULL, "block/%s/%s", mpcszName, "device/device/driver"); 803 if (RT_FAILURE(vrc) || RTStrCmp(szDriver, "nvme")) 804 return; 807 805 } 808 806 } … … 810 808 char szModel[128]; 811 809 size_t cbRead = 0; 812 rc = RTLinuxSysFsReadStrFile(szVendor, sizeof(szVendor), &cbRead, "block/%s/device/vendor", mpcszName);810 vrc = RTLinuxSysFsReadStrFile(szVendor, sizeof(szVendor), &cbRead, "block/%s/device/vendor", mpcszName); 813 811 szVendor[cbRead] = '\0'; 814 812 /* Assume the model is always present. Vendor is not present for NVME disks */ 815 813 cbRead = 0; 816 rc = RTLinuxSysFsReadStrFile(szModel, sizeof(szModel), &cbRead, "block/%s/device/model", mpcszName);814 vrc = RTLinuxSysFsReadStrFile(szModel, sizeof(szModel), &cbRead, "block/%s/device/model", mpcszName); 817 815 szModel[cbRead] = '\0'; 818 if (RT_SUCCESS( rc))816 if (RT_SUCCESS(vrc)) 819 817 { 820 818 misValid = true; … … 870 868 unsigned cFound = 0; 871 869 RTDIR hDir = NIL_RTDIR; 872 int rc = RTDirOpen(&hDir, "/sys/block");870 int vrc = RTDirOpen(&hDir, "/sys/block"); 873 871 /* This might mean that sysfs semantics have changed */ 874 AssertReturn( rc != VERR_FILE_NOT_FOUND, VINF_SUCCESS);875 if (RT_SUCCESS( rc))872 AssertReturn(vrc != VERR_FILE_NOT_FOUND, VINF_SUCCESS); 873 if (RT_SUCCESS(vrc)) 876 874 { 877 875 for (;;) 878 876 { 879 877 RTDIRENTRY entry; 880 rc = RTDirRead(hDir, &entry, NULL);881 Assert( rc != VERR_BUFFER_OVERFLOW); /* Should never happen... */882 if (RT_FAILURE( rc)) /* Including overflow and no more files */878 vrc = RTDirRead(hDir, &entry, NULL); 879 Assert(vrc != VERR_BUFFER_OVERFLOW); /* Should never happen... */ 880 if (RT_FAILURE(vrc)) /* Including overflow and no more files */ 883 881 break; 884 882 if (entry.szName[0] == '.') … … 895 893 catch (std::bad_alloc &e) 896 894 { 897 rc = VERR_NO_MEMORY;895 vrc = VERR_NO_MEMORY; 898 896 break; 899 897 } … … 902 900 RTDirClose(hDir); 903 901 } 904 if ( rc == VERR_NO_MORE_FILES)905 rc = VINF_SUCCESS;906 else if (RT_FAILURE( rc))902 if (vrc == VERR_NO_MORE_FILES) 903 vrc = VINF_SUCCESS; 904 else if (RT_FAILURE(vrc)) 907 905 /* Clean up again */ 908 906 while (cFound-- > 0) … … 910 908 if (pfSuccess) 911 909 *pfSuccess = fSuccess; 912 LogFlow ((" rc=%Rrc, fSuccess=%u\n",rc, (unsigned)fSuccess));913 return rc;910 LogFlow (("vrc=%Rrc, fSuccess=%u\n", vrc, (unsigned)fSuccess)); 911 return vrc; 914 912 } 915 913 … … 1181 1179 # endif 1182 1180 1183 int rc = iwInit(&mWatches);1184 if (RT_SUCCESS( rc))1185 { 1186 rc = iwAddWatch(&mWatches, mpcszDevicesRoot);1187 if (RT_SUCCESS( rc))1188 rc = pipeCreateSimple(&mhWakeupPipeR, &mhWakeupPipeW);1189 } 1190 mStatus = rc;1191 if (RT_FAILURE( rc))1181 int vrc = iwInit(&mWatches); 1182 if (RT_SUCCESS(vrc)) 1183 { 1184 vrc = iwAddWatch(&mWatches, mpcszDevicesRoot); 1185 if (RT_SUCCESS(vrc)) 1186 vrc = pipeCreateSimple(&mhWakeupPipeR, &mhWakeupPipeW); 1187 } 1188 mStatus = vrc; 1189 if (RT_FAILURE(vrc)) 1192 1190 term(); 1193 1191 } … … 1247 1245 int hotplugInotifyImpl::Wait(RTMSINTERVAL aMillies) 1248 1246 { 1249 int rc;1250 1251 1247 AssertRCReturn(mStatus, VERR_WRONG_ORDER); 1252 1248 bool fEntered = ASMAtomicCmpXchgU32(&mfWaiting, 1, 0); … … 1255 1251 VECTOR_PTR(char *) vecpchDevs; 1256 1252 VEC_INIT_PTR(&vecpchDevs, char *, RTStrFree); 1257 rc = readFilePaths(mpcszDevicesRoot, &vecpchDevs, false);1258 if (RT_SUCCESS( rc))1253 int vrc = readFilePaths(mpcszDevicesRoot, &vecpchDevs, false); 1254 if (RT_SUCCESS(vrc)) 1259 1255 { 1260 1256 char **ppszEntry; 1261 1257 VEC_FOR_EACH(&vecpchDevs, char *, ppszEntry) 1262 if (RT_FAILURE( rc = iwAddWatch(&mWatches, *ppszEntry)))1258 if (RT_FAILURE(vrc = iwAddWatch(&mWatches, *ppszEntry))) 1263 1259 break; 1264 1260 1265 if (RT_SUCCESS( rc))1261 if (RT_SUCCESS(vrc)) 1266 1262 { 1267 1263 struct pollfd pollFD[MAX_POLLID]; … … 1275 1271 { 1276 1272 Assert(errno > 0); 1277 rc = RTErrConvertFromErrno(errno);1273 vrc = RTErrConvertFromErrno(errno); 1278 1274 } 1279 1275 else if (pollFD[RPIPE_ID].revents) 1280 1276 { 1281 rc = drainWakeupPipe();1282 if (RT_SUCCESS( rc))1283 rc = VERR_INTERRUPTED;1277 vrc = drainWakeupPipe(); 1278 if (RT_SUCCESS(vrc)) 1279 vrc = VERR_INTERRUPTED; 1284 1280 } 1285 1281 else if ((pollFD[INOTIFY_ID].revents)) 1286 1282 { 1287 1283 if (cPolled == 1) 1288 rc = drainInotify();1284 vrc = drainInotify(); 1289 1285 else 1290 AssertFailedStmt( rc = VERR_INTERNAL_ERROR);1286 AssertFailedStmt(vrc = VERR_INTERNAL_ERROR); 1291 1287 } 1292 1288 else 1293 1289 { 1294 1290 if (errno == 0 && cPolled == 0) 1295 rc = VERR_TIMEOUT;1291 vrc = VERR_TIMEOUT; 1296 1292 else 1297 AssertFailedStmt( rc = VERR_INTERNAL_ERROR);1293 AssertFailedStmt(vrc = VERR_INTERNAL_ERROR); 1298 1294 } 1299 1295 } … … 1302 1298 mfWaiting = 0; 1303 1299 VEC_CLEANUP_PTR(&vecpchDevs); 1304 return rc;1300 return vrc; 1305 1301 } 1306 1302 -
trunk/src/VBox/Main/src-server/linux/HostPowerLinux.cpp
r98103 r98288 59 59 { 60 60 DBusError error; 61 int rc;62 61 63 rc = RTDBusLoadLib();64 if (RT_FAILURE( rc))62 int vrc = RTDBusLoadLib(); 63 if (RT_FAILURE(vrc)) 65 64 { 66 65 LogRel(("HostPowerServiceLinux: DBus library not found. Service not available.\n")); … … 92 91 93 92 /* Create the new worker thread. */ 94 rc = RTThreadCreate(&mThread, HostPowerServiceLinux::powerChangeNotificationThread, this, 0 /* cbStack */,95 RTTHREADTYPE_MSG_PUMP, RTTHREADFLAGS_WAITABLE, "MainPower");96 if (RT_FAILURE( rc))93 vrc = RTThreadCreate(&mThread, HostPowerServiceLinux::powerChangeNotificationThread, this, 0 /* cbStack */, 94 RTTHREADTYPE_MSG_PUMP, RTTHREADFLAGS_WAITABLE, "MainPower"); 95 if (RT_FAILURE(vrc)) 97 96 { 98 LogRel(("HostPowerServiceLinux: RTThreadCreate failed with %Rrc\n", rc));97 LogRel(("HostPowerServiceLinux: RTThreadCreate failed with %Rrc\n", vrc)); 99 98 dbus_connection_unref(mpConnection); 100 99 } -
trunk/src/VBox/Main/src-server/linux/NetIf-linux.cpp
r98103 r98288 126 126 { 127 127 /* Failed to get speed via sysfs, go to plan B. */ 128 int rc = NetIfAdpCtlOut(pszName, "speed", szBuf, sizeof(szBuf));129 if (RT_SUCCESS( rc))128 int vrc = NetIfAdpCtlOut(pszName, "speed", szBuf, sizeof(szBuf)); 129 if (RT_SUCCESS(vrc)) 130 130 uSpeed = RTStrToUInt32(szBuf); 131 131 } … … 230 230 { 231 231 char szDefaultIface[256]; 232 int rc = getDefaultIfaceName(szDefaultIface, sizeof(szDefaultIface));233 if (RT_FAILURE( rc))232 int vrc = getDefaultIfaceName(szDefaultIface, sizeof(szDefaultIface)); 233 if (RT_FAILURE(vrc)) 234 234 { 235 235 Log(("NetIfList: Failed to find default interface.\n")); … … 253 253 NETIFINFO Info; 254 254 RT_ZERO(Info); 255 rc = getInterfaceInfo(sock, pszName, &Info);256 if (RT_FAILURE( rc))255 vrc = getInterfaceInfo(sock, pszName, &Info); 256 if (RT_FAILURE(vrc)) 257 257 break; 258 258 if (Info.enmMediumType == NETIF_T_ETHERNET) … … 282 282 } 283 283 else 284 rc = VERR_INTERNAL_ERROR;285 286 return rc;284 vrc = VERR_INTERNAL_ERROR; 285 286 return vrc; 287 287 } 288 288 289 289 int NetIfGetConfigByName(PNETIFINFO pInfo) 290 290 { 291 int rc = VINF_SUCCESS;292 291 int sock = socket(AF_INET, SOCK_DGRAM, 0); 293 292 if (sock < 0) 294 293 return VERR_NOT_IMPLEMENTED; 295 rc = getInterfaceInfo(sock, pInfo->szShortName, pInfo);294 int vrc = getInterfaceInfo(sock, pInfo->szShortName, pInfo); 296 295 close(sock); 297 return rc;296 return vrc; 298 297 } 299 298 -
trunk/src/VBox/Main/src-server/linux/PerformanceLinux.cpp
r98103 r98288 114 114 115 115 uint64_t cb; 116 int rc = RTSystemQueryTotalRam(&cb);117 if (RT_FAILURE( rc))116 int vrc = RTSystemQueryTotalRam(&cb); 117 if (RT_FAILURE(vrc)) 118 118 mTotalRAM = 0; 119 119 else … … 130 130 { 131 131 VMProcessStats vmStats; 132 int rc = getRawProcessStats(*it, &vmStats.cpuUser, &vmStats.cpuKernel, &vmStats.pagesUsed);132 int vrc = getRawProcessStats(*it, &vmStats.cpuUser, &vmStats.cpuKernel, &vmStats.pagesUsed); 133 133 /* On failure, do NOT stop. Just skip the entry. Having the stats for 134 134 * one (probably broken) process frozen/zero is a minor issue compared 135 135 * to not updating many process stats and the host cpu stats. */ 136 if (RT_SUCCESS( rc))136 if (RT_SUCCESS(vrc)) 137 137 mProcessStats[*it] = vmStats; 138 138 } … … 146 146 int CollectorLinux::_getRawHostCpuLoad() 147 147 { 148 int rc = VINF_SUCCESS;148 int vrc = VINF_SUCCESS; 149 149 long long unsigned uUser, uNice, uKernel, uIdle, uIowait, uIrq, uSoftirq; 150 150 FILE *f = fopen("/proc/stat", "r"); … … 184 184 } 185 185 else 186 rc = VERR_FILE_IO_ERROR;186 vrc = VERR_FILE_IO_ERROR; 187 187 } 188 188 else 189 rc = VERR_FILE_IO_ERROR;189 vrc = VERR_FILE_IO_ERROR; 190 190 fclose(f); 191 191 } 192 192 else 193 rc = VERR_ACCESS_DENIED;194 195 return rc;193 vrc = VERR_ACCESS_DENIED; 194 195 return vrc; 196 196 } 197 197 … … 223 223 AssertReturn(mTotalRAM, VERR_INTERNAL_ERROR); 224 224 uint64_t cb; 225 int rc = RTSystemQueryAvailableRam(&cb);226 if (RT_SUCCESS( rc))225 int vrc = RTSystemQueryAvailableRam(&cb); 226 if (RT_SUCCESS(vrc)) 227 227 { 228 228 *total = mTotalRAM; … … 230 230 *used = *total - *available; 231 231 } 232 return rc;232 return vrc; 233 233 } 234 234 … … 257 257 Assert(pszPath); 258 258 259 int rc = VINF_SUCCESS;259 int vrc = VINF_SUCCESS; 260 260 if (!RTLinuxSysFsExists(pszPath)) 261 rc = VERR_FILE_NOT_FOUND;261 vrc = VERR_FILE_NOT_FOUND; 262 262 else 263 263 { 264 264 int64_t cSize = 0; 265 rc = RTLinuxSysFsReadIntFile(0, &cSize, pszPath);266 if (RT_SUCCESS( rc))265 vrc = RTLinuxSysFsReadIntFile(0, &cSize, pszPath); 266 if (RT_SUCCESS(vrc)) 267 267 *size = cSize * 512; 268 268 } 269 269 RTStrFree(pszPath); 270 return rc;270 return vrc; 271 271 } 272 272 … … 286 286 int CollectorLinux::getRawProcessStats(RTPROCESS process, uint64_t *cpuUser, uint64_t *cpuKernel, ULONG *memPagesUsed) 287 287 { 288 int rc = VINF_SUCCESS;288 int vrc = VINF_SUCCESS; 289 289 char *pszName; 290 290 pid_t pid2; … … 316 316 } 317 317 else 318 rc = VERR_FILE_IO_ERROR;318 vrc = VERR_FILE_IO_ERROR; 319 319 fclose(f); 320 320 } 321 321 else 322 rc = VERR_ACCESS_DENIED;323 324 return rc;322 vrc = VERR_ACCESS_DENIED; 323 324 return vrc; 325 325 } 326 326 … … 334 334 335 335 int64_t cSize = 0; 336 int rc = RTLinuxSysFsReadIntFile(0, &cSize, szIfName);337 if (RT_FAILURE( rc))338 return rc;336 int vrc = RTLinuxSysFsReadIntFile(0, &cSize, szIfName); 337 if (RT_FAILURE(vrc)) 338 return vrc; 339 339 340 340 *rx = cSize; … … 344 344 return VERR_FILE_NOT_FOUND; 345 345 346 rc = RTLinuxSysFsReadIntFile(0, &cSize, szIfName);347 if (RT_FAILURE( rc))348 return rc;346 vrc = RTLinuxSysFsReadIntFile(0, &cSize, szIfName); 347 if (RT_FAILURE(vrc)) 348 return vrc; 349 349 350 350 *tx = cSize; … … 355 355 { 356 356 #if 0 357 int rc = VINF_SUCCESS;357 int vrc = VINF_SUCCESS; 358 358 char szIfName[/*IFNAMSIZ*/ 16 + 36]; 359 359 long long unsigned int u64Busy, tmp; … … 370 370 } 371 371 else 372 rc = VERR_FILE_IO_ERROR;372 vrc = VERR_FILE_IO_ERROR; 373 373 fclose(f); 374 374 } 375 375 else 376 rc = VERR_ACCESS_DENIED;376 vrc = VERR_ACCESS_DENIED; 377 377 #else 378 int rc = VERR_MISSING;378 int vrc = VERR_MISSING; 379 379 FILE *f = fopen("/proc/diskstats", "r"); 380 380 if (f) … … 406 406 *disk_ms = u64Busy; 407 407 *total_ms = (uint64_t)(mSingleUser + mSingleKernel + mSingleIdle) * 1000 / mHZ; 408 rc = VINF_SUCCESS;408 vrc = VINF_SUCCESS; 409 409 } 410 410 else 411 rc = VERR_FILE_IO_ERROR;411 vrc = VERR_FILE_IO_ERROR; 412 412 break; 413 413 } … … 417 417 #endif 418 418 419 return rc;419 return vrc; 420 420 } 421 421 … … 525 525 { 526 526 char szVolInfo[RTPATH_MAX]; 527 int rc = RTPathAppPrivateArch(szVolInfo, 528 sizeof(szVolInfo) - sizeof("/" VBOXVOLINFO_NAME " ") - strlen(pcszVolume)); 529 if (RT_FAILURE(rc)) 530 { 531 LogRel(("VolInfo: Failed to get program path, rc=%Rrc\n", rc)); 527 int vrc = RTPathAppPrivateArch(szVolInfo, sizeof(szVolInfo) - sizeof("/" VBOXVOLINFO_NAME " ") - strlen(pcszVolume)); 528 if (RT_FAILURE(vrc)) 529 { 530 LogRel(("VolInfo: Failed to get program path, vrc=%Rrc\n", vrc)); 532 531 return; 533 532 } … … 568 567 char szFsName[1024]; 569 568 /* Try to resolve symbolic link if necessary. Yes, we access the file system here! */ 570 int rc = RTPathReal(mntent->mnt_fsname, szFsName, sizeof(szFsName));571 if (RT_FAILURE( rc))569 int vrc = RTPathReal(mntent->mnt_fsname, szFsName, sizeof(szFsName)); 570 if (RT_FAILURE(vrc)) 572 571 continue; /* something got wrong, just ignore this path */ 573 572 /* check against the actual mtab entry, NOT the real path as /dev/mapper/xyz is -
trunk/src/VBox/Main/src-server/linux/USBGetDevices.cpp
r98103 r98288 293 293 } 294 294 295 int rc = usbfsReadSkipSuffix(&pszNext);296 if (RT_FAILURE( rc))297 return rc;295 int vrc = usbfsReadSkipSuffix(&pszNext); 296 if (RT_FAILURE(vrc)) 297 return vrc; 298 298 299 299 *ppszNext = pszNext; … … 379 379 * Validate and skip stuff following the number. 380 380 */ 381 int rc = usbfsReadSkipSuffix(&pszNext);382 if (RT_FAILURE( rc))383 return rc;381 int vrc = usbfsReadSkipSuffix(&pszNext); 382 if (RT_FAILURE(vrc)) 383 return vrc; 384 384 *ppszNext = pszNext; 385 385 … … 471 471 /** Just a worker for USBProxyServiceLinux::getDevices that avoids some code duplication. */ 472 472 static int usbfsAddDeviceToChain(PUSBDEVICE pDev, PUSBDEVICE *ppFirst, PUSBDEVICE **pppNext, const char *pszUsbfsRoot, 473 bool fUnsupportedDevicesToo, int rc)473 bool fUnsupportedDevicesToo, int vrc) 474 474 { 475 475 /* usbDeterminState requires the address. */ … … 495 495 { 496 496 deviceFree(pDevNew); 497 rc = VERR_NO_MEMORY;497 vrc = VERR_NO_MEMORY; 498 498 } 499 499 } 500 500 else 501 501 { 502 rc = VERR_NO_MEMORY;502 vrc = VERR_NO_MEMORY; 503 503 deviceFreeMembers(pDev); 504 504 } 505 505 506 return rc;506 return vrc; 507 507 } 508 508 … … 535 535 PUSBDEVICE pFirst = NULL; 536 536 FILE *pFile = NULL; 537 int rc; 538 rc = usbfsOpenDevicesFile(pszUsbfsRoot, &pFile); 539 if (RT_SUCCESS(rc)) 537 int vrc = usbfsOpenDevicesFile(pszUsbfsRoot, &pFile); 538 if (RT_SUCCESS(vrc)) 540 539 { 541 540 PUSBDEVICE *ppNext = NULL; … … 547 546 548 547 /* Set close on exit and hope no one is racing us. */ 549 rc = fcntl(fileno(pFile), F_SETFD, FD_CLOEXEC) >= 0550 ? VINF_SUCCESS551 : RTErrConvertFromErrno(errno);552 while ( RT_SUCCESS(rc)553 && 548 vrc = fcntl(fileno(pFile), F_SETFD, FD_CLOEXEC) >= 0 549 ? VINF_SUCCESS 550 : RTErrConvertFromErrno(errno); 551 while ( RT_SUCCESS(vrc) 552 && fgets(szLine, sizeof(szLine), pFile)) 554 553 { 555 554 char *psz; … … 596 595 AssertMsg(cHits >= 3 || cHits == 0, ("cHits=%d\n", cHits)); 597 596 if (cHits >= 3) 598 rc = usbfsAddDeviceToChain(&Dev, &pFirst, &ppNext, pszUsbfsRoot, fUnsupportedDevicesToo,rc);597 vrc = usbfsAddDeviceToChain(&Dev, &pFirst, &ppNext, pszUsbfsRoot, fUnsupportedDevicesToo, vrc); 599 598 else 600 599 deviceFreeMembers(&Dev); … … 606 605 607 606 /* parse the line. */ 608 while (*psz && RT_SUCCESS( rc))607 while (*psz && RT_SUCCESS(vrc)) 609 608 { 610 609 if (PREFIX("Bus=")) 611 rc = usbfsRead8(pszValue, 10, &Dev.bBus, &psz);610 vrc = usbfsRead8(pszValue, 10, &Dev.bBus, &psz); 612 611 else if (PREFIX("Port=")) 613 rc = usbfsRead8(pszValue, 10, &Dev.bPort, &psz);612 vrc = usbfsRead8(pszValue, 10, &Dev.bPort, &psz); 614 613 else if (PREFIX("Spd=")) 615 rc = usbfsReadSpeed(pszValue, &Dev.enmSpeed, &psz);614 vrc = usbfsReadSpeed(pszValue, &Dev.enmSpeed, &psz); 616 615 else if (PREFIX("Dev#=")) 617 rc = usbfsRead8(pszValue, 10, &Dev.bDevNum, &psz);616 vrc = usbfsRead8(pszValue, 10, &Dev.bDevNum, &psz); 618 617 else 619 618 psz = usbfsReadSkip(psz); … … 644 643 */ 645 644 case 'D': 646 while (*psz && RT_SUCCESS( rc))645 while (*psz && RT_SUCCESS(vrc)) 647 646 { 648 647 if (PREFIX("Ver=")) 649 rc = usbfsReadBCD(pszValue, 16, &Dev.bcdUSB, &psz);648 vrc = usbfsReadBCD(pszValue, 16, &Dev.bcdUSB, &psz); 650 649 else if (PREFIX("Cls=")) 651 650 { 652 rc = usbfsRead8(pszValue, 16, &Dev.bDeviceClass, &psz);653 if (RT_SUCCESS( rc) && Dev.bDeviceClass == 9 /* HUB */)651 vrc = usbfsRead8(pszValue, 16, &Dev.bDeviceClass, &psz); 652 if (RT_SUCCESS(vrc) && Dev.bDeviceClass == 9 /* HUB */) 654 653 Dev.enmState = USBDEVICESTATE_UNSUPPORTED; 655 654 } 656 655 else if (PREFIX("Sub=")) 657 rc = usbfsRead8(pszValue, 16, &Dev.bDeviceSubClass, &psz);656 vrc = usbfsRead8(pszValue, 16, &Dev.bDeviceSubClass, &psz); 658 657 else if (PREFIX("Prot=")) 659 rc = usbfsRead8(pszValue, 16, &Dev.bDeviceProtocol, &psz);658 vrc = usbfsRead8(pszValue, 16, &Dev.bDeviceProtocol, &psz); 660 659 //else if (PREFIX("MxPS=")) 661 // rc = usbRead16(pszValue, 10, &Dev.wMaxPacketSize, &psz);660 // vrc = usbRead16(pszValue, 10, &Dev.wMaxPacketSize, &psz); 662 661 else if (PREFIX("#Cfgs=")) 663 rc = usbfsRead8(pszValue, 10, &Dev.bNumConfigurations, &psz);662 vrc = usbfsRead8(pszValue, 10, &Dev.bNumConfigurations, &psz); 664 663 else 665 664 psz = usbfsReadSkip(psz); … … 677 676 */ 678 677 case 'P': 679 while (*psz && RT_SUCCESS( rc))678 while (*psz && RT_SUCCESS(vrc)) 680 679 { 681 680 if (PREFIX("Vendor=")) 682 rc = usbfsRead16(pszValue, 16, &Dev.idVendor, &psz);681 vrc = usbfsRead16(pszValue, 16, &Dev.idVendor, &psz); 683 682 else if (PREFIX("ProdID=")) 684 rc = usbfsRead16(pszValue, 16, &Dev.idProduct, &psz);683 vrc = usbfsRead16(pszValue, 16, &Dev.idProduct, &psz); 685 684 else if (PREFIX("Rev=")) 686 rc = usbfsReadBCD(pszValue, 16, &Dev.bcdDevice, &psz);685 vrc = usbfsReadBCD(pszValue, 16, &Dev.bcdDevice, &psz); 687 686 else 688 687 psz = usbfsReadSkip(psz); … … 697 696 case 'S': 698 697 if (PREFIX("Manufacturer=")) 699 rc = usbfsReadStr(pszValue, &Dev.pszManufacturer);698 vrc = usbfsReadStr(pszValue, &Dev.pszManufacturer); 700 699 else if (PREFIX("Product=")) 701 rc = usbfsReadStr(pszValue, &Dev.pszProduct);700 vrc = usbfsReadStr(pszValue, &Dev.pszProduct); 702 701 else if (PREFIX("SerialNumber=")) 703 702 { 704 rc = usbfsReadStr(pszValue, &Dev.pszSerialNumber);705 if (RT_SUCCESS( rc))703 vrc = usbfsReadStr(pszValue, &Dev.pszSerialNumber); 704 if (RT_SUCCESS(vrc)) 706 705 Dev.u64SerialHash = USBLibHashSerial(pszValue); 707 706 } … … 735 734 { 736 735 /* Check for thing we don't support. */ 737 while (*psz && RT_SUCCESS( rc))736 while (*psz && RT_SUCCESS(vrc)) 738 737 { 739 738 if (PREFIX("Driver=")) 740 739 { 741 740 const char *pszDriver = NULL; 742 rc = usbfsReadStr(pszValue, &pszDriver);741 vrc = usbfsReadStr(pszValue, &pszDriver); 743 742 if ( !pszDriver 744 743 || !*pszDriver … … 756 755 { 757 756 uint8_t bInterfaceClass; 758 rc = usbfsRead8(pszValue, 16, &bInterfaceClass, &psz);759 if (RT_SUCCESS( rc) && bInterfaceClass == 9 /* HUB */)757 vrc = usbfsRead8(pszValue, 16, &bInterfaceClass, &psz); 758 if (RT_SUCCESS(vrc) && bInterfaceClass == 9 /* HUB */) 760 759 Dev.enmState = USBDEVICESTATE_UNSUPPORTED; 761 760 } … … 789 788 AssertMsg(cHits >= 3 || cHits == 0, ("cHits=%d\n", cHits)); 790 789 if (cHits >= 3) 791 rc = usbfsAddDeviceToChain(&Dev, &pFirst, &ppNext, pszUsbfsRoot, fUnsupportedDevicesToo,rc);790 vrc = usbfsAddDeviceToChain(&Dev, &pFirst, &ppNext, pszUsbfsRoot, fUnsupportedDevicesToo, vrc); 792 791 793 792 /* 794 793 * Success? 795 794 */ 796 if (RT_FAILURE( rc))795 if (RT_FAILURE(vrc)) 797 796 { 798 797 while (pFirst) … … 804 803 } 805 804 } 806 if (RT_FAILURE( rc))807 LogFlow(("USBProxyServiceLinux::getDevices: rc=%Rrc\n",rc));805 if (RT_FAILURE(vrc)) 806 LogFlow(("USBProxyServiceLinux::getDevices: vrc=%Rrc\n", vrc)); 808 807 return pFirst; 809 808 } … … 892 891 893 892 int64_t device; 894 int rc = RTLinuxSysFsReadIntFile(10, &device, "%s/devnum", pszNode);895 if (RT_FAILURE( rc))893 int vrc = RTLinuxSysFsReadIntFile(10, &device, "%s/devnum", pszNode); 894 if (RT_FAILURE(vrc)) 896 895 return VINF_SUCCESS; 897 896 … … 901 900 902 901 char szDevPath[RTPATH_MAX]; 903 rc = RTLinuxCheckDevicePath(devnum, RTFS_TYPE_DEV_CHAR, 904 szDevPath, sizeof(szDevPath), 905 "%s/%.3d/%.3d", 906 pszDevicesRoot, bus, device); 907 if (RT_FAILURE(rc)) 902 vrc = RTLinuxCheckDevicePath(devnum, RTFS_TYPE_DEV_CHAR, szDevPath, sizeof(szDevPath), 903 "%s/%.3d/%.3d", pszDevicesRoot, bus, device); 904 if (RT_FAILURE(vrc)) 908 905 return VINF_SUCCESS; 909 906 … … 911 908 if (usbsysfsInitDevInfo(&info, szDevPath, pszNode)) 912 909 { 913 rc = VEC_PUSH_BACK_OBJ(pvecDevInfo, USBDeviceInfo, &info);914 if (RT_SUCCESS( rc))910 vrc = VEC_PUSH_BACK_OBJ(pvecDevInfo, USBDeviceInfo, &info); 911 if (RT_SUCCESS(vrc)) 915 912 return VINF_SUCCESS; 916 913 } … … 991 988 if (pszDup) 992 989 { 993 int rc = VEC_PUSH_BACK_PTR(&pInfo->mvecpszInterfaces, char *, pszDup);994 if (RT_SUCCESS( rc))990 int vrc = VEC_PUSH_BACK_PTR(&pInfo->mvecpszInterfaces, char *, pszDup); 991 if (RT_SUCCESS(vrc)) 995 992 return VINF_SUCCESS; 996 993 RTStrFree(pszDup); … … 1010 1007 { 1011 1008 struct dirent entry, *pResult; 1012 int err , rc;1009 int err; 1013 1010 1014 1011 #if RT_GNUC_PREREQ(4, 6) … … 1033 1030 if (!pszPathCopy) 1034 1031 return VERR_NO_MEMORY; 1035 if (RT_FAILURE(rc = VEC_PUSH_BACK_PTR(pvecpchDevs, char *, pszPathCopy))) 1036 return rc; 1032 int vrc = VEC_PUSH_BACK_PTR(pvecpchDevs, char *, pszPathCopy); 1033 if (RT_FAILURE(vrc)) 1034 return vrc; 1037 1035 } 1038 1036 return RTErrConvertFromErrno(err); … … 1058 1056 if (!pDir) 1059 1057 return RTErrConvertFromErrno(errno); 1060 int rc = usbsysfsReadFilePathsFromDir(pszPath, pDir, pvecpchDevs);1061 if (closedir(pDir) < 0 && RT_SUCCESS( rc))1062 rc = RTErrConvertFromErrno(errno);1063 return rc;1058 int vrc = usbsysfsReadFilePathsFromDir(pszPath, pDir, pvecpchDevs); 1059 if (closedir(pDir) < 0 && RT_SUCCESS(vrc)) 1060 vrc = RTErrConvertFromErrno(errno); 1061 return vrc; 1064 1062 } 1065 1063 … … 1081 1079 LogFlowFunc (("pvecDevInfo=%p\n", pvecDevInfo)); 1082 1080 1083 int rc = usbsysfsReadFilePaths("/sys/bus/usb/devices", pvecpchDevs);1084 if (RT_FAILURE( rc))1085 return rc;1081 int vrc = usbsysfsReadFilePaths("/sys/bus/usb/devices", pvecpchDevs); 1082 if (RT_FAILURE(vrc)) 1083 return vrc; 1086 1084 1087 1085 char **ppszEntry; 1088 1086 VEC_FOR_EACH(pvecpchDevs, char *, ppszEntry) 1089 1087 { 1090 rc = usbsysfsAddIfDevice(pszDevicesRoot, *ppszEntry, pvecDevInfo);1091 if (RT_FAILURE( rc))1092 return rc;1088 vrc = usbsysfsAddIfDevice(pszDevicesRoot, *ppszEntry, pvecDevInfo); 1089 if (RT_FAILURE(vrc)) 1090 return vrc; 1093 1091 } 1094 1092 … … 1097 1095 VEC_FOR_EACH(pvecpchDevs, char *, ppszEntry) 1098 1096 { 1099 rc = usbsysfsAddIfInterfaceOf(*ppszEntry, pInfo);1100 if (RT_FAILURE( rc))1101 return rc;1097 vrc = usbsysfsAddIfInterfaceOf(*ppszEntry, pInfo); 1098 if (RT_FAILURE(vrc)) 1099 return vrc; 1102 1100 } 1103 1101 return VINF_SUCCESS; … … 1112 1110 LogFlowFunc(("entered\n")); 1113 1111 VEC_INIT_PTR(&vecpchDevs, char *, RTStrFree); 1114 int rc = usbsysfsEnumerateHostDevicesWorker(pszDevicesRoot, pvecDevInfo, &vecpchDevs);1112 int vrc = usbsysfsEnumerateHostDevicesWorker(pszDevicesRoot, pvecDevInfo, &vecpchDevs); 1115 1113 VEC_CLEANUP_PTR(&vecpchDevs); 1116 LogFlowFunc((" rc=%Rrc\n",rc));1117 return rc;1114 LogFlowFunc(("vrc=%Rrc\n", vrc)); 1115 return vrc; 1118 1116 } 1119 1117 … … 1185 1183 ? pchDot + 1 1186 1184 : pchDash + 1; 1187 int rc = RTStrToUInt8Full(pszLastPort, 10, pu8Port);1188 if ( rc != VINF_SUCCESS)1189 { 1190 Log(("usbGetPortFromSysfsPath(%s): failed [3], rc=%Rrc\n", pszPath,rc));1185 int vrc = RTStrToUInt8Full(pszLastPort, 10, pu8Port); 1186 if (vrc != VINF_SUCCESS) 1187 { 1188 Log(("usbGetPortFromSysfsPath(%s): failed [3], vrc=%Rrc\n", pszPath, vrc)); 1191 1189 return VERR_INVALID_PARAMETER; 1192 1190 } … … 1219 1217 1220 1218 pszBuf = RTStrStripL(pszBuf); 1221 int rc = RTStrToInt32Ex(pszBuf, &pszNext, 16, &i32);1222 if ( RT_FAILURE( rc)1223 || rc == VWRN_NUMBER_TOO_BIG1219 int vrc = RTStrToInt32Ex(pszBuf, &pszNext, 16, &i32); 1220 if ( RT_FAILURE(vrc) 1221 || vrc == VWRN_NUMBER_TOO_BIG 1224 1222 || i32 < 0) 1225 1223 return VERR_NUMBER_TOO_BIG; … … 1229 1227 return VERR_NUMBER_TOO_BIG; 1230 1228 int32_t i32Lo; 1231 rc = RTStrToInt32Ex(pszNext+1, &pszNext, 16, &i32Lo);1232 if ( RT_FAILURE( rc)1233 || rc == VWRN_NUMBER_TOO_BIG1229 vrc = RTStrToInt32Ex(pszNext+1, &pszNext, 16, &i32Lo); 1230 if ( RT_FAILURE(vrc) 1231 || vrc == VWRN_NUMBER_TOO_BIG 1234 1232 || i32Lo > 255 1235 1233 || i32Lo < 0) … … 1252 1250 * @returns uint8_t value of the given property. 1253 1251 * @param uBase The base of the number in the sysfs property. 1254 * @param bDef The default to set on error.1252 * @param fDef The default to set on error. 1255 1253 * @param pszFormat The format string for the property. 1256 1254 * @param ... Arguments for the format string. 1257 1255 */ 1258 static uint8_t usbsysfsReadDevicePropertyU8Def(unsigned uBase, uint8_t bDef, const char *pszFormat, ...)1256 static uint8_t usbsysfsReadDevicePropertyU8Def(unsigned uBase, uint8_t fDef, const char *pszFormat, ...) 1259 1257 { 1260 1258 int64_t i64Tmp = 0; … … 1262 1260 va_list va; 1263 1261 va_start(va, pszFormat); 1264 int rc = RTLinuxSysFsReadIntFileV(uBase, &i64Tmp, pszFormat, va);1262 int vrc = RTLinuxSysFsReadIntFileV(uBase, &i64Tmp, pszFormat, va); 1265 1263 va_end(va); 1266 if (RT_SUCCESS( rc))1264 if (RT_SUCCESS(vrc)) 1267 1265 return (uint8_t)i64Tmp; 1268 else 1269 return bDef; 1266 return fDef; 1270 1267 } 1271 1268 … … 1287 1284 va_list va; 1288 1285 va_start(va, pszFormat); 1289 int rc = RTLinuxSysFsReadIntFileV(uBase, &i64Tmp, pszFormat, va);1286 int vrc = RTLinuxSysFsReadIntFileV(uBase, &i64Tmp, pszFormat, va); 1290 1287 va_end(va); 1291 if (RT_SUCCESS( rc))1288 if (RT_SUCCESS(vrc)) 1292 1289 return (uint16_t)i64Tmp; 1293 else 1294 return u16Def; 1290 return u16Def; 1295 1291 } 1296 1292 … … 1298 1294 static void usbsysfsFillInDevice(USBDEVICE *pDev, USBDeviceInfo *pInfo) 1299 1295 { 1300 int rc;1296 int vrc; 1301 1297 const char *pszSysfsPath = pInfo->mSysfsPath; 1302 1298 … … 1319 1315 1320 1316 /* For simplicity, we just do strcmps on the next one. */ 1321 rc = RTLinuxSysFsReadStrFile(szBuf, sizeof(szBuf), &cchRead, "%s/speed", pszSysfsPath);1322 if (RT_FAILURE( rc) || cchRead == sizeof(szBuf))1317 vrc = RTLinuxSysFsReadStrFile(szBuf, sizeof(szBuf), &cchRead, "%s/speed", pszSysfsPath); 1318 if (RT_FAILURE(vrc) || cchRead == sizeof(szBuf)) 1323 1319 pDev->enmState = USBDEVICESTATE_UNSUPPORTED; 1324 1320 else … … 1329 1325 : USBDEVICESPEED_UNKNOWN; 1330 1326 1331 rc = RTLinuxSysFsReadStrFile(szBuf, sizeof(szBuf), &cchRead, "%s/version", pszSysfsPath);1332 if (RT_FAILURE( rc) || cchRead == sizeof(szBuf))1327 vrc = RTLinuxSysFsReadStrFile(szBuf, sizeof(szBuf), &cchRead, "%s/version", pszSysfsPath); 1328 if (RT_FAILURE(vrc) || cchRead == sizeof(szBuf)) 1333 1329 pDev->enmState = USBDEVICESTATE_UNSUPPORTED; 1334 1330 else 1335 1331 { 1336 rc = usbsysfsConvertStrToBCD(szBuf, &pDev->bcdUSB);1337 if (RT_FAILURE( rc))1332 vrc = usbsysfsConvertStrToBCD(szBuf, &pDev->bcdUSB); 1333 if (RT_FAILURE(vrc)) 1338 1334 { 1339 1335 pDev->enmState = USBDEVICESTATE_UNSUPPORTED; … … 1342 1338 } 1343 1339 1344 rc = RTLinuxSysFsReadStrFile(szBuf, sizeof(szBuf), &cchRead, "%s/bcdDevice", pszSysfsPath);1345 if (RT_FAILURE( rc) || cchRead == sizeof(szBuf))1340 vrc = RTLinuxSysFsReadStrFile(szBuf, sizeof(szBuf), &cchRead, "%s/bcdDevice", pszSysfsPath); 1341 if (RT_FAILURE(vrc) || cchRead == sizeof(szBuf)) 1346 1342 pDev->bcdDevice = UINT16_MAX; 1347 1343 else 1348 1344 { 1349 rc = usbsysfsConvertStrToBCD(szBuf, &pDev->bcdDevice);1350 if (RT_FAILURE( rc))1345 vrc = usbsysfsConvertStrToBCD(szBuf, &pDev->bcdDevice); 1346 if (RT_FAILURE(vrc)) 1351 1347 pDev->bcdDevice = UINT16_MAX; 1352 1348 } 1353 1349 1354 1350 /* Now do things that need string duplication */ 1355 rc = RTLinuxSysFsReadStrFile(szBuf, sizeof(szBuf), &cchRead, "%s/product", pszSysfsPath);1356 if (RT_SUCCESS( rc) && cchRead < sizeof(szBuf))1351 vrc = RTLinuxSysFsReadStrFile(szBuf, sizeof(szBuf), &cchRead, "%s/product", pszSysfsPath); 1352 if (RT_SUCCESS(vrc) && cchRead < sizeof(szBuf)) 1357 1353 { 1358 1354 USBLibPurgeEncoding(szBuf); … … 1360 1356 } 1361 1357 1362 rc = RTLinuxSysFsReadStrFile(szBuf, sizeof(szBuf), &cchRead, "%s/serial", pszSysfsPath);1363 if (RT_SUCCESS( rc) && cchRead < sizeof(szBuf))1358 vrc = RTLinuxSysFsReadStrFile(szBuf, sizeof(szBuf), &cchRead, "%s/serial", pszSysfsPath); 1359 if (RT_SUCCESS(vrc) && cchRead < sizeof(szBuf)) 1364 1360 { 1365 1361 USBLibPurgeEncoding(szBuf); … … 1368 1364 } 1369 1365 1370 rc = RTLinuxSysFsReadStrFile(szBuf, sizeof(szBuf), &cchRead, "%s/manufacturer", pszSysfsPath);1371 if (RT_SUCCESS( rc) && cchRead < sizeof(szBuf))1366 vrc = RTLinuxSysFsReadStrFile(szBuf, sizeof(szBuf), &cchRead, "%s/manufacturer", pszSysfsPath); 1367 if (RT_SUCCESS(vrc) && cchRead < sizeof(szBuf)) 1372 1368 { 1373 1369 USBLibPurgeEncoding(szBuf); … … 1383 1379 VEC_FOR_EACH(&pInfo->mvecpszInterfaces, char *, ppszIf) 1384 1380 { 1385 rc = RTLinuxSysFsGetLinkDest(szBuf, sizeof(szBuf), NULL, "%s/driver", *ppszIf);1386 if (RT_SUCCESS( rc) && pDev->enmState != USBDEVICESTATE_UNSUPPORTED)1381 vrc = RTLinuxSysFsGetLinkDest(szBuf, sizeof(szBuf), NULL, "%s/driver", *ppszIf); 1382 if (RT_SUCCESS(vrc) && pDev->enmState != USBDEVICESTATE_UNSUPPORTED) 1387 1383 pDev->enmState = (strcmp(szBuf, "hub") == 0) 1388 1384 ? USBDEVICESTATE_UNSUPPORTED … … 1416 1412 VECTOR_OBJ(USBDeviceInfo) vecDevInfo; 1417 1413 USBDeviceInfo *pInfo; 1418 int rc;1419 1414 1420 1415 VEC_INIT_OBJ(&vecDevInfo, USBDeviceInfo, usbsysfsCleanupDevInfo); 1421 rc = usbsysfsEnumerateHostDevices(pszDevicesRoot, &vecDevInfo);1422 if (RT_FAILURE( rc))1416 int vrc = usbsysfsEnumerateHostDevices(pszDevicesRoot, &vecDevInfo); 1417 if (RT_FAILURE(vrc)) 1423 1418 return NULL; 1424 1419 VEC_FOR_EACH(&vecDevInfo, USBDeviceInfo, pInfo) … … 1426 1421 USBDEVICE *pDev = (USBDEVICE *)RTMemAllocZ(sizeof(USBDEVICE)); 1427 1422 if (!pDev) 1428 rc = VERR_NO_MEMORY;1429 if (RT_SUCCESS( rc))1423 vrc = VERR_NO_MEMORY; 1424 if (RT_SUCCESS(vrc)) 1430 1425 usbsysfsFillInDevice(pDev, pInfo); 1431 if ( RT_SUCCESS( rc)1426 if ( RT_SUCCESS(vrc) 1432 1427 && ( pDev->enmState != USBDEVICESTATE_UNSUPPORTED 1433 1428 || fUnsupportedDevicesToo) … … 1445 1440 else 1446 1441 deviceFree(pDev); 1447 if (RT_FAILURE( rc))1442 if (RT_FAILURE(vrc)) 1448 1443 break; 1449 1444 } 1450 if (RT_FAILURE( rc))1445 if (RT_FAILURE(vrc)) 1451 1446 deviceListFree(&pFirst); 1452 1447 -
trunk/src/VBox/Main/src-server/linux/USBProxyBackendLinux.cpp
r98103 r98288 99 99 100 100 const char *pcszDevicesRoot; 101 int rc = USBProxyLinuxChooseMethod(&mUsingUsbfsDevices, &pcszDevicesRoot);102 if (RT_SUCCESS( rc))101 int vrc = USBProxyLinuxChooseMethod(&mUsingUsbfsDevices, &pcszDevicesRoot); 102 if (RT_SUCCESS(vrc)) 103 103 { 104 104 mDevicesRoot = pcszDevicesRoot; 105 rc = mUsingUsbfsDevices ? initUsbfs() : initSysfs();105 vrc = mUsingUsbfsDevices ? initUsbfs() : initSysfs(); 106 106 /* For the day when we have VBoxSVC release logging... */ 107 LogRel((RT_SUCCESS( rc) ? "Successfully initialised host USB using %s\n"108 : "Failed to initialise host USB using %s\n",107 LogRel((RT_SUCCESS(vrc) ? "Successfully initialised host USB using %s\n" 108 : "Failed to initialise host USB using %s\n", 109 109 mUsingUsbfsDevices ? "USBFS" : "sysfs")); 110 110 } 111 111 112 return rc;112 return vrc; 113 113 } 114 114 … … 146 146 * Open the devices file. 147 147 */ 148 int rc;148 int vrc; 149 149 char *pszDevices = RTPathJoinA(mDevicesRoot.c_str(), "devices"); 150 150 if (pszDevices) 151 151 { 152 rc = RTFileOpen(&mhFile, pszDevices, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);153 if (RT_SUCCESS( rc))152 vrc = RTFileOpen(&mhFile, pszDevices, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 153 if (RT_SUCCESS(vrc)) 154 154 { 155 rc = RTPipeCreate(&mhWakeupPipeR, &mhWakeupPipeW, 0 /*fFlags*/);156 if (RT_SUCCESS( rc))155 vrc = RTPipeCreate(&mhWakeupPipeR, &mhWakeupPipeW, 0 /*fFlags*/); 156 if (RT_SUCCESS(vrc)) 157 157 { 158 158 /* 159 159 * Start the poller thread. 160 160 */ 161 rc = start();162 if (RT_SUCCESS( rc))161 vrc = start(); 162 if (RT_SUCCESS(vrc)) 163 163 { 164 164 RTStrFree(pszDevices); … … 172 172 } 173 173 else 174 Log(("USBProxyBackendLinux::USBProxyBackendLinux: RTFilePipe failed with rc=%Rrc\n",rc));174 Log(("USBProxyBackendLinux::USBProxyBackendLinux: RTFilePipe failed with vrc=%Rrc\n", vrc)); 175 175 RTFileClose(mhFile); 176 176 } … … 180 180 else 181 181 { 182 rc = VERR_NO_MEMORY;182 vrc = VERR_NO_MEMORY; 183 183 Log(("USBProxyBackendLinux::USBProxyBackendLinux: out of memory!\n")); 184 184 } 185 185 186 LogFlowThisFunc(("returns failure!!! ( rc=%Rrc)\n",rc));187 return rc;186 LogFlowThisFunc(("returns failure!!! (vrc=%Rrc)\n", vrc)); 187 return vrc; 188 188 } 189 189 … … 207 207 return VERR_NO_MEMORY; 208 208 } 209 int rc = mpWaiter->getStatus();210 if (RT_SUCCESS( rc) || rc == VERR_TIMEOUT ||rc == VERR_TRY_AGAIN)211 rc = start();212 else if ( rc == VERR_NOT_SUPPORTED)209 int vrc = mpWaiter->getStatus(); 210 if (RT_SUCCESS(vrc) || vrc == VERR_TIMEOUT || vrc == VERR_TRY_AGAIN) 211 vrc = start(); 212 else if (vrc == VERR_NOT_SUPPORTED) 213 213 /* This can legitimately happen if hal or DBus are not running, but of 214 214 * course we can't start in this case. */ 215 rc = VINF_SUCCESS;216 return rc;215 vrc = VINF_SUCCESS; 216 return vrc; 217 217 218 218 #else /* !VBOX_USB_WITH_SYSFS */ … … 307 307 int USBProxyBackendLinux::wait(RTMSINTERVAL aMillies) 308 308 { 309 int rc;309 int vrc; 310 310 if (mUsingUsbfsDevices) 311 rc = waitUsbfs(aMillies);311 vrc = waitUsbfs(aMillies); 312 312 else 313 rc = waitSysfs(aMillies);314 return rc;313 vrc = waitSysfs(aMillies); 314 return vrc; 315 315 } 316 316 … … 338 338 PollFds[1].events = POLLIN | POLLERR | POLLHUP; 339 339 340 int rc = poll(&PollFds[0], 2, aMillies);341 if ( rc == 0)340 int iRc = poll(&PollFds[0], 2, aMillies); 341 if (iRc == 0) 342 342 return VERR_TIMEOUT; 343 if ( rc > 0)343 if (iRc > 0) 344 344 { 345 345 /* drain the pipe */ … … 347 347 { 348 348 char szBuf[WAKE_UP_STRING_LEN]; 349 rc= RTPipeReadBlocking(mhWakeupPipeR, szBuf, sizeof(szBuf), NULL);350 AssertRC( rc);349 int vrc2 = RTPipeReadBlocking(mhWakeupPipeR, szBuf, sizeof(szBuf), NULL); 350 AssertRC(vrc2); 351 351 } 352 352 return VINF_SUCCESS; … … 359 359 { 360 360 #ifdef VBOX_USB_WITH_SYSFS 361 int rc = mpWaiter->Wait(aMillies);362 if ( rc == VERR_TRY_AGAIN)361 int vrc = mpWaiter->Wait(aMillies); 362 if (vrc == VERR_TRY_AGAIN) 363 363 { 364 364 RTThreadYield(); 365 rc = VINF_SUCCESS;366 } 367 return rc;365 vrc = VINF_SUCCESS; 366 } 367 return vrc; 368 368 #else /* !VBOX_USB_WITH_SYSFS */ 369 369 return USBProxyService::wait(aMillies); … … 386 386 } 387 387 #endif /* VBOX_USB_WITH_SYSFS */ 388 int rc = RTPipeWriteBlocking(mhWakeupPipeW, WAKE_UP_STRING, WAKE_UP_STRING_LEN, NULL);389 if (RT_SUCCESS( rc))388 int vrc = RTPipeWriteBlocking(mhWakeupPipeW, WAKE_UP_STRING, WAKE_UP_STRING_LEN, NULL); 389 if (RT_SUCCESS(vrc)) 390 390 RTPipeFlush(mhWakeupPipeW); 391 LogFlowFunc(("returning %Rrc\n", rc));392 return rc;391 LogFlowFunc(("returning %Rrc\n", vrc)); 392 return vrc; 393 393 } 394 394
Note:
See TracChangeset
for help on using the changeset viewer.