Changeset a35b458 in mainline for uspace/lib/ext4/src/bitmap.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/lib/ext4/src/bitmap.c

    r3061bc1 ra35b458  
    5252        uint32_t byte_index = index / 8;
    5353        uint32_t bit_index = index % 8;
    54        
     54
    5555        uint8_t *target = bitmap + byte_index;
    56        
     56
    5757        *target &= ~ (1 << bit_index);
    5858}
     
    7373        uint32_t remaining = count;
    7474        uint32_t byte_index;
    75        
     75
    7676        /* Align index to multiple of 8 */
    7777        while (((idx % 8) != 0) && (remaining > 0)) {
    7878                byte_index = idx / 8;
    7979                uint32_t bit_index = idx % 8;
    80                
     80
    8181                target = bitmap + byte_index;
    8282                *target &= ~ (1 << bit_index);
    83                
     83
    8484                idx++;
    8585                remaining--;
    8686        }
    87        
     87
    8888        /* For < 8 bits this check necessary */
    8989        if (remaining == 0)
    9090                return;
    91        
     91
    9292        assert((idx % 8) == 0);
    93        
     93
    9494        byte_index = idx / 8;
    9595        target = bitmap + byte_index;
    96        
     96
    9797        /* Zero the whole bytes */
    9898        while (remaining >= 8) {
    9999                *target = 0;
    100                
     100
    101101                idx += 8;
    102102                remaining -= 8;
    103103                target++;
    104104        }
    105        
     105
    106106        assert(remaining < 8);
    107        
     107
    108108        /* Zero remaining bytes */
    109109        while (remaining != 0) {
    110110                byte_index = idx / 8;
    111111                uint32_t bit_index = idx % 8;
    112                
     112
    113113                target = bitmap + byte_index;
    114114                *target &= ~ (1 << bit_index);
    115                
     115
    116116                idx++;
    117117                remaining--;
     
    129129        uint32_t byte_index = index / 8;
    130130        uint32_t bit_index = index % 8;
    131        
     131
    132132        uint8_t *target = bitmap + byte_index;
    133        
     133
    134134        *target |= 1 << bit_index;
    135135}
     
    147147        uint32_t byte_index = index / 8;
    148148        uint32_t bit_index = index % 8;
    149        
     149
    150150        uint8_t *target = bitmap + byte_index;
    151        
     151
    152152        if (*target & (1 << bit_index))
    153153                return false;
     
    173173{
    174174        uint32_t idx;
    175        
     175
    176176        /* Align idx */
    177177        if (start % 8)
     
    179179        else
    180180                idx = start;
    181        
     181
    182182        uint8_t *pos = bitmap + (idx / 8);
    183        
     183
    184184        /* Try to find free byte */
    185185        while (idx < max) {
    186186                if (*pos == 0) {
    187187                        *pos |= 1;
    188                        
     188
    189189                        *index = idx;
    190190                        return EOK;
    191191                }
    192                
     192
    193193                idx += 8;
    194194                ++pos;
    195195        }
    196        
     196
    197197        /* Free byte not found */
    198198        return ENOSPC;
     
    217217        uint32_t idx = start_idx;
    218218        bool byte_part = false;
    219        
     219
    220220        /* Check the rest of first byte */
    221221        while ((idx % 8) != 0) {
    222222                byte_part = true;
    223                
     223
    224224                if ((*pos & (1 << (idx % 8))) == 0) {
    225225                        *pos |= (1 << (idx % 8));
     
    227227                        return EOK;
    228228                }
    229                
     229
    230230                ++idx;
    231231        }
    232        
     232
    233233        if (byte_part)
    234234                ++pos;
    235        
     235
    236236        /* Check the whole bytes (255 = 11111111 binary) */
    237237        while (idx < max) {
     
    240240                        break;
    241241                }
    242                
     242
    243243                idx += 8;
    244244                ++pos;
    245245        }
    246        
     246
    247247        /* If idx < max, some free bit found */
    248248        if (idx < max) {
     
    252252                                /* Free bit found */
    253253                                *pos |= (1 << i);
    254                                
     254
    255255                                *index = idx;
    256256                                return EOK;
    257257                        }
    258                        
     258
    259259                        idx++;
    260260                }
    261261        }
    262        
     262
    263263        /* Free bit not found */
    264264        return ENOSPC;
Note: See TracChangeset for help on using the changeset viewer.