aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/unicode.c
diff options
context:
space:
mode:
authormarcin.slusarz@gmail.com <marcin.slusarz@gmail.com>2008-02-27 16:38:36 -0500
committerJan Kara <jack@suse.cz>2008-04-17 08:22:24 -0400
commit34f953ddfd15da8feb5b8383c93c35dc57202b66 (patch)
treeb8876b683dc975327cc51fb3d1019aa5f4ebeb7c /fs/udf/unicode.c
parent6305a0a9d559e97807b8bc6d5250fd525dc571a7 (diff)
udf: udf_CS0toNLS cleanup
- fix error handling - always zero output variable - don't zero explicitely fields zeroed by memset - mark "in" paramater as const Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/unicode.c')
-rw-r--r--fs/udf/unicode.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 24d6165d21a9..f5872ae325a3 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -249,35 +249,32 @@ error_out:
249} 249}
250 250
251static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, 251static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
252 struct ustr *ocu_i) 252 const struct ustr *ocu_i)
253{ 253{
254 uint8_t *ocu; 254 const uint8_t *ocu;
255 uint32_t c;
256 uint8_t cmp_id, ocu_len; 255 uint8_t cmp_id, ocu_len;
257 int i; 256 int i;
258 257
259 ocu = ocu_i->u_name;
260 258
261 ocu_len = ocu_i->u_len; 259 ocu_len = ocu_i->u_len;
262 cmp_id = ocu_i->u_cmpID;
263 utf_o->u_len = 0;
264
265 if (ocu_len == 0) { 260 if (ocu_len == 0) {
266 memset(utf_o, 0, sizeof(struct ustr)); 261 memset(utf_o, 0, sizeof(struct ustr));
267 utf_o->u_cmpID = 0;
268 utf_o->u_len = 0;
269 return 0; 262 return 0;
270 } 263 }
271 264
272 if ((cmp_id != 8) && (cmp_id != 16)) { 265 cmp_id = ocu_i->u_cmpID;
266 if (cmp_id != 8 && cmp_id != 16) {
267 memset(utf_o, 0, sizeof(struct ustr));
273 printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", 268 printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
274 cmp_id, ocu_i->u_name); 269 cmp_id, ocu_i->u_name);
275 return 0; 270 return 0;
276 } 271 }
277 272
273 ocu = ocu_i->u_name;
274 utf_o->u_len = 0;
278 for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN - 3));) { 275 for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN - 3));) {
279 /* Expand OSTA compressed Unicode to Unicode */ 276 /* Expand OSTA compressed Unicode to Unicode */
280 c = ocu[i++]; 277 uint32_t c = ocu[i++];
281 if (cmp_id == 16) 278 if (cmp_id == 16)
282 c = (c << 8) | ocu[i++]; 279 c = (c << 8) | ocu[i++];
283 280