Changeset a35b458 in mainline for uspace/srv/devman/match.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
  • uspace/srv/devman/match.c

    r3061bc1 ra35b458  
    6969        link_t *drv_head = &drv->match_ids.ids.head;
    7070        link_t *dev_head = &dev->pfun->match_ids.ids.head;
    71        
     71
    7272        if (list_empty(&drv->match_ids.ids) ||
    7373            list_empty(&dev->pfun->match_ids.ids)) {
    7474                return 0;
    7575        }
    76        
     76
    7777        /*
    7878         * Go through all pairs, return the highest score obtained.
    7979         */
    8080        int highest_score = 0;
    81        
     81
    8282        link_t *drv_link = drv->match_ids.ids.head.next;
    8383        while (drv_link != drv_head) {
     
    8686                        match_id_t *drv_id = list_get_instance(drv_link, match_id_t, link);
    8787                        match_id_t *dev_id = list_get_instance(dev_link, match_id_t, link);
    88                        
     88
    8989                        int score = compute_match_score(drv_id, dev_id);
    9090                        if (score > highest_score) {
     
    9494                        dev_link = dev_link->next;
    9595                }
    96                
     96
    9797                drv_link = drv_link->next;
    9898        }
    99        
     99
    100100        return highest_score;
    101101}
     
    111111        char *res = NULL;
    112112        size_t len = get_nonspace_len(*buf);
    113        
     113
    114114        if (len > 0) {
    115115                res = malloc(len + 1);
     
    119119                }
    120120        }
    121        
     121
    122122        return res;
    123123}
     
    141141        char *id = NULL;
    142142        int ids_read = 0;
    143        
     143
    144144        while (true) {
    145145                /* skip spaces */
     
    151151                        continue;
    152152                }
    153                
     153
    154154                /* read score */
    155155                score = strtoul(buf, &buf, 10);
    156                
     156
    157157                /* skip spaces */
    158158                if (!skip_spaces(&buf))
    159159                        break;
    160                
     160
    161161                /* read id */
    162162                id = read_match_id(&buf);
    163163                if (NULL == id)
    164164                        break;
    165                
     165
    166166                /* create new match_id structure */
    167167                match_id_t *mid = create_match_id();
    168168                mid->id = id;
    169169                mid->score = score;
    170                
     170
    171171                /* add it to the list */
    172172                add_match_id(ids, mid);
    173                
     173
    174174                ids_read++;
    175175        }
    176        
     176
    177177        return ids_read > 0;
    178178}
     
    194194{
    195195        log_msg(LOG_DEFAULT, LVL_DEBUG, "read_match_ids(conf_path=\"%s\")", conf_path);
    196        
     196
    197197        bool suc = false;
    198198        char *buf = NULL;
     
    201201        size_t len = 0;
    202202        vfs_stat_t st;
    203        
     203
    204204        errno_t rc = vfs_lookup_open(conf_path, WALK_REGULAR, MODE_READ, &fd);
    205205        if (rc != EOK) {
     
    209209        }
    210210        opened = true;
    211        
     211
    212212        rc = vfs_stat(fd, &st);
    213213        if (rc != EOK) {
     
    222222                goto cleanup;
    223223        }
    224        
     224
    225225        buf = malloc(len + 1);
    226226        if (buf == NULL) {
     
    229229                goto cleanup;
    230230        }
    231        
     231
    232232        size_t read_bytes;
    233233        rc = vfs_read(fd, (aoff64_t []) {0}, buf, len, &read_bytes);
     
    238238        }
    239239        buf[read_bytes] = 0;
    240        
     240
    241241        suc = parse_match_ids(buf, ids);
    242        
     242
    243243cleanup:
    244244        free(buf);
    245        
     245
    246246        if (opened)
    247247                vfs_put(fd);
    248        
     248
    249249        return suc;
    250250}
Note: See TracChangeset for help on using the changeset viewer.