diff options
author | Fabian Frederick <fabf@skynet.be> | 2015-04-08 15:23:52 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2015-05-18 05:23:04 -0400 |
commit | 31f2566f33a6a25ac0baf402316e37e76632445f (patch) | |
tree | 5d5c915502320c16ae6f7ea02233816ddbbb7ead /fs/udf | |
parent | 5ceb8b554dcaaf6844415cd2616ce2e0132530fa (diff) |
udf: remove unnecessary test in udf_build_ustr_exact()
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>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf')
-rw-r--r-- | fs/udf/unicode.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c index 4911c1d84882..e2c079aae7c0 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) | |||
68 | /* | 68 | /* |
69 | * udf_build_ustr_exact | 69 | * udf_build_ustr_exact |
70 | */ | 70 | */ |
71 | static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize) | 71 | static void udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize) |
72 | { | 72 | { |
73 | if ((!dest) || (!ptr) || (!exactsize)) | ||
74 | return -1; | ||
75 | |||
76 | memset(dest, 0, sizeof(struct ustr)); | 73 | memset(dest, 0, sizeof(struct ustr)); |
77 | dest->u_cmpID = ptr[0]; | 74 | dest->u_cmpID = ptr[0]; |
78 | dest->u_len = exactsize - 1; | 75 | dest->u_len = exactsize - 1; |
79 | memcpy(dest->u_name, ptr + 1, exactsize - 1); | 76 | memcpy(dest->u_name, ptr + 1, exactsize - 1); |
80 | |||
81 | return 0; | ||
82 | } | 77 | } |
83 | 78 | ||
84 | /* | 79 | /* |
@@ -340,6 +335,9 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen, | |||
340 | struct ustr *filename, *unifilename; | 335 | struct ustr *filename, *unifilename; |
341 | int ret = 0; | 336 | int ret = 0; |
342 | 337 | ||
338 | if (!slen) | ||
339 | return -EIO; | ||
340 | |||
343 | filename = kmalloc(sizeof(struct ustr), GFP_NOFS); | 341 | filename = kmalloc(sizeof(struct ustr), GFP_NOFS); |
344 | if (!filename) | 342 | if (!filename) |
345 | return -ENOMEM; | 343 | return -ENOMEM; |
@@ -350,9 +348,7 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen, | |||
350 | goto out1; | 348 | goto out1; |
351 | } | 349 | } |
352 | 350 | ||
353 | if (udf_build_ustr_exact(unifilename, sname, slen)) | 351 | udf_build_ustr_exact(unifilename, sname, slen); |
354 | goto out2; | ||
355 | |||
356 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { | 352 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { |
357 | if (!udf_CS0toUTF8(filename, unifilename)) { | 353 | if (!udf_CS0toUTF8(filename, unifilename)) { |
358 | udf_debug("Failed in udf_get_filename: sname = %s\n", | 354 | udf_debug("Failed in udf_get_filename: sname = %s\n", |