Changeset a35b458 in mainline for kernel/generic/src/log/log.c


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

    r3061bc1 ra35b458  
    121121                len = LOG_LENGTH - log_current_len;
    122122        }
    123        
     123
    124124        if (len == 0)
    125125                return;
    126        
     126
    127127        size_t log_free = LOG_LENGTH - log_used - log_current_len;
    128        
     128
    129129        /* Discard older entries to make space, if necessary */
    130130        while (len > log_free) {
     
    136136                next_for_uspace -= entry_len;
    137137        }
    138        
     138
    139139        size_t pos = (log_current_start + log_current_len) % LOG_LENGTH;
    140140        log_copy_to(data, pos, len);
     
    151151        spinlock_lock(&log_lock);
    152152        spinlock_lock(&kio_lock);
    153        
     153
    154154        log_current_start = (log_start + log_used) % LOG_LENGTH;
    155155        log_current_len = 0;
    156        
     156
    157157        /* Write header of the log entry, the length will be written in log_end() */
    158158        log_append((uint8_t *) &log_current_len, sizeof(size_t));
     
    162162        log_append((uint8_t *) &fac32, sizeof(uint32_t));
    163163        log_append((uint8_t *) &lvl32, sizeof(uint32_t));
    164        
     164
    165165        log_counter++;
    166166}
     
    174174        log_copy_to((uint8_t *) &log_current_len, log_current_start, sizeof(size_t));
    175175        log_used += log_current_len;
    176        
     176
    177177        kio_push_char('\n');
    178178        spinlock_unlock(&kio_lock);
    179179        spinlock_unlock(&log_lock);
    180        
     180
    181181        /* This has to be called after we released the locks above */
    182182        kio_flush();
     
    189189        if (!atomic_get(&log_inited))
    190190                return;
    191        
     191
    192192        spinlock_lock(&log_lock);
    193193        if (next_for_uspace < log_used)
     
    200200        size_t offset = 0;
    201201        size_t chars = 0;
    202        
     202
    203203        while (offset < size) {
    204204                kio_push_char(str_decode(str, &offset, size));
    205205                chars++;
    206206        }
    207        
     207
    208208        log_append((const uint8_t *)str, size);
    209        
     209
    210210        return chars;
    211211}
     
    216216        size_t offset = 0;
    217217        size_t chars = 0;
    218        
     218
    219219        for (offset = 0; offset < size; offset += sizeof(wchar_t), chars++) {
    220220                kio_push_char(wstr[chars]);
    221                
     221
    222222                size_t buffer_offset = 0;
    223223                errno_t rc = chr_encode(wstr[chars], buffer, &buffer_offset, 16);
     
    225225                        return EOF;
    226226                }
    227                
     227
    228228                log_append((const uint8_t *)buffer, buffer_offset);
    229229        }
    230        
     230
    231231        return chars;
    232232}
     
    239239{
    240240        int ret;
    241        
     241
    242242        printf_spec_t ps = {
    243243                log_printf_str_write,
     
    245245                NULL
    246246        };
    247        
    248        
     247
     248
    249249        ret = printf_core(fmt, &ps, args);
    250        
     250
    251251        return ret;
    252252}
     
    260260        int ret;
    261261        va_list args;
    262        
     262
    263263        va_start(args, fmt);
    264264        ret = log_vprintf(fmt, args);
    265265        va_end(args);
    266        
     266
    267267        return ret;
    268268}
     
    278278        int ret;
    279279        va_list args;
    280        
     280
    281281        log_begin(fac, level);
    282        
     282
    283283        va_start(args, fmt);
    284284        ret = log_vprintf(fmt, args);
    285285        va_end(args);
    286        
     286
    287287        log_end();
    288        
     288
    289289        return ret;
    290290}
     
    298298        char *data;
    299299        errno_t rc;
    300        
     300
    301301        if (size > PAGE_SIZE)
    302302                return (sys_errno_t) ELIMIT;
    303        
     303
    304304        switch (operation) {
    305305                case KLOG_WRITE:
     
    307307                        if (!data)
    308308                                return (sys_errno_t) ENOMEM;
    309                        
     309
    310310                        rc = copy_from_uspace(data, buf, size);
    311311                        if (rc) {
     
    314314                        }
    315315                        data[size] = 0;
    316                        
     316
    317317                        if (level >= LVL_LIMIT)
    318318                                level = LVL_NOTE;
    319                        
     319
    320320                        log(LF_USPACE, level, "%s", data);
    321                        
     321
    322322                        free(data);
    323323                        return EOK;
     
    326326                        if (!data)
    327327                                return (sys_errno_t) ENOMEM;
    328                        
     328
    329329                        size_t entry_len = 0;
    330330                        size_t copied = 0;
    331                        
     331
    332332                        rc = EOK;
    333        
     333
    334334                        spinlock_lock(&log_lock);
    335                        
     335
    336336                        while (next_for_uspace < log_used) {
    337337                                size_t pos = (log_start + next_for_uspace) % LOG_LENGTH;
    338338                                log_copy_from((uint8_t *) &entry_len, pos, sizeof(size_t));
    339                                
     339
    340340                                if (entry_len > PAGE_SIZE) {
    341341                                        /*
     
    350350                                        continue;
    351351                                }
    352                                
     352
    353353                                if (size < copied + entry_len) {
    354354                                        if (copied == 0)
     
    356356                                        break;
    357357                                }
    358                                
     358
    359359                                log_copy_from((uint8_t *) (data + copied), pos, entry_len);
    360360                                copied += entry_len;
    361361                                next_for_uspace += entry_len;
    362362                        }
    363                        
     363
    364364                        spinlock_unlock(&log_lock);
    365                        
     365
    366366                        if (rc != EOK) {
    367367                                free(data);
    368368                                return (sys_errno_t) rc;
    369369                        }
    370                        
     370
    371371                        rc = copy_to_uspace(buf, data, size);
    372                        
     372
    373373                        free(data);
    374                        
     374
    375375                        if (rc != EOK)
    376376                                return (sys_errno_t) rc;
    377                        
     377
    378378                        return copy_to_uspace(uspace_nread, &copied, sizeof(copied));
    379379                        return EOK;
Note: See TracChangeset for help on using the changeset viewer.