Changeset 3427

Show
Ignore:
Timestamp:
07/18/08 16:08:18 (3 months ago)
Author:
uwe
Message:

Random coding style fixes and simplifications (trivial).
This will even reduce the final payload size a bit.

Signed-off-by: Uwe Hermann <uwe@…>
Acked-by: Uwe Hermann <uwe@…>

Location:
trunk/payloads/coreinfo
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/payloads/coreinfo/coreinfo.c

    r3419 r3427  
    7878}; 
    7979 
    80  
    8180static WINDOW *modwin; 
    8281static WINDOW *menuwin; 
     
    122121        struct tm tm; 
    123122 
    124         while(nvram_updating()) 
     123        while (nvram_updating()) 
    125124                mdelay(10); 
    126125 
     
    128127 
    129128        mvwprintw(menuwin, 0, 57, "%02d/%02d/%04d - %02d:%02d:%02d", 
    130                 tm.tm_mon, tm.tm_mday, 1900+tm.tm_year, tm.tm_hour, 
    131                 tm.tm_min, tm.tm_sec); 
     129                  tm.tm_mon, tm.tm_mday, 1900+tm.tm_year, tm.tm_hour, 
     130                  tm.tm_min, tm.tm_sec); 
    132131} 
    133132#endif 
     
    185184        ptr += sprintf(ptr, "[ %s ]", str); 
    186185 
    187  
    188  
    189186        for (i = ((SCREEN_X - len) / 2) + len; i < SCREEN_X; i++) 
    190187                ptr += sprintf(ptr, "="); 
     
    208205        if (key >= 'a' && key <= 'z') { 
    209206                int index = key - 'a'; 
    210  
    211207                if (index < cat->count) { 
    212  
    213                 cat->cur = index; 
     208                        cat->cur = index; 
    214209                        redraw_module(cat); 
    215210                        return; 
     
    297292 
    298293        for (i = 0; i < ARRAY_SIZE(categories); i++) { 
    299                 for(j = 0; j < categories[i].count; j++) 
     294                for (j = 0; j < categories[i].count; j++) 
    300295                        categories[i].modules[j]->init(); 
    301296 
     
    307302} 
    308303 
    309 PAYLOAD_INFO(name,"coreinfo"); 
    310 PAYLOAD_INFO(listname,"System Information"); 
    311 PAYLOAD_INFO(desc,"Display information about the system"); 
     304PAYLOAD_INFO(name, "coreinfo"); 
     305PAYLOAD_INFO(listname, "System Information"); 
     306PAYLOAD_INFO(desc, "Display information about the system"); 
  • trunk/payloads/coreinfo/lar_module.c

    r3289 r3427  
    2323 
    2424static struct LAR *lar; 
    25 static int lcount; 
     25static int lcount, selected; 
    2626static char **lnames; 
     27static const char *compression_table[4] = {"none", "LZMA", "NRV2B", "zeroes"}; 
    2728 
    2829static int lar_module_init(void) 
     
    3637                return 0; 
    3738 
    38         while((larent = readlar(lar))) 
     39        while ((larent = readlar(lar))) 
    3940                lcount++; 
    4041 
     
    4647        rewindlar(lar); 
    4748 
    48         while((larent = readlar(lar))) 
     49        while ((larent = readlar(lar))) 
    4950                lnames[index++] = strdup((const char *) larent->name); 
    5051 
     
    5253} 
    5354 
    54 static int selected; 
    55  
    5655static int lar_module_redraw(WINDOW *win) 
    5756{ 
    58         int i; 
    59         int row = 2; 
     57        int i, row = 2; 
    6058        struct larstat stat; 
    6159 
     
    6361 
    6462        if (lar == 0) { 
    65                 mvwprintw(win, 11, 61/2,  "Bad or missing LAR"); 
     63                mvwprintw(win, 11, 61 / 2,  "Bad or missing LAR"); 
    6664                return 0; 
    6765        } 
    6866 
    69         /* Draw a line down the middle */ 
     67        /* Draw a line down the middle. */ 
     68        for (i = 2; i < 21; i++) 
     69                mvwaddch(win, i, 30, '\263'); 
    7070 
    71         for(i = 2; i < 20; i++) { 
    72                 wmove(win, i, 30); 
    73                 waddch(win, '\263'); 
    74         } 
    75  
    76         /* Draw the names down the left side */ 
    77  
    78         for(i = 0; i < lcount; i++) { 
     71        /* Draw the names down the left side. */ 
     72        for (i = 0; i < lcount; i++) { 
    7973                if (i == selected) 
    8074                        wattrset(win, COLOR_PAIR(3) | A_BOLD); 
     
    8579        } 
    8680 
    87         /* Get the information for the LAR */ 
    88  
     81        /* Get the information for the LAR. */ 
    8982        if (larstat(lar, lnames[selected], &stat)) { 
    9083                printf("larstat failed\n"); 
     
    9790 
    9891        if (stat.compression) { 
    99                 switch(stat.compression) { 
    100                 case ALGO_LZMA: 
    101                         mvwprintw(win, row++, 32, "Compression: LZMA"); 
    102                         break; 
    103                 case ALGO_NRV2B: 
    104                         mvwprintw(win, row++, 32, "Compression: NRV2B"); 
    105                         break; 
    106                 case ALGO_ZEROES: 
    107                         mvwprintw(win, row++, 32, "Compression: zeroes"); 
    108                         break; 
    109                 } 
    110  
     92                mvwprintw(win, row++, 32, "Compression: %s", 
     93                          compression_table[stat.compression]); 
    11194                mvwprintw(win, row++, 32, "Compressed length: %d", stat.len); 
    112                 mvwprintw(win, row++, 32, "Compressed checksum: 0x%x", stat.compchecksum); 
     95                mvwprintw(win, row++, 32, "Compressed checksum: 0x%x", 
     96                          stat.compchecksum); 
    11397        } 
    11498 
    11599        mvwprintw(win, row++, 32, "Length: %d", stat.reallen); 
    116100        mvwprintw(win, row++, 32, "Checksum: 0x%x", stat.checksum); 
    117         mvwprintw(win, row++, 32, "Load Address: 0x%llx", stat.loadaddress); 
    118         mvwprintw(win, row++, 32, "Entry Point: 0x%llx", stat.entry); 
     101        mvwprintw(win, row++, 32, "Load address: 0x%llx", stat.loadaddress); 
     102        mvwprintw(win, row++, 32, "Entry point: 0x%llx", stat.entry); 
    119103 
    120104        return 0; 
     
    152136        .handle = lar_module_handle 
    153137}; 
     138 
    154139#else 
    155140 
     
    158143 
    159144#endif 
    160  
    161  
    162  
    163