Closed Bug 1212068 Opened 9 years ago Closed 8 years ago

Fix "warning C4018: '<': signed/unsigned mismatch" in mailnews/import and mailnews/mapi

Categories

(MailNews Core :: Import, defect)

x86
Windows
defect
Not set
trivial

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 51.0

People

(Reporter: ssitter, Assigned: ssitter)

Details

Attachments

(2 files)

> mailnews/import/outlook/src/nsOutlookMail.cpp(652): warning C4018: '<': signed/unsigned mismatch > mailnews/mapi/mapihook/src/msgMapiHook.cpp(720): warning C4018: '<': signed/unsigned mismatch > mailnews/mapi/mapihook/src/msgMapiImp.cpp(666): warning C4018: '<': signed/unsigned mismatch
> mailnews/import/outlook/src/nsOutlookMail.cpp(652): warning C4018: '<': signed/unsigned mismatch Change type to uint32_t to match sa->cValues and the required target type in AddListCardColumnsToRow() > mailnews/mapi/mapihook/src/msgMapiHook.cpp(720): warning C4018: '<': signed/unsigned mismatch Cast to int32_t to match the type returned by nsString.Find() to silence warning > mailnews/mapi/mapihook/src/msgMapiImp.cpp(666): warning C4018: '<': signed/unsigned mismatch Change type to size_t to match the type returned and consumed by nsTArray<nsCString> Remove some unused variables reported in the touched files. With this patch I now get 0 compiler warnings for mailnews/ with VS2015.
Attachment #8670459 - Flags: review?(Pidgeot18)
I'd like to ask you to tell me if I have to request review from a different reviewer for the Mapi part of the patch because I only chose the one that was suggested by Bugzilla for the Import component.
Only one reviewer is sufficient.
Comment on attachment 8670459 [details] [diff] [review] Fix warning C4018: '<': signed/unsigned mismatch Review of attachment 8670459 [details] [diff] [review]: ----------------------------------------------------------------- ::: mailnews/import/outlook/src/nsOutlookMail.cpp @@ +640,5 @@ > } > > LPENTRYID lpEid; > ULONG cbEid; > + uint32_t idx; Why not ULONG? It matches the variable being compared to exactly. ::: mailnews/mapi/mapihook/src/msgMapiImp.cpp @@ +662,5 @@ > ExtractAllAddresses(recipients, UTF16ArrayAdapter<>(names), > UTF16ArrayAdapter<>(addresses)); > > + size_t numAddresses = names.Length(); > + for (size_t i = 0; i < numAddresses; i++) Would size_type work? That is the type returned by nsTArray.Length().
Attachment #8670459 - Flags: review?(Pidgeot18) → review?(jorgk)
OS: Unspecified → Windows
Hardware: Unspecified → x86
Comment on attachment 8670459 [details] [diff] [review] Fix warning C4018: '<': signed/unsigned mismatch Review of attachment 8670459 [details] [diff] [review]: ----------------------------------------------------------------- Stefan, can you answer these questions and then we land this. ::: mailnews/mapi/mapihook/src/msgMapiImp.cpp @@ +662,5 @@ > ExtractAllAddresses(recipients, UTF16ArrayAdapter<>(names), > UTF16ArrayAdapter<>(addresses)); > > + size_t numAddresses = names.Length(); > + for (size_t i = 0; i < numAddresses; i++) Aceman, you have this in your patch: for (uint32_t i = 0; i < numAddresses; i++)
Flags: needinfo?(ssitter)
(In reply to Jorg K (GMT+2, PTO during summer) from comment #5) > > + size_t numAddresses = names.Length(); > > + for (size_t i = 0; i < numAddresses; i++) > > Aceman, you have this in your patch: > for (uint32_t i = 0; i < numAddresses; i++) Yes, because I didn't look up nsTArray, just matched i to numAddresses. But if size_type does not compile, size_t is fine too.
Let's land this with size_t here and ULONG above: https://msdn.microsoft.com/en-us/library/cc815398(v=office.12).aspx
Comment on attachment 8670459 [details] [diff] [review] Fix warning C4018: '<': signed/unsigned mismatch I'll make it ULONG and land this now. Thanks.
Flags: needinfo?(ssitter)
Attachment #8670459 - Flags: review?(jorgk) → review+
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 51.0
(In reply to :aceman from comment #4) > ::: mailnews/import/outlook/src/nsOutlookMail.cpp > @@ +640,5 @@ > > + uint32_t idx; > > Why not ULONG? It matches the variable being compared to exactly. See comment 1. I think I choose uint32_t because that type is used to capture sa->cValues in line 651 and the call to AddListCardColumnsToRow() expects uint32_t as well. But ULONG should work too unless you have platform where ULONG is 64-bit and sa->cValues is larger than UINT32_MAX. But in this case integer truncation would happen independent if my solution or your solution is used.
ULONG is the datatype cValues, see https://msdn.microsoft.com/en-us/library/cc815398(v=office.12).aspx I'll add a patch do it 100% correctly.
Attached patch Follow up patch.Splinter Review
If we care enough we can fix it like this.
Attachment #8780831 - Flags: review?(acelists)
Comment on attachment 8780831 [details] [diff] [review] Follow up patch. Review of attachment 8780831 [details] [diff] [review]: ----------------------------------------------------------------- OK
Attachment #8780831 - Flags: review?(acelists) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: