aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/unicode.c
diff options
context:
space:
mode:
authorMarcin Slusarz <marcin.slusarz@gmail.com>2008-02-08 07:20:36 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 12:22:35 -0500
commit4b11111aba6c80cc2969fd1806d2a869bfc9f357 (patch)
tree57b72a1ca58859dc6a9e47d647f29cebb9bcf7e0 /fs/udf/unicode.c
parentbd45a420f93d18c91115f3f0568dd6a2555aa15a (diff)
udf: fix coding style
fix coding style errors found by checkpatch: - assignments in if conditions - braces {} around single statement blocks - no spaces after commas - printks without KERN_* - lines longer than 80 characters - spaces between "type *" and variable name before: 192 errors, 561 warnings, 8987 lines checked after: 1 errors, 38 warnings, 9468 lines checked Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Cc: Jan Kara <jack@suse.cz> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/udf/unicode.c')
-rw-r--r--fs/udf/unicode.c85
1 files changed, 46 insertions, 39 deletions
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 9e6099c26c27..e533b11703bf 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -136,12 +136,18 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i)
136 if (c < 0x80U) { 136 if (c < 0x80U) {
137 utf_o->u_name[utf_o->u_len++] = (uint8_t)c; 137 utf_o->u_name[utf_o->u_len++] = (uint8_t)c;
138 } else if (c < 0x800U) { 138 } else if (c < 0x800U) {
139 utf_o->u_name[utf_o->u_len++] = (uint8_t)(0xc0 | (c >> 6)); 139 utf_o->u_name[utf_o->u_len++] =
140 utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | (c & 0x3f)); 140 (uint8_t)(0xc0 | (c >> 6));
141 utf_o->u_name[utf_o->u_len++] =
142 (uint8_t)(0x80 | (c & 0x3f));
141 } else { 143 } else {
142 utf_o->u_name[utf_o->u_len++] = (uint8_t)(0xe0 | (c >> 12)); 144 utf_o->u_name[utf_o->u_len++] =
143 utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | ((c >> 6) & 0x3f)); 145 (uint8_t)(0xe0 | (c >> 12));
144 utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | (c & 0x3f)); 146 utf_o->u_name[utf_o->u_len++] =
147 (uint8_t)(0x80 |
148 ((c >> 6) & 0x3f));
149 utf_o->u_name[utf_o->u_len++] =
150 (uint8_t)(0x80 | (c & 0x3f));
145 } 151 }
146 } 152 }
147 utf_o->u_cmpID = 8; 153 utf_o->u_cmpID = 8;
@@ -232,9 +238,8 @@ try_again:
232 goto error_out; 238 goto error_out;
233 } 239 }
234 240
235 if (max_val == 0xffffU) { 241 if (max_val == 0xffffU)
236 ocu[++u_len] = (uint8_t)(utf_char >> 8); 242 ocu[++u_len] = (uint8_t)(utf_char >> 8);
237 }
238 ocu[++u_len] = (uint8_t)(utf_char & 0xffU); 243 ocu[++u_len] = (uint8_t)(utf_char & 0xffU);
239 } 244 }
240 245
@@ -330,29 +335,29 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname,
330 struct ustr filename, unifilename; 335 struct ustr filename, unifilename;
331 int len; 336 int len;
332 337
333 if (udf_build_ustr_exact(&unifilename, sname, flen)) { 338 if (udf_build_ustr_exact(&unifilename, sname, flen))
334 return 0; 339 return 0;
335 }
336 340
337 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { 341 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
338 if (!udf_CS0toUTF8(&filename, &unifilename)) { 342 if (!udf_CS0toUTF8(&filename, &unifilename)) {
339 udf_debug("Failed in udf_get_filename: sname = %s\n", sname); 343 udf_debug("Failed in udf_get_filename: sname = %s\n",
344 sname);
340 return 0; 345 return 0;
341 } 346 }
342 } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { 347 } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
343 if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, &filename, &unifilename)) { 348 if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, &filename,
344 udf_debug("Failed in udf_get_filename: sname = %s\n", sname); 349 &unifilename)) {
350 udf_debug("Failed in udf_get_filename: sname = %s\n",
351 sname);
345 return 0; 352 return 0;
346 } 353 }
347 } else { 354 } else
348 return 0; 355 return 0;
349 }
350 356
351 len = udf_translate_to_linux(dname, filename.u_name, filename.u_len, 357 len = udf_translate_to_linux(dname, filename.u_name, filename.u_len,
352 unifilename.u_name, unifilename.u_len); 358 unifilename.u_name, unifilename.u_len);
353 if (len) { 359 if (len)
354 return len; 360 return len;
355 }
356 361
357 return 0; 362 return 0;
358} 363}
@@ -363,23 +368,20 @@ int udf_put_filename(struct super_block *sb, const uint8_t *sname,
363 struct ustr unifilename; 368 struct ustr unifilename;
364 int namelen; 369 int namelen;
365 370
366 if (!(udf_char_to_ustr(&unifilename, sname, flen))) { 371 if (!udf_char_to_ustr(&unifilename, sname, flen))
367 return 0; 372 return 0;
368 }
369 373
370 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { 374 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
371 namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN); 375 namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN);
372 if (!namelen) { 376 if (!namelen)
373 return 0; 377 return 0;
374 }
375 } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { 378 } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
376 namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, &unifilename, UDF_NAME_LEN); 379 namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname,
377 if (!namelen) { 380 &unifilename, UDF_NAME_LEN);
381 if (!namelen)
378 return 0; 382 return 0;
379 } 383 } else
380 } else {
381 return 0; 384 return 0;
382 }
383 385
384 return namelen; 386 return namelen;
385} 387}
@@ -389,8 +391,9 @@ int udf_put_filename(struct super_block *sb, const uint8_t *sname,
389#define CRC_MARK '#' 391#define CRC_MARK '#'
390#define EXT_SIZE 5 392#define EXT_SIZE 5
391 393
392static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen, 394static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName,
393 uint8_t *fidName, int fidNameLen) 395 int udfLen, uint8_t *fidName,
396 int fidNameLen)
394{ 397{
395 int index, newIndex = 0, needsCRC = 0; 398 int index, newIndex = 0, needsCRC = 0;
396 int extIndex = 0, newExtIndex = 0, hasExt = 0; 399 int extIndex = 0, newExtIndex = 0, hasExt = 0;
@@ -409,13 +412,16 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen
409 if (curr == '/' || curr == 0) { 412 if (curr == '/' || curr == 0) {
410 needsCRC = 1; 413 needsCRC = 1;
411 curr = ILLEGAL_CHAR_MARK; 414 curr = ILLEGAL_CHAR_MARK;
412 while (index + 1 < udfLen && (udfName[index + 1] == '/' || 415 while (index + 1 < udfLen &&
413 udfName[index + 1] == 0)) 416 (udfName[index + 1] == '/' ||
417 udfName[index + 1] == 0))
414 index++; 418 index++;
415 } if (curr == EXT_MARK && (udfLen - index - 1) <= EXT_SIZE) { 419 }
416 if (udfLen == index + 1) { 420 if (curr == EXT_MARK &&
421 (udfLen - index - 1) <= EXT_SIZE) {
422 if (udfLen == index + 1)
417 hasExt = 0; 423 hasExt = 0;
418 } else { 424 else {
419 hasExt = 1; 425 hasExt = 1;
420 extIndex = index; 426 extIndex = index;
421 newExtIndex = newIndex; 427 newExtIndex = newIndex;
@@ -433,16 +439,18 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen
433 439
434 if (hasExt) { 440 if (hasExt) {
435 int maxFilenameLen; 441 int maxFilenameLen;
436 for(index = 0; index < EXT_SIZE && extIndex + index + 1 < udfLen; index++) { 442 for (index = 0;
443 index < EXT_SIZE && extIndex + index + 1 < udfLen;
444 index++) {
437 curr = udfName[extIndex + index + 1]; 445 curr = udfName[extIndex + index + 1];
438 446
439 if (curr == '/' || curr == 0) { 447 if (curr == '/' || curr == 0) {
440 needsCRC = 1; 448 needsCRC = 1;
441 curr = ILLEGAL_CHAR_MARK; 449 curr = ILLEGAL_CHAR_MARK;
442 while(extIndex + index + 2 < udfLen && 450 while (extIndex + index + 2 < udfLen &&
443 (index + 1 < EXT_SIZE 451 (index + 1 < EXT_SIZE &&
444 && (udfName[extIndex + index + 2] == '/' || 452 (udfName[extIndex + index + 2] == '/' ||
445 udfName[extIndex + index + 2] == 0))) 453 udfName[extIndex + index + 2] == 0)))
446 index++; 454 index++;
447 } 455 }
448 ext[localExtIndex++] = curr; 456 ext[localExtIndex++] = curr;
@@ -452,9 +460,8 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen
452 newIndex = maxFilenameLen; 460 newIndex = maxFilenameLen;
453 else 461 else
454 newIndex = newExtIndex; 462 newIndex = newExtIndex;
455 } else if (newIndex > 250) { 463 } else if (newIndex > 250)
456 newIndex = 250; 464 newIndex = 250;
457 }
458 newName[newIndex++] = CRC_MARK; 465 newName[newIndex++] = CRC_MARK;
459 valueCRC = udf_crc(fidName, fidNameLen, 0); 466 valueCRC = udf_crc(fidName, fidNameLen, 0);
460 newName[newIndex++] = hexChar[(valueCRC & 0xf000) >> 12]; 467 newName[newIndex++] = hexChar[(valueCRC & 0xf000) >> 12];