mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Fabian Frederick <fabf@skynet.be>
Cc: linux-kernel@vger.kernel.org, Jan Kara <jack@suse.cz>
Subject: Re: [PATCH V2 2/9 linux-next] udf: remove unnecessary test in udf_build_ustr_exact()
Date: Thu, 9 Apr 2015 10:25:15 +0200	[thread overview]
Message-ID: <20150409082515.GB18044@quack.suse.cz> (raw)
In-Reply-To: <1428521039-18491-3-git-send-email-fabf@skynet.be>

On Wed 08-04-15 21:23:52, Fabian Frederick wrote:
> We can remove parameter checks:
> 
> udf_build_ustr_exact() is only called by udf_get_filename()
> which now assures dest is not NULL
> 
> udf_find_entry() and udf_readdir() call udf_get_filename()
> after checking sname
> udf_symlink_filler() calls udf_pc_to_char() with sname=kmap(page).
> 
> udf_find_entry() and udf_readdir() call udf_get_filename with UDF_NAME_LEN
> udf_pc_to_char() with PAGE_SIZE
> 
> Suggested-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
  Thanks. Added to my tree.

								Honza

> ---
> V2: Return -EIO if slen = 0 in udf_get_filename()
>     (suggested by Jan Kara)
> 
>  fs/udf/unicode.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
> index 4911c1d..e2c079a 100644
> --- a/fs/udf/unicode.c
> +++ b/fs/udf/unicode.c
> @@ -68,17 +68,12 @@ int udf_build_ustr(struct ustr *dest, dstring *ptr, int size)
>  /*
>   * udf_build_ustr_exact
>   */
> -static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize)
> +static void udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize)
>  {
> -	if ((!dest) || (!ptr) || (!exactsize))
> -		return -1;
> -
>  	memset(dest, 0, sizeof(struct ustr));
>  	dest->u_cmpID = ptr[0];
>  	dest->u_len = exactsize - 1;
>  	memcpy(dest->u_name, ptr + 1, exactsize - 1);
> -
> -	return 0;
>  }
>  
>  /*
> @@ -340,6 +335,9 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen,
>  	struct ustr *filename, *unifilename;
>  	int ret = 0;
>  
> +	if (!slen)
> +		return -EIO;
> +
>  	filename = kmalloc(sizeof(struct ustr), GFP_NOFS);
>  	if (!filename)
>  		return -ENOMEM;
> @@ -350,9 +348,7 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen,
>  		goto out1;
>  	}
>  
> -	if (udf_build_ustr_exact(unifilename, sname, slen))
> -		goto out2;
> -
> +	udf_build_ustr_exact(unifilename, sname, slen);
>  	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
>  		if (!udf_CS0toUTF8(filename, unifilename)) {
>  			udf_debug("Failed in udf_get_filename: sname = %s\n",
> -- 
> 1.9.1
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

  reply	other threads:[~2015-04-09  8:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-08 19:23 [PATCH V2 0/9 linux-next] udf: improve error management Fabian Frederick
2015-04-08 19:23 ` [PATCH V2 1/9 linux-next] udf: udf_get_filename(): return -ENOMEM when allocation fails Fabian Frederick
2015-04-09  8:21   ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 2/9 linux-next] udf: remove unnecessary test in udf_build_ustr_exact() Fabian Frederick
2015-04-09  8:25   ` Jan Kara [this message]
2015-04-08 19:23 ` [PATCH V2 3/9 linux-next] udf: unicode: update function name in comments Fabian Frederick
2015-04-09  8:26   ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 4/9 linux-next] udf: improve error management in udf_CS0toUTF8() Fabian Frederick
2015-04-09  8:36   ` Jan Kara
2015-04-09 11:53     ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 5/9 linux-next] udf: improve error management in udf_CS0toNLS() Fabian Frederick
2015-04-09  8:37   ` Jan Kara
2015-04-09 11:54     ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 6/9 linux-next] udf: bug on exotic flag in udf_get_filename() Fabian Frederick
2015-04-09  8:39   ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 7/9 linux-next] udf: return error when newIndex is 0 in udf_translate_to_linux() Fabian Frederick
2015-04-09  8:51   ` Jan Kara
2015-04-09 11:55     ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 8/9 linux-next] udf: propagate udf_get_filename() errors Fabian Frederick
2015-04-09  9:27   ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 9/9 linux-next] udf: add function definition for udf_find_entry() Fabian Frederick
2015-04-09  9:26   ` Jan Kara

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=20150409082515.GB18044@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=fabf@skynet.be \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®