lkml.org 
[lkml]   [2014]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 20/26 v5] seq_buf: Add seq_buf_can_fit() helper function
On Fri, 14 Nov 2014 23:59:07 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
>
> Add a seq_buf_can_fit() helper function that removes the possible mistakes
> of comparing the seq_buf length plus added data compared to the size of
> the buffer.
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> kernel/trace/seq_buf.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c
> index ce17f65268ed..89d1bd5c27fe 100644
> --- a/kernel/trace/seq_buf.c
> +++ b/kernel/trace/seq_buf.c
> @@ -16,6 +16,11 @@
> #include <linux/seq_file.h>
> #include <linux/seq_buf.h>
>

I'm adding a comment here:

/**
* seq_buf_can_fit - can the new data fit in the current buffer?
* @s: the seq_buf descriptor
* @len: The length to see if it can fit in the current buffer
*
* Returns true if there's enough unused space in the seq_buf buffer
* to fit the amount of new data according to @len.
*/


-- Steve

> +static bool seq_buf_can_fit(struct seq_buf *s, size_t len)
> +{
> + return s->len + len < s->size;
> +}
> +


\
 
 \ /
  Last update: 2014-11-17 19:01    [W:0.657 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site