Use typedef for the length of mozilla::pkix::Input/Reader for safer casting

RESOLVED FIXED in mozilla36

Status

()

RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: briansmith, Assigned: briansmith)

Tracking

Trunk
mozilla36
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Created attachment 8508064 [details] [diff] [review]
size_type.patch

Let's say you want to compute the diference of lengths of to Inputs:

   Input::size_type diff;
   if (a.GetLength() > b.GetLength()) {
     // The cast is required because operator- returns a signed type.
     diff = static_cast<Input::size_type>(a.GetLength() - b.GetLength());
   }

We could just use "uint16_t" but that would be problematic if/when we need to change the maximum length of Input/Reader.
Attachment #8508064 - Flags: review?(mmc)
Attachment #8508064 - Flags: review?(mmc) → review+
https://hg.mozilla.org/mozilla-central/rev/9d83b21c98e8
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.