Closed
Bug 1155963
Opened 10 years ago
Closed 10 years ago
Don't allow NS_NAMED_LITERAL_CSTRING(name, NS_LITERAL_CSTRING("value"))
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla41
People
(Reporter: neil, Assigned: neil)
References
Details
Attachments
(1 file, 1 obsolete file)
|
68.00 KB,
patch
|
froydnj
:
review+
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
The wide equivalent won't compile because of an extra MOZ_UTF16 macro.
| Assignee | ||
Comment 1•10 years ago
|
||
I suppose I could #ifdef the change to only apply to narrow strings...
Attachment #8594318 -
Flags: review?(nfroyd)
Comment 2•10 years ago
|
||
Comment on attachment 8594318 [details] [diff] [review]
Possible patch
Review of attachment 8594318 [details] [diff] [review]:
-----------------------------------------------------------------
::: caps/nsPrincipal.cpp
@@ +633,5 @@
> NS_ENSURE_SUCCESS(rv, false);
>
> // NOTE: This static whitelist is expected to be short. If that changes,
> // we should consider a different representation; e.g. hash-set, prefix tree.
> + const nsLiteralCString sFullDomainsOnWhitelist[] = {
Does the compiler actually complain if this is |static|? GCC seems to be perfectly happy with it.
Please make this |static| if possible.
@@ +666,5 @@
> // unprefixing for all its subdomains)
> static bool
> IsOnBaseDomainWhitelist(nsIURI* aURI)
> {
> + const nsLiteralCString sBaseDomainsOnWhitelist[] = {
Likewise for the |static|-ness here.
::: dom/devicestorage/nsDeviceStorage.cpp
@@ +580,5 @@
> DeviceStorageTypeChecker* typeChecker
> = DeviceStorageTypeChecker::CreateOrGet();
> MOZ_ASSERT(typeChecker);
>
> + const nsLiteralString kMediaTypes[] = {
Likewise for the |static|-ness here.
Attachment #8594318 -
Flags: review?(nfroyd) → review+
| Assignee | ||
Comment 3•10 years ago
|
||
Are static constructors/destructors no longer frowned upon?
Comment 4•10 years ago
|
||
(In reply to neil@parkwaycc.co.uk from comment #3)
> Are static constructors/destructors no longer frowned upon?
Static constructors at global scope are frowned upon, but static constructors at function scope are OK, since they won't execute until the function is called. (Indeed, that's how we got rid of a number of global-scope static constructors: moving them to function scope.)
| Assignee | ||
Comment 5•10 years ago
|
||
So, this only compiles under MSVC because it doesn't follow C++ rules on initialising arrays (they are copy-initialised so they need a copy constructor, sigh). I could add a default move constructor but I would have to #ifdef it out for MSVC as it doesn't understand that.
I looked into an alternative approach which was to ensure that NS_LITERAL_CSTRING was only passed actual literals, but I found a couple of places that forward it a template parameter:
> template <size_t LEN>
> nsresult Dispatch(const char (&taskThreadName)[LEN])
> {
> static_assert(LEN <= 15,
> "Thread name must be no more than 15 characters");
> return Dispatch(NS_LITERAL_CSTRING(taskThreadName));
> }
>
> nsresult Dispatch(const nsACString& taskThreadName);
GetCachedStatement does something similar. Interestingly RegisterDefineDOMInterface does something similar, but as it's dealing with wide characters it has to use nsLiteralString directly, so maybe Dispatch and GetCachedStatement should be using nsLiteralCString.
| Assignee | ||
Comment 6•10 years ago
|
||
Sorry about the scope creep, thus the second set of eyes.
Attachment #8594318 -
Attachment is obsolete: true
Attachment #8600576 -
Flags: review?(nfroyd)
Attachment #8600576 -
Flags: review?(ehsan)
Comment 7•10 years ago
|
||
Comment on attachment 8600576 [details] [diff] [review]
1155963.diff
Review of attachment 8600576 [details] [diff] [review]:
-----------------------------------------------------------------
::: accessible/atk/Platform.cpp
@@ +360,5 @@
> return sShouldEnable;
> #endif
>
> //check gconf-2 setting
> +#define sGconfAccessibilityKey "/desktop/gnome/interface/accessibility"
Nit: please call this GCONF_A11Y_KEY or some such.
::: dom/indexedDB/ActorsParent.cpp
@@ +209,5 @@
>
> // The length of time that idle threads will stay alive before being shut down.
> const uint32_t kConnectionThreadIdleMS = 30 * 1000; // 30 seconds
>
> +#define kSavepointClause "SAVEPOINT sp;"
Here and elsewhere too.
::: toolkit/xre/nsUpdateDriver.cpp
@@ -93,5 @@
> -static const char kUpdaterApp[] = "updater.app";
> -#endif
> -#if defined(XP_UNIX) && !defined(XP_MACOSX)
> -static const char kUpdaterPNG[] = "updater.png";
> -#endif
Please don't change the conditions under which these names are defined.
Attachment #8600576 -
Flags: review?(ehsan) → review+
Comment 8•10 years ago
|
||
Comment on attachment 8600576 [details] [diff] [review]
1155963.diff
Review of attachment 8600576 [details] [diff] [review]:
-----------------------------------------------------------------
Whoops, I r+'d this yesterday, but forgot to submit!
Attachment #8600576 -
Flags: review?(nfroyd) → review+
| Assignee | ||
Comment 9•10 years ago
|
||
This apparently broke b2g builds, so backed out in https://hg.mozilla.org/integration/mozilla-inbound/rev/e43f6dc95fc5
https://treeherder.mozilla.org/logviewer.html#?job_id=9863733&repo=mozilla-inbound
Flags: needinfo?(neil)
Comment 11•10 years ago
|
||
| Assignee | ||
Comment 12•10 years ago
|
||
(In reply to Pulsebot from comment #11)
> https://hg.mozilla.org/integration/mozilla-inbound/rev/045afee26805
(With bustage fix obviously. Also I forgot that pulsebot would spam the bug for me, so now there's an unnecssary extra comment.)
Flags: needinfo?(neil)
Comment 13•10 years ago
|
||
Status: NEW → RESOLVED
Closed: 10 years ago
status-firefox41:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
Updated•10 years ago
|
Assignee: nobody → neil
Updated•5 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•