[coreboot-gerrit] New patch to review for coreboot: 3c40fd2 cbfstool: add bputs() to store a byte stream to a buffer

Aaron Durbin (adurbin@google.com) gerrit at coreboot.org
Tue Mar 11 18:11:36 CET 2014


Aaron Durbin (adurbin at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5366

-gerrit

commit 3c40fd2ac7c97bf2dc4cc08d6c7410b16ba26ccc
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Mon Mar 10 14:13:27 2014 -0500

    cbfstool: add bputs() to store a byte stream to a buffer
    
    There was already a bgets() function which operates on a buffer to
    copy a byte stream. Provide bputs() to store a byte stream to a
    buffer, thus making the API symmetrical.
    
    Change-Id: I6166f6b68eacb822da38c9da61a3e44f4c67136d
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
 util/cbfstool/common.h | 3 ++-
 util/cbfstool/xdr.c    | 9 ++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index 16e75f9..d0069c3 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -112,6 +112,7 @@ struct xdr {
 
 /* xdr.c */
 extern struct xdr xdr_le, xdr_be;
-int bgets(struct buffer *input, void *output, size_t len);
+size_t bgets(struct buffer *input, void *output, size_t len);
+size_t bputs(struct buffer *b, const void *data, size_t len);
 
 #endif
diff --git a/util/cbfstool/xdr.c b/util/cbfstool/xdr.c
index e2cafd1..df2c4ba 100644
--- a/util/cbfstool/xdr.c
+++ b/util/cbfstool/xdr.c
@@ -25,7 +25,7 @@
 #include <stdint.h>
 #include "common.h"
 
-int bgets(struct buffer *input, void *output, size_t len)
+size_t bgets(struct buffer *input, void *output, size_t len)
 {
 	len = input->size < len ? input->size : len;
 	memmove(output, input->data, len);
@@ -34,6 +34,13 @@ int bgets(struct buffer *input, void *output, size_t len)
 	return len;
 }
 
+size_t bputs(struct buffer *b, const void *data, size_t len)
+{
+	memmove(&b->data[b->size], data, len);
+	b->size += len;
+	return len;
+}
+
 /* The assumption in all this code is that we're given a pointer to enough data.
  * Hence, we do not check for underflow.
  */



More information about the coreboot-gerrit mailing list