VirtualBox

Changeset 61065 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
May 19, 2016 11:15:31 PM (9 years ago)
Author:
vboxsync
Message:

VBoxServiceToolBox.cpp: Corrected warning fix, the intention was to return a const pointer. Added a todo/r=bird. ((Removed) some (unnecessary) parentheses.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceToolBox.cpp

    r61062 r61065  
    8383} VBOXSERVICETOOLBOXOUTPUTFLAG;
    8484
     85
    8586/*********************************************************************************************************************************
    8687*   Prototypes                                                                                                                   *
     
    9394static RTEXITCODE vgsvcToolboxStat(int argc, char **argv);
    9495
     96
    9597/*********************************************************************************************************************************
    9698*   Structures and Typedefs                                                                                                      *
     
    106108    /** Main handler to be invoked to use the tool. */
    107109    RTEXITCODE (*pfnHandler)(int argc, char **argv);
    108     /** Conversion routine to convert the tool's exit code back to an IPRT rc. Optional. */
     110    /** Conversion routine to convert the tool's exit code back to an IPRT rc. Optional.
     111     *
     112     * @todo r=bird: You better revert this, i.e. having pfnHandler return a VBox
     113     *       status code and have a routine for converting it to RTEXITCODE.
     114     *       Unless, what you really want to do here is to get a cached status, in
     115     *       which case you better call it what it is.
     116     */
    109117    int        (*pfnExitCodeConvertToRc)(RTEXITCODE rcExit);
    110 } VBOXSERVICETOOLBOXTOOL, *PVBOXSERVICETOOLBOXTOOL;
    111 
    112 static VBOXSERVICETOOLBOXTOOL s_aTools[] =
     118} VBOXSERVICETOOLBOXTOOL;
     119/** Pointer to a const tool definition. */
     120typedef VBOXSERVICETOOLBOXTOOL const *PCVBOXSERVICETOOLBOXTOOL;
     121
     122/**
     123 * An file/directory entry. Used to cache
     124 * file names/paths for later processing.
     125 */
     126typedef struct VBOXSERVICETOOLBOXPATHENTRY
     127{
     128    /** Our node. */
     129    RTLISTNODE  Node;
     130    /** Name of the entry. */
     131    char       *pszName;
     132} VBOXSERVICETOOLBOXPATHENTRY, *PVBOXSERVICETOOLBOXPATHENTRY;
     133
     134typedef struct VBOXSERVICETOOLBOXDIRENTRY
     135{
     136    /** Our node. */
     137    RTLISTNODE   Node;
     138    /** The actual entry. */
     139    RTDIRENTRYEX dirEntry;
     140} VBOXSERVICETOOLBOXDIRENTRY, *PVBOXSERVICETOOLBOXDIRENTRY;
     141
     142
     143/*********************************************************************************************************************************
     144*   Global Variables                                                                                                             *
     145*********************************************************************************************************************************/
     146/** Tool definitions. */
     147static VBOXSERVICETOOLBOXTOOL const g_aTools[] =
    113148{
    114149    { VBOXSERVICE_TOOL_CAT,    vgsvcToolboxCat   , NULL },
     
    119154    { VBOXSERVICE_TOOL_STAT,   vgsvcToolboxStat  , NULL }
    120155};
    121 
    122 /**
    123  * An file/directory entry. Used to cache
    124  * file names/paths for later processing.
    125  */
    126 typedef struct VBOXSERVICETOOLBOXPATHENTRY
    127 {
    128     /** Our node. */
    129     RTLISTNODE  Node;
    130     /** Name of the entry. */
    131     char       *pszName;
    132 } VBOXSERVICETOOLBOXPATHENTRY, *PVBOXSERVICETOOLBOXPATHENTRY;
    133 
    134 typedef struct VBOXSERVICETOOLBOXDIRENTRY
    135 {
    136     /** Our node. */
    137     RTLISTNODE   Node;
    138     /** The actual entry. */
    139     RTDIRENTRYEX dirEntry;
    140 } VBOXSERVICETOOLBOXDIRENTRY, *PVBOXSERVICETOOLBOXDIRENTRY;
    141 
    142 
    143156
    144157
     
    15271540 * @param   pszTool     The name of the tool.
    15281541 */
    1529 static PVBOXSERVICETOOLBOXTOOL vgsvcToolboxLookUp(const char *pszTool)
     1542static PCVBOXSERVICETOOLBOXTOOL const vgsvcToolboxLookUp(const char *pszTool)
    15301543{
    15311544    AssertPtrReturn(pszTool, NULL);
    15321545
    15331546    /* Do a linear search, since we don't have that much stuff in the table. */
    1534     for (unsigned i = 0; i < RT_ELEMENTS(s_aTools); i++)
    1535         if (!strcmp(s_aTools[i].pszName, pszTool))
    1536             return &s_aTools[i];
     1547    for (unsigned i = 0; i < RT_ELEMENTS(g_aTools); i++)
     1548        if (!strcmp(g_aTools[i].pszName, pszTool))
     1549            return &g_aTools[i];
    15371550
    15381551    return NULL;
     
    15511564    AssertPtrReturn(pszTool, VERR_INVALID_POINTER);
    15521565
    1553     PVBOXSERVICETOOLBOXTOOL pTool = vgsvcToolboxLookUp(pszTool);
     1566    PCVBOXSERVICETOOLBOXTOOL pTool = vgsvcToolboxLookUp(pszTool);
    15541567    if (pTool)
    15551568        return pTool->pfnExitCodeConvertToRc(rcExit);
     
    15771590    AssertReturn(argc > 0, false);
    15781591    const char              *pszTool = RTPathFilename(argv[0]);
    1579     PVBOXSERVICETOOLBOXTOOL pTool   = vgsvcToolboxLookUp(pszTool);
     1592    PCVBOXSERVICETOOLBOXTOOL pTool   = vgsvcToolboxLookUp(pszTool);
    15801593    if (!pTool)
    15811594    {
     
    15981611               return true;
    15991612           }
    1600            if (   (strcmp(pszTool, "help")) && (strcmp(pszTool, "--help"))
    1601                && (strcmp(pszTool, "-h")))
     1613           if (   strcmp(pszTool, "help")
     1614               && strcmp(pszTool, "--help")
     1615               && strcmp(pszTool, "-h"))
    16021616               *prcExit = RTEXITCODE_SYNTAX;
    16031617           vgsvcToolboxShowUsage();
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