Shush warning in alignment code.

MSVC doesn't like unary - on unsigned numbers. Also switch ssl3_read_n's
version to uintptr_t to match the write half. This gets us closer to clearing
through C4311 violations. (The remaining one is in asn1_add_error which can go
after verifying that most of asn1_mac.h is safe to drop.)

Change-Id: Idb33dda8863bf1a3408b14d5513a667338311b6b
Reviewed-on: https://boringssl-review.googlesource.com/4255
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6c95b7e..3baad51 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@
               # 'unsigned long', signed/unsigned mismatch
       "C4267" # conversion from 'size_t' to 'int', possible loss of data
       "C4311" # 'type cast' : pointer truncation from 'uint8_t *' to 'long'
-              # TODO(davidben): Fix the s3_pkt.c's alignment code to avoid this.
+              # TODO(davidben): Remove this warning once asn1_add_error is gone.
       "C4371" # layout of class may have changed from a previous version of the
               # compiler due to better packing of member '...'
       "C4388" # signed/unsigned mismatch
diff --git a/ssl/s3_pkt.c b/ssl/s3_pkt.c
index 436e830..80eb7bd 100644
--- a/ssl/s3_pkt.c
+++ b/ssl/s3_pkt.c
@@ -133,7 +133,7 @@
    * bytes may be stored in |rbuf| (plus |s->packet_length| bytes if |extend|
    * is one.) */
   int i, len, left;
-  long align = 0;
+  uintptr_t align = 0;
   uint8_t *pkt;
   SSL3_BUFFER *rb;
 
@@ -148,8 +148,8 @@
 
   left = rb->left;
 
-  align = (long)rb->buf + SSL3_RT_HEADER_LENGTH;
-  align = (-align) & (SSL3_ALIGN_PAYLOAD - 1);
+  align = (uintptr_t)rb->buf + SSL3_RT_HEADER_LENGTH;
+  align = (0 - align) & (SSL3_ALIGN_PAYLOAD - 1);
 
   if (!extend) {
     /* start with empty packet ... */
@@ -604,7 +604,7 @@
   } else {
     align = (uintptr_t)wb->buf + SSL3_RT_HEADER_LENGTH;
   }
-  align = (-align) & (SSL3_ALIGN_PAYLOAD - 1);
+  align = (0 - align) & (SSL3_ALIGN_PAYLOAD - 1);
   uint8_t *out = wb->buf + align;
   wb->offset = align;
   size_t max_out = wb->len - wb->offset;