VirtualBox

Changeset 104748 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
May 22, 2024 8:51:56 AM (8 months ago)
Author:
vboxsync
Message:

Main/SystemPropertiesImpl.cpp: Workaround for incorrect warning in g++ 13.2 when passing an array with a single entry to std::vector::assign. Corrected incorrect naming of static local variables. Introduced a MY_VECTOR_ASSIGN_ARRAY macro to reduce the typing involved in the std::vector::assign calls.

File:
1 edited

Legend:

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

    r104747 r104748  
    5959// defines
    6060/////////////////////////////////////////////////////////////////////////////
     61
     62/** @def MY_VECTOR_ASSIGN_ARRAY
     63 * Safe way to copy an array (static + const) into a vector w/ minimal typing.
     64 *
     65 * @param a_rVector     The destination vector reference.
     66 * @param a_aSrcArray   The source array to assign to the vector.
     67 */
     68#if RT_GNUC_PREREQ(13, 0) && !RT_GNUC_PREREQ(14, 0) && defined(VBOX_WITH_GCC_SANITIZER)
     69/* Workaround for g++ 13.2 incorrectly failing on arrays with a single entry in ASAN builds.
     70   This is restricted to [13.0, 14.0), assuming the issue was introduced in the 13 cycle
     71   and will be fixed by the time 14 is done.  If 14 doesn't fix it, extend the range
     72   version by version till it is fixed. */
     73# define MY_VECTOR_ASSIGN_ARRAY(a_rVector, a_aSrcArray) do { \
     74        _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wstringop-overread\""); \
     75        (a_rVector).assign(&a_aSrcArray[0], &a_aSrcArray[RT_ELEMENTS(a_aSrcArray)]); \
     76        _Pragma("GCC diagnostic pop"); \
     77    } while (0)
     78#else
     79# define MY_VECTOR_ASSIGN_ARRAY(a_rVector, a_aSrcArray) do { \
     80        (a_rVector).assign(&a_aSrcArray[0], &a_aSrcArray[RT_ELEMENTS(a_aSrcArray)]); \
     81    } while (0)
     82#endif
     83
    6184
    6285// constructor / destructor
     
    10231046HRESULT SystemProperties::getSupportedPlatformArchitectures(std::vector<PlatformArchitecture_T> &aSupportedPlatformArchitectures)
    10241047{
    1025     static const PlatformArchitecture_T aPlatformArchitectures[] =
     1048    static const PlatformArchitecture_T s_aPlatformArchitectures[] =
    10261049    {
    10271050#if   defined(RT_ARCH_X86)   || defined(RT_ARCH_AMD64)
     
    10391062#endif
    10401063    };
    1041     aSupportedPlatformArchitectures.assign(aPlatformArchitectures,
    1042                                            aPlatformArchitectures + RT_ELEMENTS(aPlatformArchitectures));
     1064    MY_VECTOR_ASSIGN_ARRAY(aSupportedPlatformArchitectures, s_aPlatformArchitectures);
    10431065    return S_OK;
    10441066}
     
    10461068HRESULT SystemProperties::getSupportedClipboardModes(std::vector<ClipboardMode_T> &aSupportedClipboardModes)
    10471069{
    1048     static const ClipboardMode_T aClipboardModes[] =
     1070    static const ClipboardMode_T s_aClipboardModes[] =
    10491071    {
    10501072        ClipboardMode_Disabled,
     
    10531075        ClipboardMode_Bidirectional,
    10541076    };
    1055     aSupportedClipboardModes.assign(aClipboardModes,
    1056                                     aClipboardModes + RT_ELEMENTS(aClipboardModes));
     1077    MY_VECTOR_ASSIGN_ARRAY(aSupportedClipboardModes, s_aClipboardModes);
    10571078    return S_OK;
    10581079}
     
    10601081HRESULT SystemProperties::getSupportedDnDModes(std::vector<DnDMode_T> &aSupportedDnDModes)
    10611082{
    1062     static const DnDMode_T aDnDModes[] =
     1083    static const DnDMode_T s_aDnDModes[] =
    10631084    {
    10641085        DnDMode_Disabled,
     
    10671088        DnDMode_Bidirectional,
    10681089    };
    1069     aSupportedDnDModes.assign(aDnDModes,
    1070                               aDnDModes + RT_ELEMENTS(aDnDModes));
     1090    MY_VECTOR_ASSIGN_ARRAY(aSupportedDnDModes, s_aDnDModes);
    10711091    return S_OK;
    10721092}
     
    10741094HRESULT SystemProperties::getSupportedPointingHIDTypes(std::vector<PointingHIDType_T> &aSupportedPointingHIDTypes)
    10751095{
    1076     static const PointingHIDType_T aPointingHIDTypes[] =
     1096    static const PointingHIDType_T s_aPointingHIDTypes[] =
    10771097    {
    10781098        PointingHIDType_PS2Mouse,
     
    10871107        PointingHIDType_USBMultiTouchScreenPlusPad,
    10881108    };
    1089     aSupportedPointingHIDTypes.assign(aPointingHIDTypes,
    1090                                       aPointingHIDTypes + RT_ELEMENTS(aPointingHIDTypes));
     1109    MY_VECTOR_ASSIGN_ARRAY(aSupportedPointingHIDTypes, s_aPointingHIDTypes);
    10911110    return S_OK;
    10921111}
     
    10941113HRESULT SystemProperties::getSupportedKeyboardHIDTypes(std::vector<KeyboardHIDType_T> &aSupportedKeyboardHIDTypes)
    10951114{
    1096     static const KeyboardHIDType_T aKeyboardHIDTypes[] =
     1115    static const KeyboardHIDType_T s_aKeyboardHIDTypes[] =
    10971116    {
    10981117        KeyboardHIDType_PS2Keyboard,
     
    11021121#endif
    11031122    };
    1104     aSupportedKeyboardHIDTypes.assign(aKeyboardHIDTypes,
    1105                                       aKeyboardHIDTypes + RT_ELEMENTS(aKeyboardHIDTypes));
     1123    MY_VECTOR_ASSIGN_ARRAY(aSupportedKeyboardHIDTypes, s_aKeyboardHIDTypes);
    11061124    return S_OK;
    11071125}
     
    11091127HRESULT SystemProperties::getSupportedVFSTypes(std::vector<VFSType_T> &aSupportedVFSTypes)
    11101128{
    1111     static const VFSType_T aVFSTypes[] =
     1129    static const VFSType_T s_aVFSTypes[] =
    11121130    {
    11131131        VFSType_File,
     
    11181136#endif
    11191137    };
    1120     aSupportedVFSTypes.assign(aVFSTypes,
    1121                               aVFSTypes + RT_ELEMENTS(aVFSTypes));
     1138    MY_VECTOR_ASSIGN_ARRAY(aSupportedVFSTypes, s_aVFSTypes);
    11221139    return S_OK;
    11231140}
     
    11251142HRESULT SystemProperties::getSupportedImportOptions(std::vector<ImportOptions_T> &aSupportedImportOptions)
    11261143{
    1127     static const ImportOptions_T aImportOptions[] =
     1144    static const ImportOptions_T s_aImportOptions[] =
    11281145    {
    11291146        ImportOptions_KeepAllMACs,
     
    11311148        ImportOptions_ImportToVDI,
    11321149    };
    1133     aSupportedImportOptions.assign(aImportOptions,
    1134                                    aImportOptions + RT_ELEMENTS(aImportOptions));
     1150    MY_VECTOR_ASSIGN_ARRAY(aSupportedImportOptions, s_aImportOptions);
    11351151    return S_OK;
    11361152}
     
    11381154HRESULT SystemProperties::getSupportedExportOptions(std::vector<ExportOptions_T> &aSupportedExportOptions)
    11391155{
    1140     static const ExportOptions_T aExportOptions[] =
     1156    static const ExportOptions_T s_aExportOptions[] =
    11411157    {
    11421158        ExportOptions_CreateManifest,
     
    11451161        ExportOptions_StripAllNonNATMACs,
    11461162    };
    1147     aSupportedExportOptions.assign(aExportOptions,
    1148                                    aExportOptions + RT_ELEMENTS(aExportOptions));
     1163    MY_VECTOR_ASSIGN_ARRAY(aSupportedExportOptions, s_aExportOptions);
    11491164    return S_OK;
    11501165}
     
    11531168{
    11541169#ifdef VBOX_WITH_RECORDING
    1155     static const RecordingFeature_T aRecordingFeatures[] =
     1170    static const RecordingFeature_T s_aRecordingFeatures[] =
    11561171    {
    11571172# ifdef VBOX_WITH_AUDIO_RECORDING
     
    11601175        RecordingFeature_Video,
    11611176    };
    1162     aSupportedRecordingFeatures.assign(aRecordingFeatures,
    1163                                        aRecordingFeatures + RT_ELEMENTS(aRecordingFeatures));
     1177    MY_VECTOR_ASSIGN_ARRAY(aSupportedRecordingFeatures, s_aRecordingFeatures);
    11641178#else  /* !VBOX_WITH_RECORDING */
    11651179    aSupportedRecordingFeatures.clear();
     
    11701184HRESULT SystemProperties::getSupportedRecordingAudioCodecs(std::vector<RecordingAudioCodec_T> &aSupportedRecordingAudioCodecs)
    11711185{
    1172     static const RecordingAudioCodec_T aRecordingAudioCodecs[] =
     1186    static const RecordingAudioCodec_T s_aRecordingAudioCodecs[] =
    11731187    {
    11741188        RecordingAudioCodec_None,
     
    11801194#endif
    11811195    };
    1182     aSupportedRecordingAudioCodecs.assign(aRecordingAudioCodecs,
    1183                                           aRecordingAudioCodecs + RT_ELEMENTS(aRecordingAudioCodecs));
     1196    MY_VECTOR_ASSIGN_ARRAY(aSupportedRecordingAudioCodecs, s_aRecordingAudioCodecs);
    11841197    return S_OK;
    11851198}
     
    11871200HRESULT SystemProperties::getSupportedRecordingVideoCodecs(std::vector<RecordingVideoCodec_T> &aSupportedRecordingVideoCodecs)
    11881201{
    1189     static const RecordingVideoCodec_T aRecordingVideoCodecs[] =
     1202    static const RecordingVideoCodec_T s_aRecordingVideoCodecs[] =
    11901203    {
    11911204        RecordingVideoCodec_None,
     
    11981211#endif
    11991212    };
    1200     aSupportedRecordingVideoCodecs.assign(aRecordingVideoCodecs,
    1201                                           aRecordingVideoCodecs + RT_ELEMENTS(aRecordingVideoCodecs));
     1213    MY_VECTOR_ASSIGN_ARRAY(aSupportedRecordingVideoCodecs, s_aRecordingVideoCodecs);
    12021214    return S_OK;
    12031215}
     
    12051217HRESULT SystemProperties::getSupportedRecordingVSModes(std::vector<RecordingVideoScalingMode_T> &aSupportedRecordingVideoScalingModes)
    12061218{
    1207     static const RecordingVideoScalingMode_T aRecordingVideoScalingModes[] =
     1219    static const RecordingVideoScalingMode_T s_aRecordingVideoScalingModes[] =
    12081220    {
    12091221        RecordingVideoScalingMode_None,
     
    12141226#endif
    12151227    };
    1216     aSupportedRecordingVideoScalingModes.assign(aRecordingVideoScalingModes,
    1217                                                 aRecordingVideoScalingModes + RT_ELEMENTS(aRecordingVideoScalingModes));
     1228    MY_VECTOR_ASSIGN_ARRAY(aSupportedRecordingVideoScalingModes, s_aRecordingVideoScalingModes);
    12181229    return S_OK;
    12191230}
     
    12211232HRESULT SystemProperties::getSupportedRecordingARCModes(std::vector<RecordingRateControlMode_T> &aSupportedRecordingAudioRateControlModes)
    12221233{
    1223     static const RecordingRateControlMode_T aRecordingAudioRateControlModes[] =
     1234    static const RecordingRateControlMode_T s_aRecordingAudioRateControlModes[] =
    12241235    {
    12251236#ifdef DEBUG
     
    12291240        RecordingRateControlMode_VBR
    12301241    };
    1231     aSupportedRecordingAudioRateControlModes.assign(aRecordingAudioRateControlModes,
    1232                                                     aRecordingAudioRateControlModes + RT_ELEMENTS(aRecordingAudioRateControlModes));
     1242    MY_VECTOR_ASSIGN_ARRAY(aSupportedRecordingAudioRateControlModes, s_aRecordingAudioRateControlModes);
    12331243    return S_OK;
    12341244}
     
    12361246HRESULT SystemProperties::getSupportedRecordingVRCModes(std::vector<RecordingRateControlMode_T> &aSupportedRecordingVideoRateControlModes)
    12371247{
    1238     static const RecordingRateControlMode_T aRecordingVideoRateControlModes[] =
     1248    static const RecordingRateControlMode_T s_aRecordingVideoRateControlModes[] =
    12391249    {
    12401250#ifdef DEBUG
     
    12441254        RecordingRateControlMode_VBR
    12451255    };
    1246     aSupportedRecordingVideoRateControlModes.assign(aRecordingVideoRateControlModes,
    1247                                                     aRecordingVideoRateControlModes + RT_ELEMENTS(aRecordingVideoRateControlModes));
     1256    MY_VECTOR_ASSIGN_ARRAY(aSupportedRecordingVideoRateControlModes, s_aRecordingVideoRateControlModes);
    12481257    return S_OK;
    12491258}
     
    12511260HRESULT SystemProperties::getSupportedCloneOptions(std::vector<CloneOptions_T> &aSupportedCloneOptions)
    12521261{
    1253     static const CloneOptions_T aCloneOptions[] =
     1262    static const CloneOptions_T s_aCloneOptions[] =
    12541263    {
    12551264        CloneOptions_Link,
     
    12591268        CloneOptions_KeepHwUUIDs,
    12601269    };
    1261     aSupportedCloneOptions.assign(aCloneOptions,
    1262                                   aCloneOptions + RT_ELEMENTS(aCloneOptions));
     1270    MY_VECTOR_ASSIGN_ARRAY(aSupportedCloneOptions, s_aCloneOptions);
    12631271    return S_OK;
    12641272}
     
    12661274HRESULT SystemProperties::getSupportedAutostopTypes(std::vector<AutostopType_T> &aSupportedAutostopTypes)
    12671275{
    1268     static const AutostopType_T aAutostopTypes[] =
     1276    static const AutostopType_T s_aAutostopTypes[] =
    12691277    {
    12701278        AutostopType_Disabled,
     
    12731281        AutostopType_AcpiShutdown,
    12741282    };
    1275     aSupportedAutostopTypes.assign(aAutostopTypes,
    1276                                    aAutostopTypes + RT_ELEMENTS(aAutostopTypes));
     1283    MY_VECTOR_ASSIGN_ARRAY(aSupportedAutostopTypes, s_aAutostopTypes);
    12771284    return S_OK;
    12781285}
     
    12801287HRESULT SystemProperties::getSupportedVMProcPriorities(std::vector<VMProcPriority_T> &aSupportedVMProcPriorities)
    12811288{
    1282     static const VMProcPriority_T aVMProcPriorities[] =
     1289    static const VMProcPriority_T s_aVMProcPriorities[] =
    12831290    {
    12841291        VMProcPriority_Default,
     
    12881295        VMProcPriority_High,
    12891296    };
    1290     aSupportedVMProcPriorities.assign(aVMProcPriorities,
    1291                                       aVMProcPriorities + RT_ELEMENTS(aVMProcPriorities));
     1297    MY_VECTOR_ASSIGN_ARRAY(aSupportedVMProcPriorities, s_aVMProcPriorities);
    12921298    return S_OK;
    12931299}
     
    12951301HRESULT SystemProperties::getSupportedNetworkAttachmentTypes(std::vector<NetworkAttachmentType_T> &aSupportedNetworkAttachmentTypes)
    12961302{
    1297     static const NetworkAttachmentType_T aNetworkAttachmentTypes[] =
     1303    static const NetworkAttachmentType_T s_aNetworkAttachmentTypes[] =
    12981304    {
    12991305        NetworkAttachmentType_NAT,
     
    13111317        NetworkAttachmentType_Null,
    13121318    };
    1313     aSupportedNetworkAttachmentTypes.assign(aNetworkAttachmentTypes,
    1314                                             aNetworkAttachmentTypes + RT_ELEMENTS(aNetworkAttachmentTypes));
     1319    MY_VECTOR_ASSIGN_ARRAY(aSupportedNetworkAttachmentTypes, s_aNetworkAttachmentTypes);
    13151320    return S_OK;
    13161321}
     
    13181323HRESULT SystemProperties::getSupportedPortModes(std::vector<PortMode_T> &aSupportedPortModes)
    13191324{
    1320     static const PortMode_T aPortModes[] =
     1325    static const PortMode_T s_aPortModes[] =
    13211326    {
    13221327        PortMode_Disconnected,
     
    13261331        PortMode_TCP,
    13271332    };
    1328     aSupportedPortModes.assign(aPortModes,
    1329                                aPortModes + RT_ELEMENTS(aPortModes));
     1333    MY_VECTOR_ASSIGN_ARRAY(aSupportedPortModes, s_aPortModes);
    13301334    return S_OK;
    13311335}
     
    13331337HRESULT SystemProperties::getSupportedAudioDriverTypes(std::vector<AudioDriverType_T> &aSupportedAudioDriverTypes)
    13341338{
    1335     static const AudioDriverType_T aAudioDriverTypes[] =
     1339    static const AudioDriverType_T s_aAudioDriverTypes[] =
    13361340    {
    13371341        AudioDriverType_Default,
     
    13651369        AudioDriverType_Null,
    13661370    };
    1367     aSupportedAudioDriverTypes.assign(aAudioDriverTypes,
    1368                                       aAudioDriverTypes + RT_ELEMENTS(aAudioDriverTypes));
     1371    MY_VECTOR_ASSIGN_ARRAY(aSupportedAudioDriverTypes, s_aAudioDriverTypes);
    13691372    return S_OK;
    13701373}
     
    13781381        case CPUArchitecture_AMD64:
    13791382        {
    1380             static const VMExecutionEngine_T aExecEngines[] =
     1383            static const VMExecutionEngine_T s_aExecEngines[] =
    13811384            {
    13821385                VMExecutionEngine_Default,
     
    13941397#endif
    13951398            };
    1396             aExecutionEngines.assign(aExecEngines,
    1397                                      aExecEngines + RT_ELEMENTS(aExecEngines));
     1399            MY_VECTOR_ASSIGN_ARRAY(aExecutionEngines, s_aExecEngines);
    13981400            break;
    13991401        }
     
    14131415# endif
    14141416            };
    1415             aExecutionEngines.assign(aExecEngines,
    1416                                      aExecEngines + RT_ELEMENTS(aExecEngines));
     1417            MY_VECTOR_ASSIGN_ARRAY(aExecutionEngines, s_aExecEngines);
    14171418#else
    14181419            aExecutionEngines.clear();
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