freemyipod r166 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r165‎ | r166 | r167 >
Date:23:11, 21 August 2010
Author:theseven
Status:new
Tags:
Comment:
Some cosmetics in the Nano2G FTL code
Modified paths:
  • /embios/trunk/target/ipodnano2g/ftl.c (modified) (history)

Diff [purge]

Index: embios/trunk/target/ipodnano2g/ftl.c
@@ -482,7 +482,7 @@
483483 if (page == 0) return 1;
484484 pagebase = page & ~(ftl_nand_type->pagesperblock - 1);
485485 if ((nand_read_page(bank, page, ftl_buffer,
486 - (uint32_t*)0, 1, 0) & 0x11F) != 0) return 1;
 486+ NULL, 1, 0) & 0x11F) != 0) return 1;
487487 if (memcmp(&ftl_buffer[0x18], "BBT", 4) != 0) return 1;
488488 unk1 = ((uint16_t*)ftl_buffer)[0x10];
489489 unk2 = ((uint16_t*)ftl_buffer)[0x11];
@@ -496,7 +496,7 @@
497497 if (page2 >= (uint32_t)(ftl_nand_type->pagesperblock - 8))
498498 break;
499499 if ((nand_read_page(bank, pagebase + page2, ftl_buffer,
500 - (void*)0, 1, 0) & 0x11F) == 0)
 500+ NULL, 1, 0) & 0x11F) == 0)
501501 {
502502 memcpy(bbt, ftl_buffer, 0x410);
503503 return 0;
@@ -628,7 +628,7 @@
629629 static struct ftl_vfl_cxt_type* ftl_vfl_get_newest_cxt(void)
630630 {
631631 uint32_t i, maxusn;
632 - struct ftl_vfl_cxt_type* cxt = (struct ftl_vfl_cxt_type*)0;
 632+ struct ftl_vfl_cxt_type* cxt = NULL;
633633 maxusn = 0;
634634 for (i = 0; i < ftl_banks; i++)
635635 if (ftl_vfl_cxt[i].usn >= maxusn)
@@ -920,8 +920,8 @@
921921 {
922922 for (i = 0; i < ftl_banks; i++)
923923 {
924 - void* databuf = (void*)0;
925 - void* sparebuf = (void*)0;
 924+ void* databuf = NULL;
 925+ void* sparebuf = NULL;
926926 if (buffer) databuf = (void*)((uint32_t)buffer + 0x800 * i);
927927 if (sparebuffer) sparebuf = (void*)((uint32_t)sparebuffer + 0x40 * i);
928928 uint32_t ret = ftl_vfl_read(vpage + i, databuf, sparebuf, checkempty, remaponfail);
@@ -1299,7 +1299,7 @@
13001300 if (ftl_log[i].scatteredvblock == 0xFFFF) continue;
13011301 if (ftl_log[i].logicalvblock == block) return &ftl_log[i];
13021302 }
1303 - return (struct ftl_log_type*)0;
 1303+ return NULL;
13041304 }
13051305 #endif
13061306
@@ -1338,7 +1338,7 @@
13391339 uint32_t abspage = ftl_map[block] * ppb + page;
13401340 #ifndef FTL_READONLY
13411341 struct ftl_log_type* logentry = ftl_get_log_entry(block);
1342 - if (logentry != (struct ftl_log_type*)0)
 1342+ if (logentry != NULL)
13431343 {
13441344 #ifdef FTL_TRACE
13451345 DEBUGF("FTL: Block %d has a log entry", block);
@@ -1358,7 +1358,7 @@
13591359
13601360 #ifndef FTL_READONLY
13611361 if (count >= i + ftl_banks && !(page & (ftl_banks - 1))
1362 - && logentry == (struct ftl_log_type*)0)
 1362+ && logentry == NULL)
13631363 #else
13641364 if (count >= i + ftl_banks && !(page & (ftl_banks - 1)))
13651365 #endif
@@ -1797,7 +1797,7 @@
17981798 uint32_t i;
17991799 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
18001800 uint32_t age = 0xFFFFFFFF, used = 0;
1801 - if (entry == (struct ftl_log_type*)0)
 1801+ if (entry == NULL)
18021802 {
18031803 for (i = 0; i < 0x11; i++)
18041804 {
@@ -1812,7 +1812,7 @@
18131813 entry = &ftl_log[i];
18141814 }
18151815 }
1816 - if (entry == (struct ftl_log_type*)0) return 1;
 1816+ if (entry == NULL) return 1;
18171817 }
18181818 else if (entry->pagescurrent < ppb / 2)
18191819 {
@@ -1845,7 +1845,7 @@
18461846 {
18471847 uint32_t i;
18481848 struct ftl_log_type* entry = ftl_get_log_entry(block);
1849 - if (entry != (struct ftl_log_type*)0)
 1849+ if (entry != NULL)
18501850 {
18511851 entry->usn = ftl_cxt.nextblockusn - 1;
18521852 return entry;
@@ -1861,17 +1861,17 @@
18621862 }
18631863 }
18641864
1865 - if (entry == (struct ftl_log_type*)0)
 1865+ if (entry == NULL)
18661866 {
18671867 if (ftl_cxt.freecount < 3) panicf(PANIC_FATAL, "FTL: Detected a pool block leak!");
18681868 else if (ftl_cxt.freecount == 3)
1869 - if (ftl_remove_scattered_block((struct ftl_log_type*)0) != 0)
1870 - return (struct ftl_log_type*)0;
 1869+ if (ftl_remove_scattered_block(NULL) != 0)
 1870+ return NULL;
18711871 entry = ftl_log;
18721872 while (entry->scatteredvblock != 0xFFFF) entry = &entry[1];
18731873 entry->scatteredvblock = ftl_allocate_pool_block();
18741874 if (entry->scatteredvblock == 0xFFFF)
1875 - return (struct ftl_log_type*)0;
 1875+ return NULL;
18761876 }
18771877
18781878 ftl_init_log_entry(entry);
@@ -1949,7 +1949,7 @@
19501950 for (i = 0; i < ftl_nand_type->userblocks; i++)
19511951 {
19521952 if (ftl_erasectr[ftl_map[i]] > max) max = ftl_erasectr[ftl_map[i]];
1953 - if (ftl_get_log_entry(i) != (struct ftl_log_type*)0) continue;
 1953+ if (ftl_get_log_entry(i) != NULL) continue;
19541954 if (ftl_erasectr[ftl_map[i]] < min)
19551955 {
19561956 minidx = i;
@@ -2028,7 +2028,7 @@
20292029 uint32_t page = (sector + i) % ppb;
20302030
20312031 struct ftl_log_type* logentry = ftl_allocate_log_entry(block);
2032 - if (logentry == (struct ftl_log_type*)0)
 2032+ if (logentry == NULL)
20332033 {
20342034 mutex_unlock(&ftl_mtx);
20352035 return -5;
@@ -2089,7 +2089,7 @@
20902090 #endif
20912091 ftl_remove_scattered_block(logentry);
20922092 logentry = ftl_allocate_log_entry(block);
2093 - if (logentry == (struct ftl_log_type*)0)
 2093+ if (logentry == NULL)
20942094 {
20952095 mutex_unlock(&ftl_mtx);
20962096 return -7;
@@ -2532,7 +2532,7 @@
25332533 blockwiped = 1;
25342534 for (i = 0; i < ftl_nand_type->pagesperblock; i++)
25352535 {
2536 - result = nand_read_page(0, i, ftl_buffer, (uint32_t*)0, 1, 1);
 2536+ result = nand_read_page(0, i, ftl_buffer, NULL, 1, 1);
25372537 if ((result & 0x11F) == 0)
25382538 {
25392539 blockwiped = 0;