Closed Bug 1427871 Opened 8 years ago Closed 8 years ago

Consider removing nsCRT::strncmp(const char*...)

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1427023

People

(Reporter: erahm, Unassigned)

Details

+++ This bug was initially created as a clone of Bug #1427023 +++ I noticed in bug 1427023 that we have two slightly different implementations of `nsCRT::strncmp(const char*, ...)`. One that takes a signed max length [1] and one that takes an unsigned max length [2]. One is "optimized" and doesn't check for null, but if the first chars don't match it will eventually check for null. We should probably get rid of one of them. Arguably we should just switch to standard `strncmp`, but we'd have to check that the current usage doesn't rely on the null checks. [1] https://searchfox.org/mozilla-central/rev/51cd1093c5c2113e7b041e8cc5c9bf2186abda13/xpcom/ds/nsCRT.h#70-79 [2] https://searchfox.org/mozilla-central/rev/51cd1093c5c2113e7b041e8cc5c9bf2186abda13/xpcom/ds/nsCRT.h#45-49
(In reply to Eric Rahm [:erahm] (please no mozreview requests) from comment #0) > Arguably we should just switch to > standard `strncmp`, but we'd have to check that the current usage doesn't > rely on the null checks. I guess there's bug 1308103 that proposed switching to `strncmp`, but then pivoted to "use something safe" which I guess means nsString and friends.
Fixed by bug 1427023.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.