Closed
Bug 1171018
Opened 9 years ago
Closed 9 years ago
nsTXTToHTMLConv.cpp: Value stored to 'cursor' is never read
Categories
(Core :: Networking, defect)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: Sylvestre, Unassigned, Mentored)
Details
(Keywords: clang-analyzer, Whiteboard: [good first bug][lang=C++])
Attachments
(4 files, 2 obsolete files)
1.14 KB,
patch
|
Details | Diff | Splinter Review | |
963 bytes,
patch
|
Details | Diff | Splinter Review | |
1.07 KB,
patch
|
Details | Diff | Splinter Review | |
1.03 KB,
patch
|
Details | Diff | Splinter Review |
Found by scan-build: https://people.mozilla.org/~sledru/reports/fx-scan-build/report-nsTXTToHTMLConv.cpp-OnDataAvailable-42-1.html#EndPath https://dxr.mozilla.org/mozilla-central/source/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp?from=nsTXTToHTMLConv.cpp#174
Hi Sylvestre I would like to take this as my first bug. The bug description seems self explanatory for the fix. However, could you guide me as to how I go about testing and submitting my changes ? Thanks!
Reporter | ||
Comment 2•9 years ago
|
||
I don't think this requires testing (besides compiling the code). You should have a look to this doc to create a patch: https://developer.mozilla.org/docs/Mercurial_FAQ
Comment 3•9 years ago
|
||
Hi Sylvestre, I would love to fix my first bug for mozilla, I am proficient in c++. Could you tell me how to compile this. The sole file won't compile due to other dependencies.
Comment 4•9 years ago
|
||
What I understand from the code is the you need not set `cursor=0;` as in the next iteration it is reset to 0, is that a valid fix? If yes how do I send a patch?
Comment 5•9 years ago
|
||
(In reply to sumith1896 from comment #4) > What I understand from the code is the you need not set `cursor=0;` as in > the next iteration it is reset to 0, is that a valid fix? Because it's not used in the rest of the block, clang-analyzer warns you of that. Removing that instruction would probably work, with a comment, that its value shouldn't be used from then on. > If yes how do I send a patch? A comprehensive guide to contributing is found at: http://codefirefox.com/ Guide to building Firefox: https://developer.mozilla.org/en-US/docs/Simple_Firefox_build
Comment 6•9 years ago
|
||
I'm on it, thanks
I have attached the patch which *should have* removed the unused variable cursor from nsTXTToHTMLConv::OnDataAvailable():nsTXTToHTMLConv.cpp. I am not sure who would be reviewing it so I left the reviewer field blank in the commit message. Does this patch do the required change or is there something else that needs to be handled?
Somehow my changes were not getting shown in the commit. Trying it one more time to make sure I got it. Sorry about the spam
Attachment #8616481 -
Attachment is obsolete: true
Attachment #8616482 -
Attachment is obsolete: true
Comment 10•9 years ago
|
||
Resync'ed the source code to make sure the removal of cursor shows the change
Comment 11•9 years ago
|
||
(In reply to Vikram from comment #10) > Created attachment 8616498 [details] [diff] [review] > Bug1171018_ver2.patch > > Resync'ed the source code to make sure the removal of cursor shows the change Better add a comment to not use cursor for thereon, suggesting that it has not been reset
Comment 12•9 years ago
|
||
Comment on attachment 8616498 [details] [diff] [review] Bug1171018_ver2.patch Review of attachment 8616498 [details] [diff] [review]: ----------------------------------------------------------------- honestly. I'm getting tired of this category of patch. basically they all follow the same pattern sPtr -= k; sLen -= k; // compiler warns that sLen is unused someone submits a patch to remove sLen -=45 .. leaving inconsistent string data and creating a footgun in the code. another instance of this class of bug satisfied clang by adding "sLen;" afterwards. I'm ok with doing it again, but frankly this is coding around a lack of flexibility in the tool. It should support explicit annotations or an external exception/suppression file. The code itself is frankly better as is - the only value is in getting a better report from the analyzer to see real issues. I'd rather see work go into making the tool work better than fixing non problems in gecko.
Reporter | ||
Comment 13•9 years ago
|
||
(In reply to Patrick McManus [:mcmanus] from comment #12) > Comment on attachment 8616498 [details] [diff] [review] > Bug1171018_ver2.patch > > Review of attachment 8616498 [details] [diff] [review]: > ----------------------------------------------------------------- > > honestly. I'm getting tired of this category of patch. Sorry about that. I didn't realize that most of them are most in "your" code. > basically they all follow the same pattern > > sPtr -= k; > sLen -= k; > > // compiler warns that sLen is unused I don't see a problem in removing useless code but you are the reviewer. For now, scan-build (built on top of clang analyzer) does not allow to ignore a warning. I will see how to silent these bugs.
Comment 14•9 years ago
|
||
(In reply to Sylvestre Ledru [:sylvestre] from comment #13) > I don't see a problem in removing useless code but you are the reviewer. > its just a maintenance problem. the string structure is now in a half valid state if that code is removed. If someone comes along and modifies the function this is unexpected and they could easily introduce a serious security bug. Its the same reason its a bad idea to do release/free(x) without assigning x to NULL in the middle of a function.. Consistent state is valuable. removing the code doesn't even improve performance - we know the compiler is recognizing the situation and optimizing away the assignment. otoh making the list of warnings have a better signal to noise ratio is a valuable thing. I just would prefer we do that in ways that don't change the intentional state of the gecko code. (annotations, suppression files, etc..) > For now, scan-build (built on top of clang analyzer) does not allow to > ignore a warning. > I will see how to silent these bugs.
Comment 15•9 years ago
|
||
I was lured to this "Bug" at Mozilla Day in Zurich today. Since I recently decided I wanted to learn some C++ I was attracted by the label "good first bug" and this looks like a nice trivial exercise to practice creating a patch, compiling, submitting etc. Can we close the bug? It isn't really a bug because, as you say, the compiler throws the unnecessary assignment out of the object code? If we can't make the analyzer ignore the issue, perhaps it would be sufficient to comment the instruction in the source code to help a future developer consider the prior state of the variable before reusing it and add a link to this Bug ticket so that it doesn't resurface?
Comment 16•9 years ago
|
||
Hi Sylvestre, I would like to take this bug as my first fix. Could you please assign it so that i can start working on it? Thank You
Comment 17•9 years ago
|
||
Here I have taken comment 11 into consideration and commented out the the line of code stating that it is never read and has been taken out.
Comment 18•9 years ago
|
||
Reporter | ||
Comment 19•9 years ago
|
||
Sorry, I am going to wontfix this bug because of comment #12. I have other similar bugs, please drop me an email if you are interested.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•