Closed Bug 2069010 Opened 2 months ago Closed 5 days ago

Make Preferences::RegisterCallbacks() take in an array of defined size

Categories

(Core :: Preferences: Backend, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: gstoll, Assigned: virpatel71)

Details

(Keywords: good-first-bug)

Attachments

(1 external file)

Right now this function takes in a const char* const* and relies on callers to null-terminate their array. This is a footgun; we should make it <size_t N>(const char prefs[N]) or something of defined size. (we should do this for Preferences::RegisterCallbacksAndCall(), Preferences::UnregisterCallbacks(), etc. as well)

Keywords: good-first-bug

we should make it <size_t N>(const char prefs[N]) or something of defined size.

Thoughts on using Span<const char* const>? Span can be included using #include "mozilla/Span.h" and can be iterated over safely:

for (const char* pref : view) {
  printf("%s\n", pref);
}

Caller does would do something like:

const char* prefs[] = {
    "browser.tabs.warnOnClose",
    "dom.webnotifications.enabled",
};

Span<const char* const> view = prefs;

Sorry for the delay in responding here. A Span sounds fine to me - thanks!

No worries, I'd like to be assigned to this if possible.

Definitely! Feel free to assign it to yourself. There’s a bunch of information here, and feel to ask questions here or on Matrix!

Unfortunately, I don't have sufficient permissions to assign myself.

Ah, sorry! I can do it then.

Assignee: nobody → virpatel71
Status: NEW → ASSIGNED
Pushed by ealvarez@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/b42f9826fdd6 https://hg.mozilla.org/integration/autoland/rev/39218c8ddd5a Use bounded spans for preference callback lists. r=gstoll,firefox-style-system-reviewers,necko-reviewers,media-playback-reviewers,layout-reviewers,padenot,dshin
Pushed by sstanca@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a82bcf39e8d2 https://hg.mozilla.org/integration/autoland/rev/05b293386ebf Revert "Bug 2069010 - Use bounded spans for preference callback lists. r=gstoll,firefox-style-system-reviewers,necko-reviewers,media-playback-reviewers,layout-reviewers,padenot,dshin" for causibg gtest process-crashes.

Reverted this because it was causing gtest process-crashes.

Flags: needinfo?(virpatel71)
Pushed by gstoll@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/e92c662118e6 https://hg.mozilla.org/integration/autoland/rev/ed3af81fb85b Use bounded spans for preference callback lists. r=gstoll,firefox-style-system-reviewers,necko-reviewers,tschuster,media-playback-reviewers,layout-reviewers,padenot,dshin,valentin
Status: ASSIGNED → RESOLVED
Closed: 5 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
Flags: needinfo?(virpatel71)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: