VirtualBox

Changeset 103429 in vbox


Ignore:
Timestamp:
Feb 19, 2024 11:59:36 AM (9 months ago)
Author:
vboxsync
Message:

Main/PerformanceLinux.cpp: Avoid re-doing overflow checks too many times. Todos. bugref:3409

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/linux/PerformanceLinux.cpp

    r103285 r103429  
    4949#include "Performance.h"
    5050
    51 #define VBOXVOLINFO_NAME "VBoxVolInfo"
     51#define VBOXVOLINFO_EXE_NAME "VBoxVolInfo"
    5252
    5353namespace pm {
     
    524524void CollectorLinux::addVolumeDependencies(const char *pcszVolume, DiskList& listDisks)
    525525{
     526    /** @todo r=bird: This is presumptive and will misbehave if someone puts VBox
     527     *        in directory which path contains spaces or other problematic
     528     *        characters.  This is one of the reasons to avoid popen(). */
     529    static const char s_szSlashExeNameSpace[] = "/" VBOXVOLINFO_EXE_NAME " ";
     530    size_t const cchVolume = strlen(pcszVolume);
    526531    char szVolInfo[RTPATH_MAX];
    527     int vrc = RTPathAppPrivateArch(szVolInfo, sizeof(szVolInfo) - sizeof("/" VBOXVOLINFO_NAME " ") - strlen(pcszVolume));
     532    int vrc = RTPathAppPrivateArch(szVolInfo, sizeof(szVolInfo) - sizeof(s_szSlashExeNameSpace) - cchVolume);
    528533    if (RT_FAILURE(vrc))
    529534    {
    530535        LogRel(("VolInfo: Failed to get program path, vrc=%Rrc\n", vrc));
     536        /** @todo r=bird: inconsistent failure behaviour. if popen fails, volume is
     537         *        pushed onto the list, while here it isn't. */
    531538        return;
    532539    }
    533     vrc = RTStrCat(szVolInfo, sizeof(szVolInfo), "/" VBOXVOLINFO_NAME " ");
    534     AssertRCReturnVoid(vrc);
    535     vrc = RTStrCat(szVolInfo, sizeof(szVolInfo), pcszVolume);
    536     AssertRCReturnVoid(vrc);
     540    memcpy(mempcpy(strchr(szVolInfo, '\0'), s_szSlashExeNameSpace, sizeof(s_szSlashExeNameSpace) - 1),
     541           pcszVolume, cchVolume + 1);
    537542
    538543    FILE *fp = popen(szVolInfo, "r");
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette