Re: [PATCH v6 18/25] rnbd: client: sysfs interface functions

Jinpu Wang
2020-01-08T16:51:42Z

On Wed, Jan 8, 2020 at 5:39 PM Bart Van Assche <bvanassche@acm.org> wrote:
>
> On 1/8/20 5:06 AM, Jinpu Wang wrote:
> > On Fri, Jan 3, 2020 at 1:03 AM Bart Van Assche <bvanassche@acm.org> wrote:
> >> On 12/30/19 2:29 AM, Jack Wang wrote:
> >>> +/* remove new line from string */
> >>> +static void strip(char *s)
> >>> +{
> >>> + char *p = s;
> >>> +
> >>> + while (*s != '\0') {
> >>> + if (*s != '\n')
> >>> + *p++ = *s++;
> >>> + else
> >>> + ++s;
> >>> + }
> >>> + *p = '\0';
> >>> +}
> >>
> >> Does this function change a multiline string into a single line? I'm not
> >> sure that is how sysfs input should be processed ... Is this perhaps
> >> what you want?
> >>
> >> static inline void kill_final_newline(char *str)
> >> {
> >> char *newline = strrchr(str, '\n');
> >>
> >> if (newline && !newline[1])
> >> *newline = 0;
> > probably you meant "*newline = '\0'"
> >
> > Your version only removes the last newline, our version removes all
> > the newlines in the string.
>
> Removing all newlines seems dubious to me. I am not aware of any other
> sysfs code that does that.
>
> Thanks,
>
> Bart.
I agree writing a string with many newlines is not common. We can
require the user to write a single line.
I will drop it after verify with our regression tests.

Thanks Bart