linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Sheng Yong <shengyong1@huawei.com>
To: Chao Yu <chao@kernel.org>, jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [RFC PATCH V3 2/2] mkfs.f2fs: avoid dumplicate extensions
Date: Sat, 28 Nov 2015 12:19:24 +0800	[thread overview]
Message-ID: <56592B4C.1080100@huawei.com> (raw)
In-Reply-To: <565926D0.7050600@kernel.org>



On 11/28/2015 12:00 PM, Chao Yu wrote:
> On 11/28/15 11:07 AM, Sheng Yong wrote:
>> Before copying an user specified extension to extension_list, check if it
>> is already in the list.
>>
>> Signed-off-by: Sheng Yong <shengyong1@huawei.com>
>> ---
>>  mkfs/f2fs_format.c | 23 ++++++++++++++++++++++-
>>  1 file changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
>> index 176bdea..0a621ae 100644
>> --- a/mkfs/f2fs_format.c
>> +++ b/mkfs/f2fs_format.c
>> @@ -118,6 +118,21 @@ const char *media_ext_lists[] = {
>>  	NULL
>>  };
>>
>> +static bool is_extension_exist(const char *name, const int len)
>> +{
>> +	int i, ret;
>> +
>> +	for (i = 0; i < F2FS_MAX_EXTENSION; i++) {
> 
> i < last_extension_position_in_list ?
Then we have to define a new global variable or add a new parameter
to pass the last position in the function.
> 
>> +		char *ext = (char *) sb.extension_list[i];
>> +		ret = strcmp(ext, name);
> 
> if (!strcmp(ext, name))
> 	return 1;
> 
>> +
>> +		if (ret == 0)
>> +			return 1;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>>  static void configure_extension_list(void)
>>  {
>>  	const char **extlist = media_ext_lists;
>> @@ -143,8 +158,14 @@ static void configure_extension_list(void)
>>  	/* add user ext list */
>>  	ue = strtok(ext_str, ",");
>>  	while (ue != NULL) {
>> +		strtrim(&ue);
>>  		name_len = strlen(ue);
>> -		memcpy(sb.extension_list[i++], ue, name_len);
>> +		if (name_len > 7) {
> 
> Shouldn't this be fixed in another patch?
This is much better than what I did :)

thanks,
Sheng
> 
> How about:
> 
> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> index 176bdea..78612e4 100644
> --- a/mkfs/f2fs_format.c
> +++ b/mkfs/f2fs_format.c
> @@ -144,7 +144,12 @@ static void configure_extension_list(void)
>  	ue = strtok(ext_str, ",");
>  	while (ue != NULL) {
>  		name_len = strlen(ue);
> +		if (name_len >= 8) {
> +			MSG(0, "\tWarn: Extension name (%s) is too long\n", ue);
> +			goto next;
> +		}
>  		memcpy(sb.extension_list[i++], ue, name_len);
> +next:
>  		ue = strtok(NULL, ",");
>  		if (i >= F2FS_MAX_EXTENSION)
>  			break;
> 
> Thanks,
> 
>> +			MSG(0, "\tError: Extension '%s' too long\n", ue);
>> +			exit(1);
>> +		}
>> +		if (!is_extension_exist(ue, name_len))
>> +			memcpy(sb.extension_list[i++], ue, name_len);
>>  		ue = strtok(NULL, ",");
>>  		if (i >= F2FS_MAX_EXTENSION)
>>  			break;
>>
> 
> .
> 


------------------------------------------------------------------------------

  reply	other threads:[~2015-11-28  4:19 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
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 [this message]
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=56592B4C.1080100@huawei.com \
    --to=shengyong1@huawei.com \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).