Changeset a35b458 in mainline for uspace/srv/klog


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
  • uspace/srv/klog/klog.c

    r3061bc1 ra35b458  
    6161        uint32_t level;
    6262        char message[0];
    63        
     63
    6464} __attribute__((__packed__)) log_entry_t;
    6565
     
    107107                return;
    108108        }
    109        
     109
    110110        size_t offset = 0;
    111111        while (offset < len) {
    112112                size_t entry_len = *((unaligned_size_t *) (buffer + offset));
    113                
     113
    114114                if (offset + entry_len > len || entry_len < sizeof(log_entry_t))
    115115                        break;
    116                
     116
    117117                log_entry_t *buf = malloc(entry_len + 1);
    118118                if (buf == NULL)
    119119                        break;
    120                
     120
    121121                item_t *item = malloc(sizeof(item_t));
    122122                if (item == NULL) {
     
    124124                        break;
    125125                }
    126                
     126
    127127                memcpy(buf, buffer + offset, entry_len);
    128128                *((uint8_t *) buf + entry_len) = 0;
     
    131131                item->data = buf;
    132132                prodcons_produce(&pc, &item->link);
    133                
     133
    134134                offset += entry_len;
    135135        }
     
    148148static errno_t consumer(void *data)
    149149{
    150        
     150
    151151        while (true) {
    152152                link_t *link = prodcons_consume(&pc);
    153153                item_t *item = list_get_instance(link, item_t, link);
    154                
     154
    155155                if (item->size < sizeof(log_entry_t)) {
    156156                        free(item->data);
     
    158158                        continue;
    159159                }
    160                
     160
    161161                if (item->data->facility == LF_USPACE) {
    162162                        /* Avoid reposting messages */
     
    165165                        continue;
    166166                }
    167                
     167
    168168                log_t ctx = kernel_ctx;
    169169                if (item->data->facility < facility_len) {
    170170                        ctx = facility_ctx[item->data->facility];
    171171                }
    172                
     172
    173173                log_level_t lvl = item->data->level;
    174174                if (lvl > LVL_LIMIT)
    175175                        lvl = LVL_NOTE;
    176                
     176
    177177                log_msg(ctx, lvl, "%s", item->data->message);
    178                
     178
    179179                free(item->data);
    180180                free(item);
    181181        }
    182        
     182
    183183        return EOK;
    184184}
     
    199199         * starving.
    200200         */
    201        
     201
    202202        fibril_mutex_lock(&mtx);
    203        
     203
    204204        producer();
    205        
     205
    206206        async_event_unmask(EVENT_KLOG);
    207207        fibril_mutex_unlock(&mtx);
     
    215215                return rc;
    216216        }
    217        
     217
    218218        kernel_ctx = log_create("kernel", LOG_NO_PARENT);
    219219        for (unsigned int i = 0; i < facility_len; i++) {
    220220                facility_ctx[i] = log_create(facility_name[i], kernel_ctx);
    221221        }
    222        
     222
    223223        buffer = malloc(BUFFER_SIZE);
    224224        if (buffer == NULL) {
     
    226226                return 1;
    227227        }
    228        
     228
    229229        prodcons_initialize(&pc);
    230230        rc = async_event_subscribe(EVENT_KLOG, klog_notification_received, NULL);
     
    234234                return rc;
    235235        }
    236        
     236
    237237        fid_t fid = fibril_create(consumer, NULL);
    238238        if (!fid) {
     
    241241                return ENOMEM;
    242242        }
    243        
     243
    244244        fibril_add_ready(fid);
    245245        async_event_unmask(EVENT_KLOG);
    246        
     246
    247247        fibril_mutex_lock(&mtx);
    248248        producer();
    249249        fibril_mutex_unlock(&mtx);
    250        
     250
    251251        task_retval(0);
    252252        async_manager();
    253        
     253
    254254        return 0;
    255255}
Note: See TracChangeset for help on using the changeset viewer.