summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2020-06-03 10:10:11 +0200
committerAndreas Schneider <asn@cryptomilk.org>2020-06-03 10:40:04 +0200
commit10b3ebbe61a7031a3dae97f05834442220447181 (patch)
tree0e3ebfe3c150895536e3e4f2164c7b029834f00c
parent2782cb0495b7450bd8fe43ce4af886b66fea6c40 (diff)
downloadlibssh-10b3ebbe61a7031a3dae97f05834442220447181.tar.gz
libssh-10b3ebbe61a7031a3dae97f05834442220447181.tar.xz
libssh-10b3ebbe61a7031a3dae97f05834442220447181.zip
buffer: Reformat ssh_buffer_add_data()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
-rw-r--r--src/buffer.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/buffer.c b/src/buffer.c
index a2e6246a..476bc135 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -299,28 +299,29 @@ int ssh_buffer_reinit(struct ssh_buffer_struct *buffer)
*/
int ssh_buffer_add_data(struct ssh_buffer_struct *buffer, const void *data, uint32_t len)
{
- buffer_verify(buffer);
+ buffer_verify(buffer);
- if (data == NULL) {
- return -1;
- }
+ if (data == NULL) {
+ return -1;
+ }
- if (buffer->used + len < len) {
- return -1;
- }
+ if (buffer->used + len < len) {
+ return -1;
+ }
- if (buffer->allocated < (buffer->used + len)) {
- if(buffer->pos > 0)
- buffer_shift(buffer);
- if (realloc_buffer(buffer, buffer->used + len) < 0) {
- return -1;
+ if (buffer->allocated < (buffer->used + len)) {
+ if (buffer->pos > 0) {
+ buffer_shift(buffer);
+ }
+ if (realloc_buffer(buffer, buffer->used + len) < 0) {
+ return -1;
+ }
}
- }
- memcpy(buffer->data+buffer->used, data, len);
- buffer->used+=len;
- buffer_verify(buffer);
- return 0;
+ memcpy(buffer->data + buffer->used, data, len);
+ buffer->used += len;
+ buffer_verify(buffer);
+ return 0;
}
/**