Check or remove rv from GetUrlForUri() call, in nsMsgAttachmentHandler.cpp
Categories
(MailNews Core :: Composition, defect)
Tracking
(Not tracked)
People
(Reporter: sgautherie, Unassigned)
References
()
Details
(Keywords: good-first-bug, Whiteboard: [patchlove][lang=c++])
Attachments
(2 files, 2 obsolete files)
2.25 KB,
patch
|
squib
:
review+
|
Details | Diff | Splinter Review |
4.05 KB,
patch
|
Details | Diff | Splinter Review |
(In reply to neil@parkwaycc.co.uk from bug 736789 comment #22) > > rv = messageService->GetUrlForUri(uri.get(), getter_AddRefs(aURL), nsnull); > [I wonder why kaie never checked this rv] Right. *** { 588 nsCOMPtr<nsIURI> aURL; 589 rv = messageService->GetUrlForUri(uri.get(), getter_AddRefs(aURL), nsnull); 590 591 rv = NS_NewInputStreamChannel(getter_AddRefs(m_converter_channel), aURL, nsnull); 592 if (NS_FAILED(rv)) 593 goto done; } *** Maybe check the other calls too? http://mxr.mozilla.org/comm-central/search?string=GetUrlForUri&case=1&find=%2Fmail "Found 23 matching lines in 22 files"
Comment 1•12 years ago
|
||
please please be careful - injudicious checking of return values are what led to the original bug.
Reporter | ||
Comment 2•12 years ago
|
||
Sure, I'm not saying that rv must be checked: just removing rv if the other option. It's only the unchecked rv that looks "bad". Yet, in this case, I would assume it should be checked: I assume that currently it does something like "if GetUrlForUri() fails, then NS_NewInputStreamChannel(null) fails too", doesn't it?
Comment 3•12 years ago
|
||
(In reply to Serge Gautherie (:sgautherie) from comment #2) > Sure, I'm not saying that rv must be checked: just removing rv if the other > option. > It's only the unchecked rv that looks "bad". > > Yet, in this case, I would assume it should be checked: > I assume that currently it does something like "if GetUrlForUri() fails, > then NS_NewInputStreamChannel(null) fails too", doesn't it? I'm referring specifically to : Maybe check the other calls too? http://mxr.mozilla.org/comm-central/search?string=GetUrlForUri&case=1&find=%2Fmail "Found 23 matching lines in 22 files"
Reporter | ||
Comment 4•12 years ago
|
||
(In reply to David :Bienvenu from comment #3) > I'm referring specifically to : > > Maybe check the other calls too? Ah! I meant "1- check whether existing rv are actually used, 2- maybe check whether calls without rv should have one" (not that all calls must have a checked rv) ;-)
Comment 5•12 years ago
|
||
Is someone working on it right now? If not, I would like to work on this bug :-)
Comment 6•12 years ago
|
||
(In reply to Atul Jangra from comment #5) > Is someone working on it right now? If not, I would like to work on this bug > :-) No so please take it. you can ask questions here, but it's faster on irc.mozilla.org in #maildev.
Comment 7•12 years ago
|
||
I should also rename aURL to url, as this is not our convention. aURL is generally used as a parameter to the routine. { 588 nsCOMPtr<nsIURI> aURL; 589 rv = messageService->GetUrlForUri(uri.get(), getter_AddRefs(aURL), nsnull); 590 Usul, Bienvenu should I go for this?
Comment 8•12 years ago
|
||
Created first version of the patch. Gone through this: http://mxr.mozilla.org/comm-central/search?string=GetUrlForUri&case=1&find=%2Fmail. Looked up all the search results, and to be on safer side(as pointed out by bienvenu) I have just removed rv, where it is not used or checked. I have also renamed aURL, as pointed out in earlier comment. Obviously we need to do more, so just a Version 1 patch. Cheers!!
Comment 9•12 years ago
|
||
Comment on attachment 640849 [details] [diff] [review] First attempt Jim knows this code way better than I do. I can't review anyway - passing the review along.
Comment 10•12 years ago
|
||
a small mistake. rest all same as last one.
Comment 11•12 years ago
|
||
Thanks Usul:-)
Reporter | ||
Comment 12•12 years ago
|
||
(While here) I'm a little confused: is it expected that .idl has void whereas .cpp have NS_IMETHODIMP? { /mailnews/base/public/nsIMsgMessageService.idl * line 135 -- void GetUrlForUri(in string aMessageURI, out nsIURI aURL, in nsIMsgWindow aMsgWindow); /mailnews/imap/src/nsImapService.cpp * line 241 -- NS_IMETHODIMP nsImapService::GetUrlForUri(const char *aMessageURI, /mailnews/local/src/nsMailboxService.cpp * line 404 -- NS_IMETHODIMP nsMailboxService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL, nsIMsgWindow *aMsgWindow) /mailnews/news/src/nsNntpService.cpp * line 469 -- NS_IMETHODIMP nsNntpService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL, nsIMsgWindow *aMsgWindow) }
Reporter | ||
Comment 13•12 years ago
|
||
Comment on attachment 640983 [details] [diff] [review] Version 1 Review of attachment 640983 [details] [diff] [review]: ----------------------------------------------------------------- (In reply to Atul Jangra from comment #8) > Looked up all the search results, and to be on safer side(as pointed out by That's a good step. > bienvenu) I have just removed rv, where it is not used or checked. But I'm not fond of such simple cleanup: I meant that this should be actually analyzed and '(void)' cast should be used where we don't (want to) check the return value, even adding a comment as need be.
Reporter | ||
Updated•12 years ago
|
Comment 14•12 years ago
|
||
(In reply to Serge Gautherie (:sgautherie) from comment #13) > But I'm not fond of such simple cleanup: > I meant that this should be actually analyzed and '(void)' cast should be > used where we don't (want to) check the return value, > even adding a comment as need be. We definitely don't want to start adding more checks unless we're absolutely sure they won't return failure codes for legitimate values (i.e. stuff that works currently). We've already been bitten by overzealous error checking in similar code recently.
Comment 15•12 years ago
|
||
Comment on attachment 640983 [details] [diff] [review] Version 1 Review of attachment 640983 [details] [diff] [review]: ----------------------------------------------------------------- Clearing out review for now. I'd r+ anything that casts those return values to void, though. Like so: (void)msgService->GetUrlForUri(...); Comments might be nice, but I have no strong opinions either way for that.
Comment 16•11 years ago
|
||
Is this still active? Should it still be listed as a good first/mentored bug? I'm checking up on mentored bugs that haven't been changed in a while. Thanks!
Comment 17•11 years ago
|
||
Unassigning the bug if someone else wants to work on this :-)
Updated•11 years ago
|
Comment 18•11 years ago
|
||
I would like to work on the bug. Will upload the patch within a while.
Comment 19•11 years ago
|
||
Comment 20•11 years ago
|
||
Anyone still alive here?.. Can I take the bug?..
Comment 21•11 years ago
|
||
(In reply to Alexey Bugrov from comment #20) > Anyone still alive here?.. Can I take the bug?.. please do. Helping peeps will be available in #maildev on irc.mozilla.org ask standard8 neilaway or mconley
Updated•11 years ago
|
Comment 22•11 years ago
|
||
AFAICT, this bug is now ASSIGNED, so I'm marking it as such. This also answers lizzard's questions in comment #16, except I'm not sure sgautherie is still available for mentoring. (In reply to comment #21) Usul, do you think someone else should be written in as mentor?
Comment 23•11 years ago
|
||
(In reply to Tony Mechelynck [:tonymec] from comment #22) > AFAICT, this bug is now ASSIGNED, so I'm marking it as such. This also > answers lizzard's questions in comment #16, except I'm not sure sgautherie > is still available for mentoring. (In reply to comment #21) Usul, do you > think someone else should be written in as mentor? I don't know Serge is active in SM more than TB. I think reveiw should be redirected to say standard8 if tony doesn't find more about serge's status.
Comment 24•11 years ago
|
||
(In reply to Ludovic Hirlimann [:Usul] from comment #23) > (In reply to Tony Mechelynck [:tonymec] from comment #22) > > AFAICT, this bug is now ASSIGNED, so I'm marking it as such. This also > > answers lizzard's questions in comment #16, except I'm not sure sgautherie > > is still available for mentoring. (In reply to comment #21) Usul, do you > > think someone else should be written in as mentor? > > I don't know Serge is active in SM more than TB. I think reveiw should be > redirected to say standard8 if tony doesn't find more about serge's status. I think Serge is active in seaMonkey, but his all-around activity seems to come in bursts: see for yourself, https://bugzilla.mozilla.org/page.cgi?id=user_activity.html&action=run&who=sgautherie.bz%40free.fr&from=2013-04-13&to=2013-08-12&sort=when
Reporter | ||
Comment 25•11 years ago
|
||
Comment on attachment 778868 [details] [diff] [review] If not checked, remove rv from GetUrlForUri() call and cast it to void (Sorry for the delay.) I'm not a reviewer: passing it back to :squib. Ftr, could someone answer my comment 12? (The C++ methods do return a value. Is it expected to "silently" ignore/mask it on IDL/JS side?) You may want to re-add your s/aURL/url/ nit fix (later).
Reporter | ||
Updated•11 years ago
|
Comment 26•11 years ago
|
||
Comment on attachment 778868 [details] [diff] [review] If not checked, remove rv from GetUrlForUri() call and cast it to void Review of attachment 778868 [details] [diff] [review]: ----------------------------------------------------------------- Sorry about taking so long on this review! rs=me.
Comment 27•11 years ago
|
||
Should I also add that s/aURL/url/ fix? It was Atul Jangra who added it, not me. I didn't add it because I don't know about those conventions, I'm just trying to do my first bug. :)
Assignee | ||
Updated•10 years ago
|
Comment 28•10 years ago
|
||
(In reply to Alexey Bugrov from comment #27) > Should I also add that s/aURL/url/ fix? It was Atul Jangra who added it, not > me. I didn't add it because I don't know about those conventions, I'm just > trying to do my first bug. :) squib, I suspect this question was directed at you
Comment 29•10 years ago
|
||
It would be reasonable to do that, yes. "aFoo" means that the variable is a function parameter.
Comment 30•10 years ago
|
||
Alexey: Is this patch ready to land, or did you want to do the s/aURL/url/ fix as mentioned in comment 27?
Updated•10 years ago
|
Updated•9 years ago
|
Updated•9 years ago
|
Comment 31•9 years ago
|
||
So what I get from the comments is I should apply a (void) cast to all instances where GetUrlForUri()? I'd like to work on this bug.
Updated•9 years ago
|
Comment 32•9 years ago
|
||
No. You'll just want to merge the two most-recent patches on this bug (one of them is marked obsolete). The goal is: 1) Use a (void) cast in places where we're not checking the return value (already done in the latest patch). 2) Rename local variables named "aURL" to "url" (done in the previous patch).
Comment 33•9 years ago
|
||
To be honest, we could probably just land this patch as-is, but I didn't want to mark the patch as checkin-needed until Alexey gave the ok.
Comment 34•9 years ago
|
||
Removing myslef on all the bugs I'm cced on. Please NI me if you need something on MailNews Core bugs from me.
Comment 35•9 years ago
|
||
Is anyone working on this right now? If not, I would like to work on this bug.
Comment 36•9 years ago
|
||
Looks abandoned, so feel free to dust it off! Instructions in comment 32
Comment 37•9 years ago
|
||
I think the patch is basically done (see comment 33), but it'd be helpful if someone could check to see if we missed anything before landing.
Comment 38•8 years ago
|
||
1) Used (void) cast in places where we're not checking the return value. 2) Renamed local variables named "aURL" to "url".
Updated•5 years ago
|
Updated•4 years ago
|
Updated•2 years ago
|
Comment 39•7 months ago
|
||
The file nsMsgAttachmentHandler.cpp does not exist anymore.
I have found cases of aUri should these be named to uri?
as of the rv variable from what i found all the places seem to check if it succeed, will do further inspections
I have also found one case of aUrl in the file mimedrft.cpp which i have renamed to url
Comment 40•7 months ago
|
||
aUri was in nsMsgComposeContentHandler.cpp @ line 102
I've also found two cases where the return value isnt being checked
nsMsgComposeService.cpp @ line 784
rv = inStream->Read(readBuf + readOffset, maxReadCount, &readCount);
nsMsgCompose.cpp
rv = GetMsgDBHdrFromURI(msgURI, getter_AddRefs(msgHdr));
Comment 41•7 months ago
|
||
wondering if we should check them instead of simply casting them into void
Comment 42•7 months ago
|
||
all mentions of GetUrlForUri()'s return value is checked
Comment 43•7 months ago
|
||
i have done the required changes to the above mentioned return values if anyone would like to add anything please do.
will be posting the diff after a confirmation
Description
•