Closed Bug 182265 Opened 22 years ago Closed 12 years ago

functions return negative values for nsresult

Categories

(MailNews Core :: MIME, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: mozilla-bugs, Unassigned)

References

(Blocks 1 open bug)

Details

mimedrft.cpp: In function `nsresult mime_decompose_file_init_fn(void*, MimeHeaders*)': mimedrft.cpp:1749: warning: return of negative value `-1' to `nsresult' mimedrft.cpp:1749: warning: argument of negative value `-1' to `unsigned int' mimedrft.cpp:1788: warning: return of negative value `-1000' to `nsresult' mimedrft.cpp:1788: warning: argument of negative value `-1000' to `unsigned int ' mimedrft.cpp:1805: warning: return of negative value `-1000' to `nsresult' mimedrft.cpp:1805: warning: argument of negative value `-1000' to `unsigned int ' mimedrft.cpp:1814: warning: return of negative value `-1000' to `nsresult' mimedrft.cpp:1814: warning: argument of negative value `-1000' to `unsigned int ' mimedrft.cpp:1932: warning: return of negative value `-1000' to `nsresult' mimedrft.cpp:1932: warning: argument of negative value `-1000' to `unsigned int ' mimedrft.cpp:1936: warning: return of negative value `-1000' to `nsresult' mimedrft.cpp:1936: warning: argument of negative value `-1000' to `unsigned int ' mimedrft.cpp:1942: warning: return of negative value `-1001' to `nsresult' mimedrft.cpp:1942: warning: argument of negative value `-1001' to `unsigned int ' mimedrft.cpp:1971: warning: return of negative value `-1000' to `nsresult' mimedrft.cpp:1971: warning: argument of negative value `-1000' to `unsigned int ' mimedrft.cpp: In function `nsresult mime_decompose_file_output_fn(char*, int, void*)': mimedrft.cpp:1987: warning: return of negative value `-1' to `nsresult' mimedrft.cpp:1987: warning: argument of negative value `-1' to `unsigned int' mimedrft.cpp:1995: warning: return of negative value `-1' to `nsresult' mimedrft.cpp:1995: warning: argument of negative value `-1' to `unsigned int' mimedrft.cpp:2001: warning: return of negative value `-1002' to `nsresult' mimedrft.cpp:2001: warning: argument of negative value `-1002' to `unsigned int ' mimedrft.cpp: In function `nsresult mime_decompose_file_close_fn(void*)': mimedrft.cpp:2013: warning: return of negative value `-1' to `nsresult' mimedrft.cpp:2013: warning: argument of negative value `-1' to `unsigned int' As I understand this is happening because in rev 1.69 <ducarroz@netscape.com> 12 Apr 2001 21:34 (which refers to bug 28348 bug 52329, but attachments on those bugs do not seem to have such a change) sime functions that used to return an int were marked as returning nsresult instead, without changing the actual return statements. Should those negative values be replaced with some meaningful NS_ERROR_*? Shoud "return 0" in those functions be replaced with "return NS_OK"?
Another instances of the same issue: nsMsgComposeSecure.cpp: In member function `nsresult nsMsgComposeSecure::MimeInitMultipartSigned(int, nsIMsgSendReport*)': nsMsgComposeSecure.cpp:554: warning: assignment of negative value `-1' to ` nsresult' nsMsgComposeSecure.cpp:554: warning: argument of negative value `-1' to ` unsigned int' nsMsgComposeSecure.cpp: In member function `nsresult nsMsgComposeSecure::MimeFinishMultipartSigned(int, nsIMsgSendReport*)': nsMsgComposeSecure.cpp:718: warning: assignment of negative value `-1' to ` nsresult' nsMsgComposeSecure.cpp:718: warning: argument of negative value `-1' to ` unsigned int' nsMsgComposeSecure.cpp:794: warning: assignment of negative value `-1' to ` nsresult' nsMsgComposeSecure.cpp:794: warning: argument of negative value `-1' to ` unsigned int' nsMsgComposeSecure.cpp: In member function `virtual nsresult nsMsgComposeSecure::MimeCryptoWriteBlock(const char*, int)': nsMsgComposeSecure.cpp:1027: warning: return of negative value `-1' to ` nsresult' nsMsgComposeSecure.cpp:1027: warning: argument of negative value `-1' to ` unsigned int' nsMsgComposeSecure.cpp: In function `nsresult mime_encoder_output_fn(const char*, int, void*)': nsMsgComposeSecure.cpp:1106: warning: return of negative value `-1' to ` nsresult' nsMsgComposeSecure.cpp:1106: warning: argument of negative value `-1' to ` unsigned int' In many cases the problem seems to be that there are error variables/macros MK_OUT_OF_MEMORY, MK_MIME_ERROR_WRITING_FILE, etc that are used in "return" statements as an nsresult, but are defined to be -1.
Summary: mimedrft.cpp: function return negative values for nsresult → functions return negative values for nsresult
Blocks: buildwarning
Product: MailNews → Core
Assignee: ducarroz → nobody
QA Contact: yulian → mime
Product: Core → MailNews Core
I this still relevant?
Seems to be related to our discussion in bug 210927.
Yes, but it is a different file and I do not remember seeing such compiler warnings in current tree.
The function mime_decompose_file_init_fn mentioned in comment 0 is of type int today, not nsresult. So returning plain 0 or -1 seems fine. The report seems outdated.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.