Changeset a35b458 in mainline for uspace/app/tester/mm


Ignore:
Timestamp:
2018-03-02T20:10:49Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

Location:
uspace/app/tester/mm
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/mm/common.c

    r3061bc1 ra35b458  
    7272{
    7373        link_t *link;
    74        
     74
    7575        while ((link = list_first(&mem_blocks)) != NULL) {
    7676                mem_block_t *block = list_get_instance(link, mem_block_t, link);
    7777                free_block(block);
    7878        }
    79        
     79
    8080        while ((link = list_first(&mem_areas)) != NULL) {
    8181                mem_area_t *area = list_get_instance(link, mem_area_t, link);
     
    8989        uint8_t *mbeg = (uint8_t *) block;
    9090        uint8_t *mend = (uint8_t *) block + sizeof(mem_block_t);
    91        
     91
    9292        /* Entry block memory <bbeg, bend) */
    9393        uint8_t *bbeg = (uint8_t *) block->addr;
    9494        uint8_t *bend = (uint8_t *) block->addr + block->size;
    95        
     95
    9696        /* Data block <dbeg, dend) */
    9797        uint8_t *dbeg = (uint8_t *) addr;
    9898        uint8_t *dend = (uint8_t *) addr + size;
    99        
     99
    100100        /* Check for overlaps */
    101101        if (((mbeg >= dbeg) && (mbeg < dend)) ||
     
    104104            ((bend > dbeg) && (bend <= dend)))
    105105                return true;
    106        
     106
    107107        return false;
    108108}
     
    122122{
    123123        bool fnd = false;
    124        
     124
    125125        list_foreach(mem_blocks, link, mem_block_t, block) {
    126126                if (overlap_match(block, addr, size)) {
     
    129129                }
    130130        }
    131        
     131
    132132        return fnd;
    133133}
     
    160160{
    161161        void *data;
    162        
     162
    163163        /* Allocate the chunk of memory */
    164164        data = malloc(size);
     
    166166        if (data == NULL)
    167167                return NULL;
    168        
     168
    169169        /* Check for overlaps with other chunks */
    170170        if (test_overlap(data, size)) {
     
    174174                error_flag = true;
    175175        }
    176        
     176
    177177        return data;
    178178}
     
    197197        if (mem_allocated >= MAX_ALLOC)
    198198                return NULL;
    199        
     199
    200200        /* Allocate the block holder */
    201201        mem_block_t *block =
     
    203203        if (block == NULL)
    204204                return NULL;
    205        
     205
    206206        link_initialize(&block->link);
    207        
     207
    208208        /* Allocate the block memory */
    209209        block->addr = checked_malloc(size);
     
    213213                return NULL;
    214214        }
    215        
     215
    216216        block->size = size;
    217        
     217
    218218        /* Register the allocated block */
    219219        list_append(&block->link, &mem_blocks);
    220220        mem_allocated += size + sizeof(mem_block_t);
    221221        mem_blocks_count++;
    222        
     222
    223223        return block;
    224224}
     
    238238        mem_allocated -= block->size + sizeof(mem_block_t);
    239239        mem_blocks_count--;
    240        
     240
    241241        /* Free the memory */
    242242        free(block->addr);
     
    272272            pos < end; pos++)
    273273                *pos = block_expected_value(block, pos);
    274        
     274
    275275        check_consistency("fill_block");
    276276}
     
    308308        if (mem_blocks_count == 0)
    309309                return NULL;
    310        
     310
    311311        unsigned long idx = rand() % mem_blocks_count;
    312312        link_t *entry = list_nth(&mem_blocks, idx);
    313        
     313
    314314        if (entry == NULL) {
    315315                TPRINTF("\nError: Corrupted list of allocated memory blocks.\n");
     
    317317                error_flag = true;
    318318        }
    319        
     319
    320320        return list_get_instance(entry, mem_block_t, link);
    321321}
     
    337337        if (area == NULL)
    338338                return NULL;
    339        
     339
    340340        link_initialize(&area->link);
    341        
     341
    342342        area->addr = as_area_create(AS_AREA_ANY, size,
    343343            AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE,
     
    348348                return NULL;
    349349        }
    350        
     350
    351351        area->size = size;
    352        
     352
    353353        /* Register the allocated area */
    354354        list_append(&area->link, &mem_areas);
    355        
     355
    356356        return area;
    357357}
     
    369369        /* Unregister the area */
    370370        list_remove(&area->link);
    371        
     371
    372372        /* Free the memory */
    373373        errno_t ret = as_area_destroy(area->addr);
    374374        if (ret != EOK)
    375375                error_flag = true;
    376        
     376
    377377        free(area);
    378378        check_consistency("unmap_area");
     
    405405            pos < end; pos++)
    406406                *pos = area_expected_value(area, pos);
    407        
     407
    408408        check_consistency("fill_area");
    409409}
  • uspace/app/tester/mm/common.h

    r3061bc1 ra35b458  
    4848        /* Address of the start of the block */
    4949        void *addr;
    50        
     50
    5151        /* Size of the memory block */
    5252        size_t size;
    53        
     53
    5454        /* Link to other blocks */
    5555        link_t link;
     
    5959        /* Address of the start of the area */
    6060        void *addr;
    61        
     61
    6262        /* Size of the memory area */
    6363        size_t size;
  • uspace/app/tester/mm/malloc1.c

    r3061bc1 ra35b458  
    208208{
    209209        for (unsigned int cycles = 0; /* always */; cycles++) {
    210                
     210
    211211                if ((subphase->cond.max_cycles) &&
    212212                    (cycles >= subphase->cond.max_cycles)) {
     
    217217                        break;
    218218                }
    219                
     219
    220220                /*
    221221                 * Decide whether we alloc or free memory in this step.
     
    229229                        int alloc = phase->alloc.min_block_size +
    230230                            (rand() % (phase->alloc.max_block_size - phase->alloc.min_block_size + 1));
    231                        
     231
    232232                        mem_block_t *blk = alloc_block(alloc);
    233233                        RETURN_IF_ERROR;
    234                        
     234
    235235                        if (blk == NULL) {
    236236                                TPRINTF("F(A)");
     
    244244                                RETURN_IF_ERROR;
    245245                        }
    246                        
     246
    247247                } else if (rnd < subphase->prob.free) {
    248248                        mem_block_t *blk = get_random_block();
     
    257257                                check_block(blk);
    258258                                RETURN_IF_ERROR;
    259                                
     259
    260260                                free_block(blk);
    261261                                RETURN_IF_ERROR;
     
    263263                }
    264264        }
    265        
     265
    266266        TPRINTF("\n..  finished.\n");
    267267}
     
    271271        for (unsigned int subno = 0; subno < 3; subno++) {
    272272                subphase_t *subphase = &phase->subphases[subno];
    273                
     273
    274274                TPRINTF(".. Sub-phase %u (%s)\n", subno + 1, subphase->name);
    275275                do_subphase(phase, subphase);
     
    281281{
    282282        init_mem();
    283        
     283
    284284        for (unsigned int phaseno = 0; phaseno < sizeof_array(phases);
    285285            phaseno++) {
    286286                phase_t *phase = &phases[phaseno];
    287                
     287
    288288                TPRINTF("Entering phase %u (%s)\n", phaseno + 1, phase->name);
    289                
     289
    290290                do_phase(phase);
    291291                if (error_flag)
    292292                        break;
    293                
     293
    294294                TPRINTF("Phase finished.\n");
    295295        }
    296        
     296
    297297        TPRINTF("Cleaning up.\n");
    298298        done_mem();
    299299        if (error_flag)
    300300                return "Test failed";
    301        
     301
    302302        return NULL;
    303303}
  • uspace/app/tester/mm/malloc3.c

    r3061bc1 ra35b458  
    200200{
    201201        for (unsigned int cycles = 0; /* always */; cycles++) {
    202                
     202
    203203                if ((subphase->cond.max_cycles) &&
    204204                    (cycles >= subphase->cond.max_cycles)) {
     
    209209                        break;
    210210                }
    211                
     211
    212212                /*
    213213                 * Decide whether we alloc or free memory in this step.
     
    221221                        int alloc = phase->alloc.min_block_size +
    222222                            (rand() % (phase->alloc.max_block_size - phase->alloc.min_block_size + 1));
    223                        
     223
    224224                        mem_block_t *blk = alloc_block(alloc);
    225225                        RETURN_IF_ERROR;
    226                        
     226
    227227                        if (blk == NULL) {
    228228                                TPRINTF("F(A)");
     
    235235                                fill_block(blk);
    236236                                RETURN_IF_ERROR;
    237                                
     237
    238238                                if ((mem_blocks_count % AREA_GRANULARITY) == 0) {
    239239                                        mem_area_t *area = map_area(AREA_SIZE);
    240240                                        RETURN_IF_ERROR;
    241                                        
     241
    242242                                        if (area != NULL) {
    243243                                                TPRINTF("*");
     
    248248                                }
    249249                        }
    250                        
     250
    251251                } else if (rnd < subphase->prob.free) {
    252252                        mem_block_t *blk = get_random_block();
     
    261261                                check_block(blk);
    262262                                RETURN_IF_ERROR;
    263                                
     263
    264264                                free_block(blk);
    265265                                RETURN_IF_ERROR;
     
    267267                }
    268268        }
    269        
     269
    270270        TPRINTF("\n..  finished.\n");
    271271}
     
    275275        for (unsigned int subno = 0; subno < 3; subno++) {
    276276                subphase_t *subphase = &phase->subphases[subno];
    277                
     277
    278278                TPRINTF(".. Sub-phase %u (%s)\n", subno + 1, subphase->name);
    279279                do_subphase(phase, subphase);
     
    285285{
    286286        init_mem();
    287        
     287
    288288        for (unsigned int phaseno = 0; phaseno < sizeof_array(phases);
    289289            phaseno++) {
    290290                phase_t *phase = &phases[phaseno];
    291                
     291
    292292                TPRINTF("Entering phase %u (%s)\n", phaseno + 1, phase->name);
    293                
     293
    294294                do_phase(phase);
    295295                if (error_flag)
    296296                        break;
    297                
     297
    298298                TPRINTF("Phase finished.\n");
    299299        }
    300        
     300
    301301        TPRINTF("Cleaning up.\n");
    302302        done_mem();
    303303        if (error_flag)
    304304                return "Test failed";
    305        
     305
    306306        return NULL;
    307307}
  • uspace/app/tester/mm/mapping1.c

    r3061bc1 ra35b458  
    4141{
    4242        TPRINTF("Creating AS area...\n");
    43        
     43
    4444        void *result = as_area_create(AS_AREA_ANY, size,
    4545            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, AS_AREA_UNPAGED);
    4646        if (result == AS_MAP_FAILED)
    4747                return NULL;
    48        
     48
    4949        return result;
    5050}
     
    5353{
    5454        TPRINTF("Touching (faulting-in) AS area...\n");
    55        
     55
    5656        char *ptr = (char *)area;
    57        
     57
    5858        while (size > 0) {
    5959                *ptr = 0;
     
    8686{
    8787        errno_t rc;
    88        
     88
    8989        size_t buffer1_len = BUFFER1_PAGES * PAGE_SIZE;
    9090        size_t buffer2_len = BUFFER2_PAGES * PAGE_SIZE;
     
    9494                return "Cannot allocate memory";
    9595        }
    96        
     96
    9797        touch_area(buffer1, buffer1_len);
    9898        touch_area(buffer2, buffer2_len);
    99        
     99
    100100        /* Now verify that mapping to physical frames exist. */
    101101        if (!VERIFY_MAPPING(buffer1, BUFFER1_PAGES, EOK)) {
     
    105105                return "Failed to find mapping (buffer2)";
    106106        }
    107        
     107
    108108        /* Let's destroy the buffer1 area and access it again. */
    109109        rc = as_area_destroy(buffer1);
     
    114114                return "Mapping of destroyed area still exists";
    115115        }
    116        
     116
    117117        /* clean-up */
    118118        rc = as_area_destroy(buffer2);
     
    120120                return "Failed to destroy AS area";
    121121        }
    122        
     122
    123123        return NULL;
    124124}
  • uspace/app/tester/mm/pager1.c

    r3061bc1 ra35b458  
    7171                return NULL;
    7272        }
    73        
     73
    7474        TPRINTF("Creating AS area...\n");
    75        
     75
    7676        void *result = async_as_area_create(AS_AREA_ANY, size,
    7777            AS_AREA_READ | AS_AREA_CACHEABLE, vfs_pager_sess, fd, 0, 0);
     
    8080                return NULL;
    8181        }
    82        
     82
    8383        return result;
    8484}
     
    8787{
    8888        TPRINTF("Touching (faulting-in) AS area...\n");
    89        
     89
    9090        volatile char *ptr = (char *) area;
    91        
     91
    9292        char ch;
    9393        while ((ch = *ptr++))
     
    101101        if (!buffer)
    102102                return "Cannot allocate memory";
    103        
     103
    104104        touch_area(buffer, buffer_len);
    105105
    106106        as_area_destroy(buffer);
    107107        vfs_put(fd);
    108        
     108
    109109        return NULL;
    110110}
Note: See TracChangeset for help on using the changeset viewer.