Re: [PATCH 1/5] tty: Add a function to insert a string ofcharacters with the same flag

From: Alan Cox
Date: Sat Feb 27 2010 - 14:32:17 EST


Was it really the 17th I sent the second set out - apparently so - so
ignore the first email, this is the correct patch set.

> > +int tty_insert_flip_string_fixed_flag(struct tty_struct *tty,
> > + const unsigned char *chars, char flag, size_t size)
> > {
> > int copied = 0;
> > do {
> > + int goal = min(size - copied, TTY_BUFFER_PAGE);
>
> This variable isn't used in this function.
>
> > int space = tty_buffer_request_room(tty, goal);

Its used here. The logic basically is

goal = { I want a buffer to hold "size - copied"
{ I want it to fit in one page

space = what I get back

we copy space and move on based on what we get back, so it looks correct
to me.

> > memcpy(tb->char_buf_ptr + tb->used, chars, space);
> > - memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space);
> > + memset(tb->flag_buf_ptr + tb->used, flag, space);
>
> Should you have "goal" here instead of "space"?

No because we could ask for say 500 and get 250 back, we then want to
copy 250.


Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/