LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Fabian Frederick <fabf@skynet.be>
To: Jan Kara <jack@suse.cz>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/5 linux-next] udf: rename udf_get_filename()
Date: Sun, 15 Mar 2015 09:34:35 +0100 (CET)	[thread overview]
Message-ID: <886970217.268830.1426408475073.open-xchange@webmail.nmp.proximus.be> (raw)
In-Reply-To: <20150314065222.GD2888@quack.suse.cz>



> On 14 March 2015 at 07:52 Jan Kara <jack@suse.cz> wrote:
>
>
> On Tue 10-03-15 21:44:34, Fabian Frederick wrote:
> > udf_readdir(), udf_find_entry() and udf_pc_to_char() use
> > udf_get_filename to obtain name length. Give that function
> > an appropriate name.
>   Hum, have you read what that function does? It actually converts the name
> to a different format and returns converted length. So your name is IMHO
> more confusing - it's as if sprintf() was called sprintf_length()... Not
> applied.
>
>                                                               Honza

Hi Jan,

Ok for the name but AFAICS there's still a problem with error management in
udf_get_filename().
We return 0 when not able to allocate filename and callsites don't seem to
relate the real problem.
Maybe we could either BUG_ON(!filename), BUG_ON(!unifilename) directly in
udf_get_filename() or return -ENOMEM ?
 
udf_readdir() could return -ENOMEM instead of 0 but functions like
udf_find_entry() would need some updates ...

Another solution would be to have length as argument and return error...

Regards,
Fabian

>
> >
> > Signed-off-by: Fabian Frederick <fabf@skynet.be>
> > ---
> >  fs/udf/dir.c     | 3 ++-
> >  fs/udf/namei.c   | 3 ++-
> >  fs/udf/symlink.c | 7 ++++---
> >  fs/udf/udfdecl.h | 4 ++--
> >  fs/udf/unicode.c | 4 ++--
> >  5 files changed, 12 insertions(+), 9 deletions(-)
> >
> > diff --git a/fs/udf/dir.c b/fs/udf/dir.c
> > index 05e90ed..edf4232 100644
> > --- a/fs/udf/dir.c
> > +++ b/fs/udf/dir.c
> > @@ -168,7 +168,8 @@ static int udf_readdir(struct file *file, struct
> > dir_context *ctx)
> >                     continue;
> >             }
> > 
> > -           flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
> > +           flen = udf_get_filename_length(sb, nameptr, lfi, fname,
> > +                                          UDF_NAME_LEN);
> >             if (!flen)
> >                     continue;
> > 
> > diff --git a/fs/udf/namei.c b/fs/udf/namei.c
> > index 33b246b..189b98b 100644
> > --- a/fs/udf/namei.c
> > +++ b/fs/udf/namei.c
> > @@ -234,7 +234,8 @@ static struct fileIdentDesc *udf_find_entry(struct inode
> > *dir,
> >             if (!lfi)
> >                     continue;
> > 
> > -           flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
> > +           flen = udf_get_filename_length(sb, nameptr, lfi, fname,
> > +                                          UDF_NAME_LEN);
> >             if (flen && udf_match(flen, fname, child->len, child->name))
> >                     goto out_ok;
> >     }
> > diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
> > index ac10ca9..d986916a 100644
> > --- a/fs/udf/symlink.c
> > +++ b/fs/udf/symlink.c
> > @@ -80,9 +80,10 @@ static int udf_pc_to_char(struct super_block *sb,
> > unsigned char *from,
> >                     elen += pc->lengthComponentIdent;
> >                     if (elen > fromlen)
> >                             return -EIO;
> > -                   comp_len = udf_get_filename(sb, pc->componentIdent,
> > -                                               pc->lengthComponentIdent,
> > -                                               p, tolen);
> > +                   comp_len = udf_get_filename_length(sb,
> > +                                           pc->componentIdent,
> > +                                           pc->lengthComponentIdent,
> > +                                           p, tolen);
> >                     p += comp_len;
> >                     tolen -= comp_len;
> >                     if (tolen == 0)
> > diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
> > index 47bb3f5..70dc260 100644
> > --- a/fs/udf/udfdecl.h
> > +++ b/fs/udf/udfdecl.h
> > @@ -211,8 +211,8 @@ udf_get_lb_pblock(struct super_block *sb, struct
> > kernel_lb_addr *loc,
> >  }
> > 
> >  /* unicode.c */
> > -extern int udf_get_filename(struct super_block *, uint8_t *, int, uint8_t
> > *,
> > -                       int);
> > +extern int udf_get_filename_length(struct super_block *, uint8_t *, int,
> > +                              uint8_t *, int);
> >  extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t
> >*,
> >                         int);
> >  extern int udf_build_ustr(struct ustr *, dstring *, int);
> > diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
> > index b84fee3..209c0c7 100644
> > --- a/fs/udf/unicode.c
> > +++ b/fs/udf/unicode.c
> > @@ -334,8 +334,8 @@ try_again:
> >     return u_len + 1;
> >  }
> > 
> > -int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen,
> > -                uint8_t *dname, int dlen)
> > +int udf_get_filename_length(struct super_block *sb, uint8_t *sname, int
> > slen,
> > +                       uint8_t *dname, int dlen)
> >  {
> >     struct ustr *filename, *unifilename;
> >     int len = 0;
> > --
> > 1.9.1
> >
> --
> Jan Kara <jack@suse.cz>
> SUSE Labs, CR

  reply	other threads:[~2015-03-15  8:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-10 20:44 [PATCH 1/5 linux-next] udf: remove unused variable in udf_table_free_blocks() Fabian Frederick
2015-03-10 20:44 ` [PATCH 2/5 linux-next] udf: use sector_t for udf_bitmap_prealloc_blocks() return value Fabian Frederick
2015-03-14  6:39   ` Jan Kara
2015-03-10 20:44 ` [PATCH 3/5 linux-next] udf: remove else after return in __load_block_bitmap() Fabian Frederick
2015-03-14  6:39   ` Jan Kara
2015-03-10 20:44 ` [PATCH 4/5 linux-next] udf: rename udf_get_filename() Fabian Frederick
2015-03-14  6:52   ` Jan Kara
2015-03-15  8:34     ` Fabian Frederick [this message]
2015-03-16  7:46       ` Jan Kara
2015-03-16 20:24         ` Fabian Frederick
2015-03-10 20:44 ` [PATCH 5/5 linux-next] udf: remove redundant buffer_head.h includes Fabian Frederick
2015-03-14  6:54   ` Jan Kara
2015-03-14  6:34 ` [PATCH 1/5 linux-next] udf: remove unused variable in udf_table_free_blocks() 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=886970217.268830.1426408475073.open-xchange@webmail.nmp.proximus.be \
    --to=fabf@skynet.be \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 4/5 linux-next] udf: rename udf_get_filename()' \
    /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

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).