VirtualBox

Changeset 89642 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
Jun 13, 2021 1:38:33 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145087
Message:

ValKit/Audio: g_aCommands -> g_apCommands to avoid having the compiler generate initialization code for copying g_CmdEnum, g_CmdPlay, g_CmdRec and g_CmdSelfTest into the array. bugref:10008

Location:
trunk/src/VBox/ValidationKit/utils/audio
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp

    r89641 r89642  
    734734
    735735
     736const VKATCMD g_CmdTest =
     737{
     738    "test",
     739    audioTestMain,
     740    "Runs audio tests and creates an audio test set.",
     741    g_aCmdTestOptions,
     742    RT_ELEMENTS(g_aCmdTestOptions),
     743    audioTestCmdTestHelp
     744};
     745
     746
    736747/*********************************************************************************************************************************
    737748*   Command: verify                                                                                                              *
     
    895906
    896907
     908const VKATCMD g_CmdVerify =
     909{
     910    "verify",
     911    audioVerifyMain,
     912    "Verifies a formerly created audio test set.",
     913    g_aCmdVerifyOptions,
     914    RT_ELEMENTS(g_aCmdVerifyOptions),
     915    NULL,
     916};
     917
     918
    897919/*********************************************************************************************************************************
    898920*   Main                                                                                                                         *
     
    914936}
    915937
    916 const VKATCMD g_aCommands[] =
    917 {
    918     {
    919         "test",     audioTestMain,
    920         "Runs audio tests and creates an audio test set.",
    921         g_aCmdTestOptions,      RT_ELEMENTS(g_aCmdTestOptions),     audioTestCmdTestHelp
    922     },
    923     {
    924         "verify",   audioVerifyMain,
    925         "Verifies a formerly created audio test set.",
    926         g_aCmdVerifyOptions,    RT_ELEMENTS(g_aCmdVerifyOptions),   NULL,
    927     },
    928     g_cmdEnum,
    929     g_cmdPlay,
    930     g_cmdRec,
    931     g_cmdSelfTest
     938/**
     939 * Commands.
     940 */
     941const VKATCMD *g_apCommands[] =
     942{
     943    &g_CmdTest,
     944    &g_CmdVerify,
     945    &g_CmdEnum,
     946    &g_CmdPlay,
     947    &g_CmdRec,
     948    &g_CmdSelfTest
    932949};
    933950
     
    956973                 );
    957974
    958     for (uintptr_t iCmd = 0; iCmd < RT_ELEMENTS(g_aCommands); iCmd++)
    959     {
     975    for (uintptr_t iCmd = 0; iCmd < RT_ELEMENTS(g_apCommands); iCmd++)
     976    {
     977        PCVKATCMD const pCmd = g_apCommands[iCmd];
    960978        RTStrmPrintf(pStrm,
    961979                     "\n"
     
    963981                     "    %s\n"
    964982                     "Options for '%s':\n",
    965                      g_aCommands[iCmd].pszCommand, g_aCommands[iCmd].pszDesc, g_aCommands[iCmd].pszCommand);
    966         PCRTGETOPTDEF const paOptions = g_aCommands[iCmd].paOptions;
    967         for (unsigned i = 0; i < g_aCommands[iCmd].cOptions; i++)
     983                     pCmd->pszCommand, pCmd->pszDesc, pCmd->pszCommand);
     984        PCRTGETOPTDEF const paOptions = pCmd->paOptions;
     985        for (unsigned i = 0; i < pCmd->cOptions; i++)
    968986        {
    969987            if (RT_C_IS_PRINT(paOptions[i].iShort))
     
    973991
    974992            const char *pszHelp = NULL;
    975             if (g_aCommands[iCmd].pfnOptionHelp)
    976                 pszHelp = g_aCommands[iCmd].pfnOptionHelp(&paOptions[i]);
     993            if (pCmd->pfnOptionHelp)
     994                pszHelp = pCmd->pfnOptionHelp(&paOptions[i]);
    977995            if (pszHelp)
    978996                RTStrmPrintf(pStrm, "    %s\n", pszHelp);
     
    10751093            case VINF_GETOPT_NOT_OPTION:
    10761094            {
    1077                 for (uintptr_t i = 0; i < RT_ELEMENTS(g_aCommands); i++)
    1078                     if (strcmp(ValueUnion.psz, g_aCommands[i].pszCommand) == 0)
     1095                for (uintptr_t iCmd = 0; iCmd < RT_ELEMENTS(g_apCommands); iCmd++)
     1096                {
     1097                    PCVKATCMD const pCmd = g_apCommands[iCmd];
     1098                    if (strcmp(ValueUnion.psz, pCmd->pszCommand) == 0)
    10791099                    {
    1080                         size_t const cCombinedOptions  = g_aCommands[i].cOptions + RT_ELEMENTS(g_aCmdCommonOptions);
     1100                        size_t const cCombinedOptions  = pCmd->cOptions + RT_ELEMENTS(g_aCmdCommonOptions);
    10811101                        PRTGETOPTDEF paCombinedOptions = (PRTGETOPTDEF)RTMemAlloc(cCombinedOptions * sizeof(RTGETOPTDEF));
    10821102                        if (paCombinedOptions)
     
    10841104                            memcpy(paCombinedOptions, g_aCmdCommonOptions, sizeof(g_aCmdCommonOptions));
    10851105                            memcpy(&paCombinedOptions[RT_ELEMENTS(g_aCmdCommonOptions)],
    1086                                    g_aCommands[i].paOptions, g_aCommands[i].cOptions * sizeof(RTGETOPTDEF));
     1106                                   pCmd->paOptions, pCmd->cOptions * sizeof(RTGETOPTDEF));
    10871107
    10881108                            rc = RTGetOptInit(&GetState, argc, argv, paCombinedOptions, cCombinedOptions,
     
    10911111                            {
    10921112
    1093                                 rcExit = g_aCommands[i].pfnHandler(&GetState);
     1113                                rcExit = pCmd->pfnHandler(&GetState);
    10941114                                RTMemFree(paCombinedOptions);
    10951115                                return rcExit;
     
    10991119                        return RTMsgErrorExitFailure("Out of memory!");
    11001120                    }
     1121                }
    11011122                RTMsgError("Unknown command '%s'!\n", ValueUnion.psz);
    11021123                audioTestUsage(g_pStdErr);
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCmdGeneric.cpp

    r89641 r89642  
    149149 * Command table entry for 'enum'.
    150150 */
    151 const VKATCMD g_cmdEnum =
     151const VKATCMD g_CmdEnum =
    152152{
    153153    "enum",
     
    478478 * Command table entry for 'play'.
    479479 */
    480 const VKATCMD g_cmdPlay =
     480const VKATCMD g_CmdPlay =
    481481{
    482482    "play",
     
    858858 * Command table entry for 'rec'.
    859859 */
    860 const VKATCMD g_cmdRec =
     860const VKATCMD g_CmdRec =
    861861{
    862862    "rec",
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCmdSelfTest.cpp

    r89617 r89642  
    329329}
    330330
    331 const VKATCMD g_cmdSelfTest =
    332 {
    333     "selftest", audioTestCmdSelftestHandler,
     331/**
     332 * Command table entry for 'selftest'.
     333 */
     334const VKATCMD g_CmdSelfTest =
     335{
     336    "selftest",
     337    audioTestCmdSelftestHandler,
    334338    "Performs self-tests.",
    335     s_aCmdSelftestOptions,  RT_ELEMENTS(s_aCmdSelftestOptions), audioTestCmdSelftestHelp,
     339    s_aCmdSelftestOptions,
     340    RT_ELEMENTS(s_aCmdSelftestOptions),
     341    audioTestCmdSelftestHelp,
    336342};
    337343
  • trunk/src/VBox/ValidationKit/utils/audio/vkatInternal.h

    r89641 r89642  
    363363    DECLCALLBACKMEMBER(const char *, pfnOptionHelp,(PCRTGETOPTDEF pOpt));
    364364} VKATCMD;
    365 /** Pointer to a single VKAT command. */
    366 typedef VKATCMD *PVKATCMD;
    367 
    368 extern const VKATCMD g_cmdEnum;
    369 extern const VKATCMD g_cmdPlay;
    370 extern const VKATCMD g_cmdRec;
    371 extern const VKATCMD g_cmdSelfTest;
     365/** Pointer to a const VKAT command entry. */
     366typedef VKATCMD const *PCVKATCMD;
     367
     368extern const VKATCMD g_CmdEnum;
     369extern const VKATCMD g_CmdPlay;
     370extern const VKATCMD g_CmdRec;
     371extern const VKATCMD g_CmdSelfTest;
    372372
    373373extern AUDIOTESTDESC g_aTests[];
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