Closed
Bug 302092
Opened 19 years ago
Closed 3 years ago
Bad variable naming (kSourceURLLength) for a variable that isn't a constant
Categories
(Core :: Widget: Win32, defect, P2)
Tracking
()
RESOLVED
FIXED
99 Branch
| Tracking | Status | |
|---|---|---|
| firefox99 | --- | fixed |
People
(Reporter: daniel_atallah, Assigned: rkraesig)
Details
Attachments
(2 files, 3 obsolete files)
|
5.59 KB,
patch
|
timeless
:
review+
neil
:
superreview+
|
Details | Diff | Splinter Review |
|
48 bytes,
text/x-phabricator-request
|
Details | Review |
(17:07:09) timelyx: datallah: lastly, could you file a bug about kSourceURLLength (17:07:13) timelyx: that variable is terribly named (17:07:59) datallah: timelyx: the bug would be that it is misnamed? (17:08:04) timelyx: yes (17:08:26) timelyx: the 'k' is really wrong. dropping the k prefix and lowercasing the next letter would be fine
Comment on attachment 190459 [details] [diff] [review] rename kSourceURLLength variable to sourceURLLength since it isn't a constant >Index: nsDataObj.cpp >@@ -1200,7 +1200,7 @@ nsDataObj :: BuildPlatformHTML ( const c >- const PRInt32 kSourceURLLength = mSourceURL.Length(); this line should probably have one more space before the = sign since for some reason the code is trying to keep them at the same position: >+ const PRInt32 sourceURLLength = mSourceURL.Length(); > const PRInt32 kNumberLength = strlen(numPlaceholder); > > const PRInt32 kTotalHeaderLen = strlen(startHTMLPrefix) +
Attachment #190459 -
Flags: superreview?(neil.parkwaycc.co.uk)
Attachment #190459 -
Flags: review?(timeless)
Attachment #190459 -
Flags: review+
Comment 3•19 years ago
|
||
Comment on attachment 190459 [details] [diff] [review] rename kSourceURLLength variable to sourceURLLength since it isn't a constant >- const PRInt32 kSourceURLLength = mSourceURL.Length(); >+ const PRInt32 sourceURLLength = mSourceURL.Length(); > const PRInt32 kNumberLength = strlen(numPlaceholder); > > const PRInt32 kTotalHeaderLen = strlen(startHTMLPrefix) + Well if you're going to be picky then kTotalHeaderLen isn't a constant either, and I don't see why you're still declaring it const. And all the strings should be in arrays so you can use sizeof instead of strlen. Also you didn't keep the = signs lined up.
| Reporter | ||
Comment 4•19 years ago
|
||
After spending a ton of time trying to understand the various string types, I came to the conclusion that at the very least the usage in this method wasn't consistent. I made all the "static" strings actually static to the method and also pre-calculated the the static part of the header length. If there is a more preferred way to do this, I'd love to know.
| Reporter | ||
Updated•19 years ago
|
Attachment #190459 -
Attachment is obsolete: true
Attachment #190713 -
Flags: review?(timeless)
Comment on attachment 190713 [details] [diff] [review] Implementation of Neil's suggestions (and more) >RCS file: /cvsroot/mozilla/widget/src/windows/nsDataObj.cpp,v >diff -u -d -p -r1.68 nsDataObj.cpp it seems like all these should be PRUint32 instead of PRInt32, no? >+ static const PRInt32 kHeaderLen = sizeof(kStartHTMLPrefix) - 1 + >+ sizeof(kEndHTMLPrefix) - 1 + >+ sizeof(kStartFragPrefix) - 1 + >+ sizeof(kEndFragPrefix) - 1 + >+ sizeof(kEndFragTrailer) - 1 + >+ (4 * (sizeof(kNumPlaceholder) - 1)); >+ PRInt32 totalHeaderLen = kHeaderLen; >+ PRInt32 startHTMLOffset = totalHeaderLen; > PRInt32 startFragOffset = startHTMLOffset ... > PRInt32 endFragOffset = startFragOffset ... > PRInt32 endHTMLOffset = endFragOffset
Attachment #190713 -
Flags: superreview?(neil.parkwaycc.co.uk)
Attachment #190713 -
Flags: review?(timeless)
Attachment #190713 -
Flags: review+
Comment 6•19 years ago
|
||
Comment on attachment 190713 [details] [diff] [review] Implementation of Neil's suggestions (and more) >+ clipboardString.Append(kStartHTMLPrefix); > clipboardString.Append(nsPrintfCString("%08u", startHTMLOffset)); > >+ clipboardString.Append(kEndHTMLPrefix); > clipboardString.Append(nsPrintfCString("%08u", endHTMLOffset)); > >+ clipboardString.Append(kStartFragPrefix); > clipboardString.Append(nsPrintfCString("%08u", startFragOffset)); > >+ clipboardString.Append(kEndFragPrefix); > clipboardString.Append(nsPrintfCString("%08u", endFragOffset)); I'm wondering whether this couldn't be done in one big nsPrintfCString. >+ clipboardString.Append(kEndFragTrailer); > >+ clipboardString.Append(kHtmlHeaderString); >+ clipboardString.Append(kFragmentHeaderString); Hmm... I suppose you could switch to #define and use clipboardString.AppendLiteral(kEndFragTrailer kHtmlHederString kFragmentHeaderString); but I guess that's less readable. >+ clipboardString.Append(kTrailingString); I'd consider using AppendLiteral anyway, except that it's not documented to work on static const char arrays...
Attachment #190713 -
Flags: superreview?(neil) → superreview+
| Reporter | ||
Comment 8•17 years ago
|
||
(In reply to comment #7) > Daniel, were you still planning on working on this? > I haven't had a working build setup for this in a while, so if someone else wants to take care of this that'd be great.
Updated•15 years ago
|
Assignee: win32 → nobody
QA Contact: ian → win32
Updated•3 years ago
|
Assignee: nobody → rkraesig
Updated•3 years ago
|
Severity: minor → S4
Priority: -- → P2
| Assignee | ||
Comment 9•3 years ago
|
||
Perform a straightforward rename: constants get a "k-" prefix; non-constants
have it removed. No functional changes.
| Assignee | ||
Comment 10•3 years ago
|
||
Perform some additional cleanup to bring the code closer to modern
standards.
Depends on D138087
| Assignee | ||
Comment 11•3 years ago
•
|
||
Following the original diff [1], break the header into constexpr and
non-constant portions, and compute their length separately.
This will almost certainly be done by the compiler anyway.
(If approved, this commit will be squashed into the previous.)
[0] https://bug302092.bmoattachments.org/attachment.cgi?id=190713
Depends on D138088
Updated•3 years ago
|
Attachment #9262763 -
Attachment description: WIP: Bug 302092 - [2/2] modernization and cleanup → WIP: Bug 302092 - [2/2] Modernization and cleanup
Updated•3 years ago
|
Attachment #9262764 -
Attachment description: WIP: Bug 302092 - [3/2] constexpr all the things → WIP: Bug 302092 - [3/2] Constexpr all the things
Updated•3 years ago
|
Attachment #9262762 -
Attachment description: WIP: Bug 302092 - [1/2] Rename variables → Bug 302092 - [1/2] Rename variables r=handyman
Updated•3 years ago
|
Attachment #9262763 -
Attachment description: WIP: Bug 302092 - [2/2] Modernization and cleanup → Bug 302092 - [2/2] Modernization and cleanup r=handyman
Updated•3 years ago
|
Attachment #9262764 -
Attachment description: WIP: Bug 302092 - [3/2] Constexpr all the things → Bug 302092 - [3/2] Constexpr all the things r=handyman
Updated•3 years ago
|
Attachment #9262763 -
Attachment is obsolete: true
Updated•3 years ago
|
Attachment #9262764 -
Attachment is obsolete: true
Updated•3 years ago
|
Attachment #9262762 -
Attachment description: Bug 302092 - [1/2] Rename variables r=handyman → Bug 302092 - Perform various minor modernizations r=handyman
Comment 12•3 years ago
|
||
Pushed by rkraesig@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/37fd03a3eebc Perform various minor modernizations r=handyman
Comment 13•3 years ago
|
||
| bugherder | ||
Status: NEW → RESOLVED
Closed: 3 years ago
status-firefox99:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 99 Branch
You need to log in
before you can comment on or make changes to this bug.
Description
•