Re: [PATCH 4/5 linux-next] udf: rename udf_get_filename()

From: Fabian Frederick
Date: Sun Mar 15 2015 - 04:34:44 EST




> On 14 March 2015 at 07:52 Jan Kara <jack@xxxxxxx> 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@xxxxxxxxx>
> > ---
> > 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@xxxxxxx>
> SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/