Changeset a35b458 in mainline for uspace/lib/c/generic/sysinfo.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/c/generic/sysinfo.c

    r3061bc1 ra35b458  
    7373         * and transfer the keys as a single atomic operation.
    7474         */
    75        
     75
    7676        /* Get the keys size */
    7777        errno_t ret = sysinfo_get_keys_size(path, size);
     
    8383                return NULL;
    8484        }
    85        
     85
    8686        char *data = malloc(*size);
    8787        if (data == NULL) {
     
    8989                return NULL;
    9090        }
    91        
     91
    9292        /* Get the data */
    9393        size_t sz;
     
    9999                return data;
    100100        }
    101        
     101
    102102        free(data);
    103103        *size = 0;
     
    166166         * and transfer the data as a single atomic operation.
    167167         */
    168        
     168
    169169        /* Get the binary data size */
    170170        errno_t ret = sysinfo_get_data_size(path, size);
     
    177177                return NULL;
    178178        }
    179        
     179
    180180        void *data = malloc(*size);
    181181        if (data == NULL) {
     
    183183                return NULL;
    184184        }
    185        
     185
    186186        /* Get the data */
    187187        size_t sz;
     
    193193                return data;
    194194        }
    195        
     195
    196196        free(data);
    197197        *size = 0;
     
    219219                return NULL;
    220220        }
    221        
     221
    222222        size_t pos = 0;
    223223        while (pos < total_size) {
     
    226226                if (((char *) data)[pos + cur_size] != 0)
    227227                        break;
    228                
     228
    229229                bool found = (str_cmp(data + pos, name) == 0);
    230                
     230
    231231                pos += cur_size + 1;
    232232                if (pos >= total_size)
    233233                        break;
    234                
     234
    235235                /* Process value size */
    236236                size_t value_size;
    237237                memcpy(&value_size, data + pos, sizeof(value_size));
    238                
     238
    239239                pos += sizeof(value_size);
    240240                if ((pos >= total_size) || (pos + value_size > total_size))
    241241                        break;
    242                
     242
    243243                if (found) {
    244244                        void *value = malloc(value_size);
    245245                        if (value == NULL)
    246246                                break;
    247                        
     247
    248248                        memcpy(value, data + pos, value_size);
    249249                        free(data);
    250                        
     250
    251251                        *size = value_size;
    252252                        return value;
    253253                }
    254                
     254
    255255                pos += value_size;
    256256        }
    257        
     257
    258258        free(data);
    259        
     259
    260260        *size = 0;
    261261        return NULL;
Note: See TracChangeset for help on using the changeset viewer.