summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDoug Hogan <doug@cvs.openbsd.org>2015-04-29 01:49:29 +0000
committerDoug Hogan <doug@cvs.openbsd.org>2015-04-29 01:49:29 +0000
commit44af89df961335af730234197017850c8dafe36c (patch)
treec209660619008d7c966a76e4e58c0687a60cb0e4 /lib
parentd4083db7ddbe3c4734c569c4cac2a9445c81e7ed (diff)
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@
Diffstat (limited to 'lib')
-rw-r--r--lib/libssl/src/ssl/bs_cbb.c21
1 files changed, 6 insertions, 15 deletions
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