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>
This commit is contained in:
David Benjamin 2015-04-06 20:31:44 -04:00 committed by Adam Langley
parent ff9c74f6f4
commit ef4962f5a3
2 changed files with 5 additions and 5 deletions

View File

@ -27,7 +27,7 @@ elseif(MSVC)
# 'unsigned long', signed/unsigned mismatch # 'unsigned long', signed/unsigned mismatch
"C4267" # conversion from 'size_t' to 'int', possible loss of data "C4267" # conversion from 'size_t' to 'int', possible loss of data
"C4311" # 'type cast' : pointer truncation from 'uint8_t *' to 'long' "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 "C4371" # layout of class may have changed from a previous version of the
# compiler due to better packing of member '...' # compiler due to better packing of member '...'
"C4388" # signed/unsigned mismatch "C4388" # signed/unsigned mismatch

View File

@ -133,7 +133,7 @@ int ssl3_read_n(SSL *s, int n, int max, int extend) {
* bytes may be stored in |rbuf| (plus |s->packet_length| bytes if |extend| * bytes may be stored in |rbuf| (plus |s->packet_length| bytes if |extend|
* is one.) */ * is one.) */
int i, len, left; int i, len, left;
long align = 0; uintptr_t align = 0;
uint8_t *pkt; uint8_t *pkt;
SSL3_BUFFER *rb; SSL3_BUFFER *rb;
@ -148,8 +148,8 @@ int ssl3_read_n(SSL *s, int n, int max, int extend) {
left = rb->left; left = rb->left;
align = (long)rb->buf + SSL3_RT_HEADER_LENGTH; align = (uintptr_t)rb->buf + SSL3_RT_HEADER_LENGTH;
align = (-align) & (SSL3_ALIGN_PAYLOAD - 1); align = (0 - align) & (SSL3_ALIGN_PAYLOAD - 1);
if (!extend) { if (!extend) {
/* start with empty packet ... */ /* start with empty packet ... */
@ -604,7 +604,7 @@ static int do_ssl3_write(SSL *s, int type, const uint8_t *buf, unsigned int len,
} else { } else {
align = (uintptr_t)wb->buf + SSL3_RT_HEADER_LENGTH; 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; uint8_t *out = wb->buf + align;
wb->offset = align; wb->offset = align;
size_t max_out = wb->len - wb->offset; size_t max_out = wb->len - wb->offset;