Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932355AbbDHTYS (ORCPT ); Wed, 8 Apr 2015 15:24:18 -0400 Received: from mailrelay116.isp.belgacom.be ([195.238.20.143]:22368 "EHLO mailrelay116.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932219AbbDHTYO (ORCPT ); Wed, 8 Apr 2015 15:24:14 -0400 X-Belgacom-Dynamic: yes X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=Ax9Kd9og7W2htzcJF9odWb+87PP6pPoG1t8Q07ebhfo= c=1 sm=2 a=CkoRH0U8e7JUhkDgZecA:9 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BwCACEfyVV/8wuQFdcgwiBLrISAQEBAQEBBQF7kFyHTwKBKzoTAQEBAQEBAX2EIAEBBCcvIxBROR4ZiC4BzREBAQgihhCKFwcWhBcFmnuLUYkKIoIDHIFSPDGCQwEBAQ From: Fabian Frederick To: linux-kernel@vger.kernel.org Cc: Jan Kara , Fabian Frederick Subject: [PATCH V2 2/9 linux-next] udf: remove unnecessary test in udf_build_ustr_exact() Date: Wed, 8 Apr 2015 21:23:52 +0200 Message-Id: <1428521039-18491-3-git-send-email-fabf@skynet.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428521039-18491-1-git-send-email-fabf@skynet.be> References: <1428521039-18491-1-git-send-email-fabf@skynet.be> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2178 Lines: 73 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 Signed-off-by: Fabian Frederick --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/