From: Chao Yu <chao@kernel.org>
To: Sheng Yong <shengyong1@huawei.com>, jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [RFC PATCH V2 1/2] mkfs.f2fs: add helper strtrim() to trim string's space
Date: Sat, 28 Nov 2015 11:53:36 +0800 [thread overview]
Message-ID: <56592540.6070806@kernel.org> (raw)
In-Reply-To: <1448705988-29484-1-git-send-email-shengyong1@huawei.com>
On 11/28/15 6:19 PM, Sheng Yong wrote:
> Add a helper function strtrim() to trim space both at the beginning and end
> of a string.
I'm not sure we should add more logic when processing user defined extension string.
How about waiting for Jaegeuk's opinion?
Thanks,
>
> Signed-off-by: Sheng Yong <shengyong1@huawei.com>
> ---
> include/f2fs_fs.h | 1 +
> lib/libf2fs.c | 24 ++++++++++++++++++++++++
> 2 files changed, 25 insertions(+)
>
> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
> index 359deec..e85b2d0 100644
> --- a/include/f2fs_fs.h
> +++ b/include/f2fs_fs.h
> @@ -768,6 +768,7 @@ enum {
>
> extern void ASCIIToUNICODE(u_int16_t *, u_int8_t *);
> extern int log_base_2(u_int32_t);
> +extern void strtrim(char **str);
> extern unsigned int addrs_per_inode(struct f2fs_inode *);
>
> extern int get_bits_in_byte(unsigned char n);
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index 83d1296..e901289 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -48,6 +48,30 @@ int log_base_2(u_int32_t num)
> return ret;
> }
>
> +void strtrim(char **str)
> +{
> + int len = strlen(*str);
> + char *head = *str;
> + char *tail = *str + len - 1;
> +
> + while (head != tail) {
> + if (*head == ' ')
> + head++;
> + else {
> + *str = head;
> + break;
> + }
> + }
> +
> + while (tail != head) {
> + if (*tail == ' ') {
> + *tail = '\0';
> + tail--;
> + } else
> + break;
> + }
> +}
> +
> /*
> * f2fs bit operations
> */
>
------------------------------------------------------------------------------
next prev parent reply other threads:[~2015-11-28 3:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-28 10:19 [RFC PATCH V2 1/2] mkfs.f2fs: add helper strtrim() to trim string's space Sheng Yong
2015-11-28 3:53 ` Chao Yu [this message]
2015-11-28 10:19 ` [RFC PATCH V2 2/2] mkfs.f2fs: avoid dumplicate extensions Sheng Yong
2015-11-28 3:07 ` [RFC PATCH V3 " Sheng Yong
2015-11-28 4:00 ` Chao Yu
2015-11-28 4:19 ` Sheng Yong
2015-11-29 6:00 ` Jaegeuk Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56592540.6070806@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=shengyong1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.