Bug 1729815 - Allow empty feature list, or bitset=0 - r=julienw

This is necessary, because the next patch will remove the "threads" feature, and some tests only add that one feature so now they will have an empty feature list, equivalent to a feature bitset of 0 (zero).

Differential Revision: https://phabricator.services.mozilla.com/D134136
This commit is contained in:
Gerald Squelart 2021-12-20 21:03:09 +00:00
parent 16ce2f0dcc
commit 7b40fa572e
2 changed files with 14 additions and 6 deletions

View File

@ -2554,7 +2554,11 @@ static Vector<const char*> SplitAtCommas(const char* aString,
aStorage[i] = '\0';
}
if (aStorage[i] == '\0') {
MOZ_RELEASE_ASSERT(array.append(&aStorage[currentElementStart]));
// Only add non-empty elements, otherwise ParseFeatures would later
// complain about unrecognized features.
if (currentElementStart != i) {
MOZ_RELEASE_ASSERT(array.append(&aStorage[currentElementStart]));
}
currentElementStart = i + 1;
}
}
@ -2717,7 +2721,7 @@ void profiler_init(void* aStackTop) {
if (startupFeaturesBitfield && startupFeaturesBitfield[0] != '\0') {
errno = 0;
features = strtol(startupFeaturesBitfield, nullptr, 10);
if (errno == 0 && features != 0) {
if (errno == 0) {
LOG("- MOZ_PROFILER_STARTUP_FEATURES_BITFIELD = %d", features);
} else {
PrintToConsole(
@ -2727,7 +2731,7 @@ void profiler_init(void* aStackTop) {
}
} else {
const char* startupFeatures = getenv("MOZ_PROFILER_STARTUP_FEATURES");
if (startupFeatures && startupFeatures[0] != '\0') {
if (startupFeatures) {
// Interpret startupFeatures as a list of feature strings, separated by
// commas.
UniquePtr<char[]> featureStringStorage;

View File

@ -4645,7 +4645,11 @@ static Vector<const char*> SplitAtCommas(const char* aString,
aStorage[i] = '\0';
}
if (aStorage[i] == '\0') {
MOZ_RELEASE_ASSERT(array.append(&aStorage[currentElementStart]));
// Only add non-empty elements, otherwise ParseFeatures would later
// complain about unrecognized features.
if (currentElementStart != i) {
MOZ_RELEASE_ASSERT(array.append(&aStorage[currentElementStart]));
}
currentElementStart = i + 1;
}
}
@ -4828,7 +4832,7 @@ void profiler_init(void* aStackTop) {
if (startupFeaturesBitfield && startupFeaturesBitfield[0] != '\0') {
errno = 0;
features = strtol(startupFeaturesBitfield, nullptr, 10);
if (errno == 0 && features != 0) {
if (errno == 0) {
LOG("- MOZ_PROFILER_STARTUP_FEATURES_BITFIELD = %d", features);
} else {
LOG("- MOZ_PROFILER_STARTUP_FEATURES_BITFIELD not a valid integer: %s",
@ -4837,7 +4841,7 @@ void profiler_init(void* aStackTop) {
}
} else {
const char* startupFeatures = getenv("MOZ_PROFILER_STARTUP_FEATURES");
if (startupFeatures && startupFeatures[0] != '\0') {
if (startupFeatures) {
// Interpret startupFeatures as a list of feature strings, separated by
// commas.
UniquePtr<char[]> featureStringStorage;