From: doug Date: Wed, 29 Apr 2015 01:49:28 +0000 (+0000) Subject: Rename cbb_buffer_add_u to cbb_add_u and remove redundant code. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f49f13178533b67237acfe81b3594ca4906e8c1e;p=openbsd Rename cbb_buffer_add_u to cbb_add_u and remove redundant code. All of cbb_buffer_add_u's callers first call CBB_flush and send cbb->base. cbb_add_u() now has that common code in one place. ok jsing@ --- diff --git a/lib/libssl/bs_cbb.c b/lib/libssl/bs_cbb.c index 7f0e474dede..07315e86bbc 100644 --- a/lib/libssl/bs_cbb.c +++ b/lib/libssl/bs_cbb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs_cbb.c,v 1.6 2015/04/29 01:39:32 doug Exp $ */ +/* $OpenBSD: bs_cbb.c,v 1.7 2015/04/29 01:49:28 doug Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -119,7 +119,7 @@ cbb_buffer_add(struct cbb_buffer_st *base, uint8_t **out, size_t len) } static int -cbb_buffer_add_u(struct cbb_buffer_st *base, uint32_t v, size_t len_len) +cbb_add_u(CBB *cbb, uint32_t v, size_t len_len) { uint8_t *buf; size_t i; @@ -130,7 +130,7 @@ cbb_buffer_add_u(struct cbb_buffer_st *base, uint32_t v, size_t len_len) if (len_len > 4) return 0; - if (!cbb_buffer_add(base, &buf, len_len)) + if (!CBB_flush(cbb) || !cbb_buffer_add(cbb->base, &buf, len_len)) return 0; for (i = len_len - 1; i < len_len; i--) { @@ -343,28 +343,19 @@ CBB_add_space(CBB *cbb, uint8_t **out_data, size_t len) int CBB_add_u8(CBB *cbb, uint8_t value) { - if (!CBB_flush(cbb)) - return 0; - - return cbb_buffer_add_u(cbb->base, value, 1); + return cbb_add_u(cbb, value, 1); } int CBB_add_u16(CBB *cbb, uint16_t value) { - if (!CBB_flush(cbb)) - return 0; - - return cbb_buffer_add_u(cbb->base, value, 2); + return cbb_add_u(cbb, value, 2); } int CBB_add_u24(CBB *cbb, uint32_t value) { - if (!CBB_flush(cbb)) - return 0; - - return cbb_buffer_add_u(cbb->base, value, 3); + return cbb_add_u(cbb, value, 3); } int diff --git a/lib/libssl/src/ssl/bs_cbb.c b/lib/libssl/src/ssl/bs_cbb.c index 7f0e474dede..07315e86bbc 100644 --- a/lib/libssl/src/ssl/bs_cbb.c +++ b/lib/libssl/src/ssl/bs_cbb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs_cbb.c,v 1.6 2015/04/29 01:39:32 doug Exp $ */ +/* $OpenBSD: bs_cbb.c,v 1.7 2015/04/29 01:49:28 doug Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -119,7 +119,7 @@ cbb_buffer_add(struct cbb_buffer_st *base, uint8_t **out, size_t len) } static int -cbb_buffer_add_u(struct cbb_buffer_st *base, uint32_t v, size_t len_len) +cbb_add_u(CBB *cbb, uint32_t v, size_t len_len) { uint8_t *buf; size_t i; @@ -130,7 +130,7 @@ cbb_buffer_add_u(struct cbb_buffer_st *base, uint32_t v, size_t len_len) if (len_len > 4) return 0; - if (!cbb_buffer_add(base, &buf, len_len)) + if (!CBB_flush(cbb) || !cbb_buffer_add(cbb->base, &buf, len_len)) return 0; for (i = len_len - 1; i < len_len; i--) { @@ -343,28 +343,19 @@ CBB_add_space(CBB *cbb, uint8_t **out_data, size_t len) int CBB_add_u8(CBB *cbb, uint8_t value) { - if (!CBB_flush(cbb)) - return 0; - - return cbb_buffer_add_u(cbb->base, value, 1); + return cbb_add_u(cbb, value, 1); } int CBB_add_u16(CBB *cbb, uint16_t value) { - if (!CBB_flush(cbb)) - return 0; - - return cbb_buffer_add_u(cbb->base, value, 2); + return cbb_add_u(cbb, value, 2); } int CBB_add_u24(CBB *cbb, uint32_t value) { - if (!CBB_flush(cbb)) - return 0; - - return cbb_buffer_add_u(cbb->base, value, 3); + return cbb_add_u(cbb, value, 3); } int