HV:change the return type of sbuf_get and sbuf_put

Because of the return type inconsistent,change the
sbuf return type to uint32_t to fix it,and make the
pre-condition to check the parameter whether is NULL.

V1->V2:
  1.add () to bool expression
  2.add pre-assumption to sbuf_get and sbuf_put

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Huihuang Shi
2018-10-09 15:21:35 +08:00
committed by wenlingz
parent c5f4c5109c
commit 2b53acb5f8
3 changed files with 16 additions and 16 deletions

View File

@@ -82,14 +82,10 @@ void sbuf_free(struct shared_buf *sbuf)
free(sbuf);
}
int sbuf_get(struct shared_buf *sbuf, uint8_t *data)
uint32_t sbuf_get(struct shared_buf *sbuf, uint8_t *data)
{
const void *from;
if ((sbuf == NULL) || (data == NULL)) {
return -EINVAL;
}
if (sbuf_is_empty(sbuf)) {
/* no data available */
return 0;
@@ -122,16 +118,12 @@ int sbuf_get(struct shared_buf *sbuf, uint8_t *data)
* negative: failed.
*/
int sbuf_put(struct shared_buf *sbuf, uint8_t *data)
uint32_t sbuf_put(struct shared_buf *sbuf, uint8_t *data)
{
void *to;
uint32_t next_tail;
bool trigger_overwrite = false;
if ((sbuf == NULL) || (data == NULL)) {
return -EINVAL;
}
next_tail = sbuf_next_ptr(sbuf->tail, sbuf->ele_size, sbuf->size);
/* if this write would trigger overrun */
if (next_tail == sbuf->head) {