Skip to content

Commit

Permalink
Merge pull request #11 from h2o/master
Browse files Browse the repository at this point in the history
Sync latest changes
  • Loading branch information
huitema authored Mar 9, 2018
2 parents 1ebd33a + e2b9878 commit 27b7df0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
19 changes: 16 additions & 3 deletions include/picotls.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ typedef const struct st_ptls_aead_algorithm_t {
/**
* the underlying key stream
*/
const ptls_cipher_algorithm_t *ctr_cipher;
ptls_cipher_algorithm_t *ctr_cipher;
/**
* key size
*/
Expand Down Expand Up @@ -472,6 +472,11 @@ typedef struct st_ptls_raw_extension_t {
/**
* optional arguments to client-driven handshake
*/
#ifdef _WINDOWS
/* suppress warning C4201: nonstandard extension used: nameless struct/union */
#pragma warning(push)
#pragma warning(disable : 4201)
#endif
typedef struct st_ptls_handshake_properties_t {
union {
struct {
Expand Down Expand Up @@ -544,6 +549,9 @@ typedef struct st_ptls_handshake_properties_t {
*/
int (*collected_extensions)(ptls_t *tls, struct st_ptls_handshake_properties_t *properties, ptls_raw_extension_t *extensions);
} ptls_handshake_properties_t;
#ifdef _WINDOWS
#pragma warning(pop)
#endif

/**
* builds a new ptls_iovec_t instance using the supplied parameters
Expand Down Expand Up @@ -859,10 +867,15 @@ extern void (*volatile ptls_clear_memory)(void *p, size_t len);
static ptls_iovec_t ptls_iovec_init(const void *p, size_t len);

/* inline functions */

inline ptls_iovec_t ptls_iovec_init(const void *p, size_t len)
{
return (ptls_iovec_t){(uint8_t *)p, len};
/* avoid the "return (ptls_iovec_t){(uint8_t *)p, len};" construct because it requires C99
* and triggers a warning "C4204: nonstandard extension used: non-constant aggregate initializer"
* in Visual Studio */
ptls_iovec_t r;
r.base = (uint8_t *)p;
r.len = len;
return r;
}

inline void ptls_buffer_init(ptls_buffer_t *buf, void *smallbuf, size_t smallbuf_size)
Expand Down
6 changes: 3 additions & 3 deletions lib/picotls.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ static int buffer_encrypt_record(ptls_buffer_t *buf, size_t rec_start, struct st
ptls_decode_assert_block_close((src), end); \
} while (0)

int ptls_decode16(uint16_t *value, const uint8_t **src, const uint8_t *const end)
int ptls_decode16(uint16_t *value, const uint8_t **src, const uint8_t *end)
{
if (end - *src < 2)
return PTLS_ALERT_DECODE_ERROR;
Expand All @@ -626,7 +626,7 @@ int ptls_decode16(uint16_t *value, const uint8_t **src, const uint8_t *const end
return 0;
}

int ptls_decode32(uint32_t *value, const uint8_t **src, const uint8_t *const end)
int ptls_decode32(uint32_t *value, const uint8_t **src, const uint8_t *end)
{
if (end - *src < 4)
return PTLS_ALERT_DECODE_ERROR;
Expand All @@ -635,7 +635,7 @@ int ptls_decode32(uint32_t *value, const uint8_t **src, const uint8_t *const end
return 0;
}

int ptls_decode64(uint64_t *value, const uint8_t **src, const uint8_t *const end)
int ptls_decode64(uint64_t *value, const uint8_t **src, const uint8_t *end)
{
if (end - *src < 8)
return PTLS_ALERT_DECODE_ERROR;
Expand Down

0 comments on commit 27b7df0

Please sign in to comment.