Changeset a35b458 in mainline for kernel/generic/src/console/cmd.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/cmd.c

    r3061bc1 ra35b458  
    686686{
    687687        spinlock_lock(&cmd_lock);
    688        
     688
    689689        size_t len = 0;
    690690        list_foreach(cmd_list, link, cmd_info_t, hlp) {
     
    694694                spinlock_unlock(&hlp->lock);
    695695        }
    696        
     696
    697697        unsigned int _len = (unsigned int) len;
    698698        if ((_len != len) || (((int) _len) < 0)) {
     
    700700                return 1;
    701701        }
    702        
     702
    703703        list_foreach(cmd_list, link, cmd_info_t, hlp) {
    704704                spinlock_lock(&hlp->lock);
     
    706706                spinlock_unlock(&hlp->lock);
    707707        }
    708        
     708
    709709        spinlock_unlock(&cmd_lock);
    710        
     710
    711711        return 1;
    712712}
     
    721721{
    722722        uint8_t *ptr = NULL;
    723        
     723
    724724#ifdef IO_SPACE_BOUNDARY
    725725        if ((void *) argv->intval < IO_SPACE_BOUNDARY)
     
    729729                ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t),
    730730                    PAGE_NOT_CACHEABLE);
    731        
     731
    732732        const uint8_t val = pio_read_8(ptr);
    733733        printf("read %" PRIxn ": %" PRIx8 "\n", argv[0].intval, val);
    734        
     734
    735735#ifdef IO_SPACE_BOUNDARY
    736736        if ((void *) argv->intval < IO_SPACE_BOUNDARY)
    737737                return 1;
    738738#endif
    739        
     739
    740740        km_unmap((uintptr_t) ptr, sizeof(uint8_t));
    741741        return 1;
     
    751751{
    752752        uint16_t *ptr = NULL;
    753        
     753
    754754#ifdef IO_SPACE_BOUNDARY
    755755        if ((void *) argv->intval < IO_SPACE_BOUNDARY)
     
    759759                ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t),
    760760                    PAGE_NOT_CACHEABLE);
    761        
     761
    762762        const uint16_t val = pio_read_16(ptr);
    763763        printf("read %" PRIxn ": %" PRIx16 "\n", argv[0].intval, val);
    764        
     764
    765765#ifdef IO_SPACE_BOUNDARY
    766766        if ((void *) argv->intval < IO_SPACE_BOUNDARY)
    767767                return 1;
    768768#endif
    769        
     769
    770770        km_unmap((uintptr_t) ptr, sizeof(uint16_t));
    771771        return 1;
     
    781781{
    782782        uint32_t *ptr = NULL;
    783        
     783
    784784#ifdef IO_SPACE_BOUNDARY
    785785        if ((void *) argv->intval < IO_SPACE_BOUNDARY)
     
    789789                ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t),
    790790                    PAGE_NOT_CACHEABLE);
    791        
     791
    792792        const uint32_t val = pio_read_32(ptr);
    793793        printf("read %" PRIxn ": %" PRIx32 "\n", argv[0].intval, val);
    794        
     794
    795795#ifdef IO_SPACE_BOUNDARY
    796796        if ((void *) argv->intval < IO_SPACE_BOUNDARY)
    797797                return 1;
    798798#endif
    799        
     799
    800800        km_unmap((uintptr_t) ptr, sizeof(uint32_t));
    801801        return 1;
     
    811811{
    812812        uint8_t *ptr = NULL;
    813        
     813
    814814#ifdef IO_SPACE_BOUNDARY
    815815        if ((void *) argv->intval < IO_SPACE_BOUNDARY)
     
    819819                ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t),
    820820                    PAGE_NOT_CACHEABLE);
    821        
     821
    822822        printf("write %" PRIxn ": %" PRIx8 "\n", argv[0].intval,
    823823            (uint8_t) argv[1].intval);
    824824        pio_write_8(ptr, (uint8_t) argv[1].intval);
    825        
     825
    826826#ifdef IO_SPACE_BOUNDARY
    827827        if ((void *) argv->intval < IO_SPACE_BOUNDARY)
    828828                return 1;
    829829#endif
    830        
     830
    831831        km_unmap((uintptr_t) ptr, sizeof(uint8_t));
    832832        return 1;
     
    842842{
    843843        uint16_t *ptr = NULL;
    844        
     844
    845845#ifdef IO_SPACE_BOUNDARY
    846846        if ((void *) argv->intval < IO_SPACE_BOUNDARY)
     
    850850                ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t),
    851851                    PAGE_NOT_CACHEABLE);
    852        
     852
    853853        printf("write %" PRIxn ": %" PRIx16 "\n", argv[0].intval,
    854854            (uint16_t) argv[1].intval);
    855855        pio_write_16(ptr, (uint16_t) argv[1].intval);
    856        
     856
    857857#ifdef IO_SPACE_BOUNDARY
    858858        if ((void *) argv->intval < IO_SPACE_BOUNDARY)
    859859                return 1;
    860860#endif
    861        
     861
    862862        km_unmap((uintptr_t) ptr, sizeof(uint16_t));
    863863        return 1;
     
    873873{
    874874        uint32_t *ptr = NULL;
    875        
     875
    876876#ifdef IO_SPACE_BOUNDARY
    877877        if ((void *) argv->intval < IO_SPACE_BOUNDARY)
     
    881881                ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t),
    882882                    PAGE_NOT_CACHEABLE);
    883        
     883
    884884        printf("write %" PRIxn ": %" PRIx32 "\n", argv[0].intval,
    885885            (uint32_t) argv[1].intval);
    886886        pio_write_32(ptr, (uint32_t) argv[1].intval);
    887        
     887
    888888#ifdef IO_SPACE_BOUNDARY
    889889        if ((void *) argv->intval < IO_SPACE_BOUNDARY)
    890890                return 1;
    891891#endif
    892        
     892
    893893        km_unmap((uintptr_t) ptr, sizeof(uint32_t));
    894894        return 1;
     
    904904{
    905905        reboot();
    906        
     906
    907907        /* Not reached */
    908908        return 1;
     
    918918{
    919919        assert(uptime);
    920        
     920
    921921        /* This doesn't have to be very accurate */
    922922        sysarg_t sec = uptime->seconds1;
    923        
     923
    924924        printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n",
    925925                sec / 86400, (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60);
    926        
     926
    927927        return 1;
    928928}
     
    937937{
    938938        spinlock_lock(&cmd_lock);
    939        
     939
    940940        list_foreach(cmd_list, link, cmd_info_t, hlp) {
    941941                spinlock_lock(&hlp->lock);
    942                
     942
    943943                if (str_lcmp(hlp->name, (const char *) argv->buffer, str_length(hlp->name)) == 0) {
    944944                        printf("%s - %s\n", hlp->name, hlp->description);
     
    948948                        break;
    949949                }
    950                
     950
    951951                spinlock_unlock(&hlp->lock);
    952952        }
    953        
     953
    954954        spinlock_unlock(&cmd_lock);
    955        
     955
    956956        return 1;
    957957}
     
    961961{
    962962        symtab_print_search((char *) argv->buffer);
    963        
     963
    964964        return 1;
    965965}
     
    10041004         * call the function.
    10051005         */
    1006        
     1006
    10071007        unsigned int i;
    10081008        for (i = 0; i < config.cpu_count; i++) {
    10091009                if (!cpus[i].active)
    10101010                        continue;
    1011                
     1011
    10121012                thread_t *thread;
    10131013                if ((thread = thread_create((void (*)(void *)) cmd_call0,
     
    10211021                        printf("Unable to create thread for cpu%u\n", i);
    10221022        }
    1023        
     1023
    10241024        return 1;
    10251025}
     
    11081108        fncptr_t fptr;
    11091109        errno_t rc;
    1110        
     1110
    11111111        symbol = (char *) argv->buffer;
    11121112        rc = symtab_addr_lookup(symbol, &symaddr);
     
    11831183        bool pointer = false;
    11841184        errno_t rc;
    1185        
     1185
    11861186        if (((char *) argv->buffer)[0] == '*') {
    11871187                rc = symtab_addr_lookup((char *) argv->buffer + 1, &addr);
     
    11951195        } else
    11961196                rc = symtab_addr_lookup((char *) argv->buffer, &addr);
    1197        
     1197
    11981198        if (rc == ENOENT)
    11991199                printf("Symbol %s not found.\n", (char *) argv->buffer);
     
    12101210        } else
    12111211                printf("No symbol information available.\n");
    1212        
     1212
    12131213        return 1;
    12141214}
     
    12521252        else
    12531253                printf("Unknown argument \"%s\".\n", flag_buf);
    1254        
     1254
    12551255        return 1;
    12561256}
     
    12701270        else
    12711271                printf("Unknown argument \"%s\".\n", flag_buf);
    1272        
     1272
    12731273        return 1;
    12741274}
     
    14121412        release_console();
    14131413        indev_pop_character(stdin);
    1414        
     1414
    14151415        return 1;
    14161416}
     
    14201420{
    14211421        printf("%s (%s)\n", test->name, test->desc);
    1422        
     1422
    14231423        /* Update and read thread accounting
    14241424           for benchmarking */
     
    14271427        task_get_accounting(TASK, &ucycles0, &kcycles0);
    14281428        irq_spinlock_unlock(&TASK->lock, true);
    1429        
     1429
    14301430        /* Execute the test */
    14311431        test_quiet = false;
    14321432        const char *ret = test->entry();
    1433        
     1433
    14341434        /* Update and read thread accounting */
    14351435        uint64_t ucycles1, kcycles1;
     
    14371437        task_get_accounting(TASK, &ucycles1, &kcycles1);
    14381438        irq_spinlock_unlock(&TASK->lock, true);
    1439        
     1439
    14401440        uint64_t ucycles, kcycles;
    14411441        char usuffix, ksuffix;
    14421442        order_suffix(ucycles1 - ucycles0, &ucycles, &usuffix);
    14431443        order_suffix(kcycles1 - kcycles0, &kcycles, &ksuffix);
    1444        
     1444
    14451445        printf("Time: %" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles\n",
    14461446            ucycles, usuffix, kcycles, ksuffix);
    1447        
     1447
    14481448        if (ret == NULL) {
    14491449                printf("Test passed\n");
    14501450                return true;
    14511451        }
    1452        
     1452
    14531453        printf("%s\n", ret);
    14541454        return false;
     
    14611461        uint64_t ucycles, kcycles;
    14621462        char usuffix, ksuffix;
    1463        
     1463
    14641464        if (cnt < 1)
    14651465                return true;
    1466        
     1466
    14671467        uint64_t *data = (uint64_t *) malloc(sizeof(uint64_t) * cnt, 0);
    14681468        if (data == NULL) {
     
    14701470                return false;
    14711471        }
    1472        
     1472
    14731473        for (i = 0; i < cnt; i++) {
    14741474                printf("%s (%u/%u) ... ", test->name, i + 1, cnt);
    1475                
     1475
    14761476                /* Update and read thread accounting
    14771477                   for benchmarking */
     
    14801480                task_get_accounting(TASK, &ucycles0, &kcycles0);
    14811481                irq_spinlock_unlock(&TASK->lock, true);
    1482                
     1482
    14831483                /* Execute the test */
    14841484                test_quiet = true;
    14851485                const char *test_ret = test->entry();
    1486                
     1486
    14871487                /* Update and read thread accounting */
    14881488                irq_spinlock_lock(&TASK->lock, true);
     
    14901490                task_get_accounting(TASK, &ucycles1, &kcycles1);
    14911491                irq_spinlock_unlock(&TASK->lock, true);
    1492                
     1492
    14931493                if (test_ret != NULL) {
    14941494                        printf("%s\n", test_ret);
     
    14961496                        break;
    14971497                }
    1498                
     1498
    14991499                data[i] = ucycles1 - ucycles0 + kcycles1 - kcycles0;
    15001500                order_suffix(ucycles1 - ucycles0, &ucycles, &usuffix);
     
    15031503                    ucycles, usuffix, kcycles, ksuffix);
    15041504        }
    1505        
     1505
    15061506        if (ret) {
    15071507                printf("\n");
    1508                
     1508
    15091509                uint64_t sum = 0;
    1510                
     1510
    15111511                for (i = 0; i < cnt; i++) {
    15121512                        sum += data[i];
    15131513                }
    1514                
     1514
    15151515                order_suffix(sum / (uint64_t) cnt, &ucycles, &usuffix);
    15161516                printf("Average\t\t%" PRIu64 "%c\n", ucycles, usuffix);
    15171517        }
    1518        
     1518
    15191519        free(data);
    1520        
     1520
    15211521        return ret;
    15221522}
     
    15261526        size_t len = 0;
    15271527        test_t *test;
    1528        
     1528
    15291529        for (test = tests; test->name != NULL; test++) {
    15301530                if (str_length(test->name) > len)
    15311531                        len = str_length(test->name);
    15321532        }
    1533        
     1533
    15341534        unsigned int _len = (unsigned int) len;
    15351535        if ((_len != len) || (((int) _len) < 0)) {
     
    15371537                return;
    15381538        }
    1539        
     1539
    15401540        for (test = tests; test->name != NULL; test++)
    15411541                printf("%-*s %s%s\n", _len, test->name, test->desc,
    15421542                    (test->safe ? "" : " (unsafe)"));
    1543        
     1543
    15441544        printf("%-*s Run all safe tests\n", _len, "*");
    15451545}
     
    15551555{
    15561556        test_t *test;
    1557        
     1557
    15581558        if (str_cmp((char *) argv->buffer, "*") == 0) {
    15591559                for (test = tests; test->name != NULL; test++) {
     
    15661566        } else if (str_cmp((char *) argv->buffer, "") != 0) {
    15671567                bool fnd = false;
    1568                
     1568
    15691569                for (test = tests; test->name != NULL; test++) {
    15701570                        if (str_cmp(test->name, (char *) argv->buffer) == 0) {
     
    15741574                        }
    15751575                }
    1576                
     1576
    15771577                if (!fnd)
    15781578                        printf("Unknown test\n");
    15791579        } else
    15801580                list_tests();
    1581        
     1581
    15821582        return 1;
    15831583}
     
    15931593        test_t *test;
    15941594        uint32_t cnt = argv[1].intval;
    1595        
     1595
    15961596        if (str_cmp((char *) argv->buffer, "*") == 0) {
    15971597                for (test = tests; test->name != NULL; test++) {
     
    16031603        } else {
    16041604                bool fnd = false;
    1605                
     1605
    16061606                for (test = tests; test->name != NULL; test++) {
    16071607                        if (str_cmp(test->name, (char *) argv->buffer) == 0) {
    16081608                                fnd = true;
    1609                                
     1609
    16101610                                if (test->safe)
    16111611                                        run_bench(test, cnt);
    16121612                                else
    16131613                                        printf("Unsafe test\n");
    1614                                
     1614
    16151615                                break;
    16161616                        }
    16171617                }
    1618                
     1618
    16191619                if (!fnd)
    16201620                        printf("Unknown test\n");
    16211621        }
    1622        
     1622
    16231623        return 1;
    16241624}
Note: See TracChangeset for help on using the changeset viewer.