cbfstool: Simplify the common buffer_splice() function's interface

Previously, this function allowed one to pass a size of 0 in order to
indicate that the entire buffer should be copied. However, the
semantics of calling it this way were non-obvious: The desired
behavior was clear when the offset was also 0, but what was the
expected outcome when the offset was nonzero, since carrying over the
original size in this case would be an error? In fact, it turns out
that it always ignored the provided offset when the size was zero.
This commit eliminates all special handling of 0; thus, the resulting
buffer is exactly as large as requested, even if it's degenerate.
Since the only consumer that actually called the function with a size
of 0 was buffer_clone(), no other files required changes.

Change-Id: I1baa5dbaa7ba5bd746e8b1e08816335183bd5d2d
Signed-off-by: Sol Boucher <solb@chromium.org>
Reviewed-on: http://review.coreboot.org/10132
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index f364ea1..78ec40a 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -86,23 +86,19 @@
 	b->size = size;
 }
 
-/* Splice a buffer into another buffer. If size is zero the entire buffer
- * is spliced while if size is non-zero the buffer is spliced starting at
- * offset for size bytes. Note that it's up to caller to bounds check.
- */
+/* Splice a buffer into another buffer. Note that it's up to the caller to
+ * bounds check the offset and size. */
 static inline void buffer_splice(struct buffer *dest, const struct buffer *src,
                                  size_t offset, size_t size)
 {
 	buffer_init(dest, src->name, src->data, src->size);
-	if (size != 0) {
-		dest->data += offset;
-		buffer_set_size(dest, size);
-	}
+	dest->data += offset;
+	buffer_set_size(dest, size);
 }
 
 static inline void buffer_clone(struct buffer *dest, const struct buffer *src)
 {
-	buffer_splice(dest, src, 0, 0);
+	buffer_splice(dest, src, 0, src->size);
 }
 
 static inline void buffer_seek(struct buffer *b, size_t size)