[PATCH] ctdb: strip trailing spaces from nodes file lines

Herb Lewis hlewis at panasas.com
Fri Jun 26 17:13:51 MDT 2015


We really should fix trim_string as well. The front trimming calls
memmove for each character/string found instead of finding
the first non-match and then calling memmove once.

On 06/26/2015 03:54 PM, Michael Adam wrote:
> On 2015-06-26 at 21:46 +0200, Volker Lendecke wrote:
>> On Fri, Jun 26, 2015 at 05:26:04PM +0200, Michael Adam wrote:
>>> FYI: Volker pointed out to me that we have trim_string()
>>> which I might re-use. I am currently evaluating that,
>>> also looking for a function that can trim chars of
>>> a set and not a single char or whole string, but I have
>>> not yet found one. :)
>> strtok_r?
> Not sure if that really applies:
>
> This use case wants to advance the start pointer
> of the string over leading white space and trim
> trailing whitespace, not necessarily chop up the
> whole string by whitespaces.
>
> It may be true that the current use case has
> no white spaces that are not leading or trailing,
> but somehow this seems non-obvious to me.
>
> About using trim_string():
>
> One can achieve the desired effect by
> two calls to trim_string:
>
> trim_string(node, " ", " ");
> trim_string(node, "\t", "\t");
>
> This reads more nicely but has the drawback
> that it uses memmove instead of just incrementing
> the node pointer. But reading the nodes file is
> arguably not a very performance critical operation.. ;)
>
> So attached is the alternative patch.
> Also created a bug and added the reference in the
> commit message.
>
> Thanks for further review.
>
> Michael



More information about the samba-technical mailing list