Changeset 1433ecda in mainline for uspace/lib/c/generic


Ignore:
Timestamp:
2018-04-04T15:42:37Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2c4e1cc
Parents:
47b2d7e3
Message:

Fix cstyle: make ccheck-fix and commit only files where all the changes are good.

Location:
uspace/lib/c/generic
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/assert.c

    r47b2d7e3 r1433ecda  
    3939#include <stdint.h>
    4040
    41 static atomic_t failed_asserts = {0};
     41static atomic_t failed_asserts = { 0 };
    4242
    4343void __helenos_assert_quick_abort(const char *cond, const char *file, unsigned int line)
  • uspace/lib/c/generic/cap.c

    r47b2d7e3 r1433ecda  
    211211{
    212212        switch (c) {
    213         case '0': *val = 0; break;
    214         case '1': *val = 1; break;
    215         case '2': *val = 2; break;
    216         case '3': *val = 3; break;
    217         case '4': *val = 4; break;
    218         case '5': *val = 5; break;
    219         case '6': *val = 6; break;
    220         case '7': *val = 7; break;
    221         case '8': *val = 8; break;
    222         case '9': *val = 9; break;
     213        case '0':
     214                *val = 0;
     215                break;
     216        case '1':
     217                *val = 1;
     218                break;
     219        case '2':
     220                *val = 2;
     221                break;
     222        case '3':
     223                *val = 3;
     224                break;
     225        case '4':
     226                *val = 4;
     227                break;
     228        case '5':
     229                *val = 5;
     230                break;
     231        case '6':
     232                *val = 6;
     233                break;
     234        case '7':
     235                *val = 7;
     236                break;
     237        case '8':
     238                *val = 8;
     239                break;
     240        case '9':
     241                *val = 9;
     242                break;
    223243        default:
    224244                return EINVAL;
     
    275295
    276296                return EINVAL;
    277 found:
     297        found:
    278298                cap->cunit = i;
    279299        }
  • uspace/lib/c/generic/elf/elf_load.c

    r47b2d7e3 r1433ecda  
    7777        DPRINTF("Binary is dynamically linked.\n");
    7878#ifdef CONFIG_RTLD
    79         DPRINTF( "- prog dynamic: %p\n", info->finfo.dynamic);
     79        DPRINTF("- prog dynamic: %p\n", info->finfo.dynamic);
    8080
    8181        errno_t rc2 = rtld_prog_process(&info->finfo, &env);
  • uspace/lib/c/generic/fibril_synch.c

    r47b2d7e3 r1433ecda  
    7777                    context_get_pc(&oi->owned_by->ctx));
    7878                printf("Fibril %p waits for primitive %p.\n",
    79                      oi->owned_by, oi->owned_by->waits_for);
     79                    oi->owned_by, oi->owned_by->waits_for);
    8080                oi = oi->owned_by->waits_for;
    8181        }
     
    354354
    355355errno_t
    356 fibril_condvar_wait_timeout(fibril_condvar_t *fcv, fibril_mutex_t *fm,
     356    fibril_condvar_wait_timeout(fibril_condvar_t *fcv, fibril_mutex_t *fm,
    357357    suseconds_t timeout)
    358358{
  • uspace/lib/c/generic/inet/addr.c

    r47b2d7e3 r1433ecda  
    4949
    5050#if !(defined(__BE__) ^ defined(__LE__))
    51         #error The architecture must be either big-endian or little-endian.
     51#error The architecture must be either big-endian or little-endian.
    5252#endif
    5353
     
    6969static const inet_addr_t inet_addr_any_addr6 = {
    7070        .version = ip_v6,
    71         .addr6 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
     71        .addr6 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
    7272};
    7373
  • uspace/lib/c/generic/io/printf_core.c

    r47b2d7e3 r1433ecda  
    593593/** Prints a special double (ie NaN, infinity) padded to width characters. */
    594594static int print_special(ieee_double_t val, int width, uint32_t flags,
    595         printf_spec_t *ps)
     595    printf_spec_t *ps)
    596596{
    597597        assert(val.is_special);
     
    702702 */
    703703static int print_double_str_fixed(double_str_t *val_str, int precision, int width,
    704         uint32_t flags, printf_spec_t *ps)
     704    uint32_t flags, printf_spec_t *ps)
    705705{
    706706        int len = val_str->len;
     
    840840 */
    841841static int print_double_fixed(double g, int precision, int width, uint32_t flags,
    842         printf_spec_t *ps)
     842    printf_spec_t *ps)
    843843{
    844844        if (flags & __PRINTF_FLAG_LEFTALIGNED) {
     
    869869                 */
    870870                val_str.len = double_to_fixed_str(val, -1, precision + 1, buf, buf_size,
    871                         &val_str.dec_exp);
     871                    &val_str.dec_exp);
    872872
    873873                /*
     
    919919
    920920        exp_str[0] = '0' + exp_val / 100;
    921         exp_str[1] = '0' + (exp_val % 100) / 10 ;
     921        exp_str[1] = '0' + (exp_val % 100) / 10;
    922922        exp_str[2] = '0' + (exp_val % 10);
    923923
     
    938938 */
    939939static int print_double_str_scient(double_str_t *val_str, int precision,
    940         int width, uint32_t flags, printf_spec_t *ps)
     940    int width, uint32_t flags, printf_spec_t *ps)
    941941{
    942942        int len = val_str->len;
     
    10621062 */
    10631063static int print_double_scientific(double g, int precision, int width,
    1064         uint32_t flags, printf_spec_t *ps)
     1064    uint32_t flags, printf_spec_t *ps)
    10651065{
    10661066        if (flags & __PRINTF_FLAG_LEFTALIGNED) {
     
    10881088                 */
    10891089                val_str.len = double_to_fixed_str(val, precision + 2, -1, buf, buf_size,
    1090                         &val_str.dec_exp);
     1090                    &val_str.dec_exp);
    10911091
    10921092                /*
     
    11291129 */
    11301130static int print_double_generic(double g, int precision, int width,
    1131         uint32_t flags, printf_spec_t *ps)
     1131    uint32_t flags, printf_spec_t *ps)
    11321132{
    11331133        ieee_double_t val = extract_ieee_double(g);
     
    11561156                        precision = precision - (dec_exp + 1);
    11571157                        return print_double_fixed(g, precision, width,
    1158                                 flags | __PRINTF_FLAG_NOFRACZEROS, ps);
     1158                            flags | __PRINTF_FLAG_NOFRACZEROS, ps);
    11591159                } else {
    11601160                        --precision;
    11611161                        return print_double_scientific(g, precision, width,
    1162                                 flags | __PRINTF_FLAG_NOFRACZEROS, ps);
     1162                            flags | __PRINTF_FLAG_NOFRACZEROS, ps);
    11631163                }
    11641164        } else {
     
    12141214 */
    12151215static int print_double(double g, char spec, int precision, int width,
    1216         uint32_t flags, printf_spec_t *ps)
     1216    uint32_t flags, printf_spec_t *ps)
    12171217{
    12181218        switch (spec) {
     
    15431543                        case 'e':
    15441544                                retval = print_double(va_arg(ap, double), uc, precision,
    1545                                         width, flags, ps);
     1545                                    width, flags, ps);
    15461546
    15471547                                if (retval < 0) {
  • uspace/lib/c/generic/io/visualizer.c

    r47b2d7e3 r1433ecda  
    174174errno_t visualizer_update_damaged_region(async_sess_t *sess,
    175175    sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height,
    176         sysarg_t x_offset, sysarg_t y_offset)
     176    sysarg_t x_offset, sysarg_t y_offset)
    177177{
    178178        assert(x_offset <= UINT16_MAX);
  • uspace/lib/c/generic/io/vsnprintf.c

    r47b2d7e3 r1433ecda  
    170170        };
    171171        printf_spec_t ps = {
    172                 (int(*) (const char *, size_t, void *)) vsnprintf_str_write,
    173                 (int(*) (const wchar_t *, size_t, void *)) vsnprintf_wstr_write,
     172                (int (*) (const char *, size_t, void *)) vsnprintf_str_write,
     173                (int (*) (const wchar_t *, size_t, void *)) vsnprintf_wstr_write,
    174174                &data
    175175        };
  • uspace/lib/c/generic/l18n/langs.c

    r47b2d7e3 r1433ecda  
    5454         */
    5555        switch (locale) {
    56                 case L18N_WIN_LOCALE_AFRIKAANS:
    57                         return "Afrikaans";
    58                 case L18N_WIN_LOCALE_CZECH:
    59                         return "Czech";
    60                 case L18N_WIN_LOCALE_ENGLISH_UNITED_STATES:
    61                         return "English (US)";
    62                 case L18N_WIN_LOCALE_SLOVAK:
    63                         return "Slovak";
    64                 case L18N_WIN_LOCALE_SPANISH_TRADITIONAL:
    65                         return "Spanish (traditional)";
    66                 case L18N_WIN_LOCALE_ZULU:
    67                         return "Zulu";
    68                 default:
    69                         break;
     56        case L18N_WIN_LOCALE_AFRIKAANS:
     57                return "Afrikaans";
     58        case L18N_WIN_LOCALE_CZECH:
     59                return "Czech";
     60        case L18N_WIN_LOCALE_ENGLISH_UNITED_STATES:
     61                return "English (US)";
     62        case L18N_WIN_LOCALE_SLOVAK:
     63                return "Slovak";
     64        case L18N_WIN_LOCALE_SPANISH_TRADITIONAL:
     65                return "Spanish (traditional)";
     66        case L18N_WIN_LOCALE_ZULU:
     67                return "Zulu";
     68        default:
     69                break;
    7070        }
    7171
  • uspace/lib/c/generic/libc.c

    r47b2d7e3 r1433ecda  
    138138
    139139        /* Unreachable */
    140         while (1);
     140        while (1)
     141                ;
    141142}
    142143
     
    146147
    147148        /* Unreachable */
    148         while (1);
     149        while (1)
     150                ;
    149151}
    150152
  • uspace/lib/c/generic/mem.c

    r47b2d7e3 r1433ecda  
    5454        word_size = sizeof(unsigned long);
    5555        fill = word_size - ((uintptr_t) dest & (word_size - 1));
    56         if (fill > n) fill = n;
     56        if (fill > n)
     57                fill = n;
    5758
    5859        pb = dest;
     
    6465        /* Compute remaining size. */
    6566        n -= fill;
    66         if (n == 0) return dest;
     67        if (n == 0)
     68                return dest;
    6769
    6870        n_words = n / word_size;
     
    9395struct along {
    9496        unsigned long n;
    95 } __attribute__ ((packed));
     97} __attribute__((packed));
    9698
    9799static void *unaligned_memcpy(void *dst, const void *src, size_t n)
     
    133135        if (((uintptr_t) dst & (word_size - 1)) !=
    134136            ((uintptr_t) src & (word_size - 1)))
    135                 return unaligned_memcpy(dst, src, n);
     137                return unaligned_memcpy(dst, src, n);
    136138
    137139        /*
     
    143145        mod = (uintptr_t) dst & (word_size - 1);
    144146        fill = word_size - mod;
    145         if (fill > n) fill = n;
     147        if (fill > n)
     148                fill = n;
    146149
    147150        /* Copy the initial segment. */
     
    157160
    158161        n -= fill;
    159         if (n == 0) return dst;
     162        if (n == 0)
     163                return dst;
    160164
    161165        /* Pointers to aligned segment. */
  • uspace/lib/c/generic/pio_trace.c

    r47b2d7e3 r1433ecda  
    5050} region_t;
    5151
    52 static inline region_t * region_instance(link_t *l)
     52static inline region_t *region_instance(link_t *l)
    5353{
    5454        return list_get_instance(l, region_t, link);
    5555}
    5656
    57 static inline region_t * region_create(volatile void* base, size_t size,
    58     trace_fnc log, void* data)
     57static inline region_t *region_create(volatile void *base, size_t size,
     58    trace_fnc log, void *data)
    5959{
    6060        region_t *new_reg = malloc(sizeof(region_t));
     
    7979} pio_regions_t;
    8080
    81 static pio_regions_t * get_regions(void)
     81static pio_regions_t *get_regions(void)
    8282{
    8383        static pio_regions_t regions = {
  • uspace/lib/c/generic/rcu.c

    r47b2d7e3 r1433ecda  
    340340                list_foreach_safe(rcu.fibrils_list, fibril_it, next_fibril) {
    341341                        fibril_rcu_data_t *fib = member_to_inst(fibril_it,
    342                                 fibril_rcu_data_t, link);
     342                            fibril_rcu_data_t, link);
    343343
    344344                        if (is_preexisting_reader(fib, reader_group)) {
     
    405405                if (!list_empty(&rcu.sync_lock.blocked_fibrils)) {
    406406                        blocked_fibril_t *blocked_fib = member_to_inst(
    407                                 list_first(&rcu.sync_lock.blocked_fibrils), blocked_fibril_t, link);
     407                            list_first(&rcu.sync_lock.blocked_fibrils), blocked_fibril_t, link);
    408408
    409409                        if (!blocked_fib->is_ready) {
  • uspace/lib/c/generic/rtld/dynamic.c

    r47b2d7e3 r1433ecda  
    6565                d_val = dp->d_un.d_val;
    6666                DPRINTF("tag=%u ptr=0x%x val=%u\n", (unsigned)dp->d_tag,
    67                         (unsigned)d_ptr, (unsigned)d_val);
     67                    (unsigned)d_ptr, (unsigned)d_val);
    6868
    6969                switch (dp->d_tag) {
    7070
    71                 case DT_PLTRELSZ:       info->plt_rel_sz = d_val; break;
    72                 case DT_PLTGOT:         info->plt_got = d_ptr; break;
    73                 case DT_HASH:           info->hash = d_ptr; break;
    74                 case DT_STRTAB:         info->str_tab = d_ptr; break;
    75                 case DT_SYMTAB:         info->sym_tab = d_ptr; break;
    76                 case DT_RELA:           info->rela = d_ptr; break;
    77                 case DT_RELASZ:         info->rela_sz = d_val; break;
    78                 case DT_RELAENT:        info->rela_ent = d_val; break;
    79                 case DT_STRSZ:          info->str_sz = d_val; break;
    80                 case DT_SYMENT:         info->sym_ent = d_val; break;
    81                 case DT_INIT:           info->init = d_ptr; break;
    82                 case DT_FINI:           info->fini = d_ptr; break;
    83                 case DT_SONAME:         soname_idx = d_val; break;
    84                 case DT_RPATH:          rpath_idx = d_val; break;
    85                 case DT_SYMBOLIC:       info->symbolic = true; break;
    86                 case DT_REL:            info->rel = d_ptr; break;
    87                 case DT_RELSZ:          info->rel_sz = d_val; break;
    88                 case DT_RELENT:         info->rel_ent = d_val; break;
    89                 case DT_PLTREL:         info->plt_rel = d_val; break;
    90                 case DT_TEXTREL:        info->text_rel = true; break;
    91                 case DT_JMPREL:         info->jmp_rel = d_ptr; break;
    92                 case DT_BIND_NOW:       info->bind_now = true; break;
     71                case DT_PLTRELSZ:
     72                        info->plt_rel_sz = d_val;
     73                        break;
     74                case DT_PLTGOT:
     75                        info->plt_got = d_ptr;
     76                        break;
     77                case DT_HASH:
     78                        info->hash = d_ptr;
     79                        break;
     80                case DT_STRTAB:
     81                        info->str_tab = d_ptr;
     82                        break;
     83                case DT_SYMTAB:
     84                        info->sym_tab = d_ptr;
     85                        break;
     86                case DT_RELA:
     87                        info->rela = d_ptr;
     88                        break;
     89                case DT_RELASZ:
     90                        info->rela_sz = d_val;
     91                        break;
     92                case DT_RELAENT:
     93                        info->rela_ent = d_val;
     94                        break;
     95                case DT_STRSZ:
     96                        info->str_sz = d_val;
     97                        break;
     98                case DT_SYMENT:
     99                        info->sym_ent = d_val;
     100                        break;
     101                case DT_INIT:
     102                        info->init = d_ptr;
     103                        break;
     104                case DT_FINI:
     105                        info->fini = d_ptr;
     106                        break;
     107                case DT_SONAME:
     108                        soname_idx = d_val;
     109                        break;
     110                case DT_RPATH:
     111                        rpath_idx = d_val;
     112                        break;
     113                case DT_SYMBOLIC:
     114                        info->symbolic = true;
     115                        break;
     116                case DT_REL:
     117                        info->rel = d_ptr;
     118                        break;
     119                case DT_RELSZ:
     120                        info->rel_sz = d_val;
     121                        break;
     122                case DT_RELENT:
     123                        info->rel_ent = d_val;
     124                        break;
     125                case DT_PLTREL:
     126                        info->plt_rel = d_val;
     127                        break;
     128                case DT_TEXTREL:
     129                        info->text_rel = true;
     130                        break;
     131                case DT_JMPREL:
     132                        info->jmp_rel = d_ptr;
     133                        break;
     134                case DT_BIND_NOW:
     135                        info->bind_now = true;
     136                        break;
    93137
    94138                default:
     
    108152
    109153        DPRINTF("str_tab=0x%" PRIxPTR ", soname_idx=0x%x, soname=0x%" PRIxPTR "\n",
    110                 (uintptr_t)info->soname, soname_idx, (uintptr_t)info->soname);
     154            (uintptr_t)info->soname, soname_idx, (uintptr_t)info->soname);
    111155        DPRINTF("soname='%s'\n", info->soname);
    112156        DPRINTF("rpath='%s'\n", info->rpath);
     
    134178                        break;
    135179
    136                 default: break;
     180                default:
     181                        break;
    137182                }
    138183
  • uspace/lib/c/generic/rtld/module.c

    r47b2d7e3 r1433ecda  
    9191
    9292        /* Do not relocate twice. */
    93         if (m->relocated) return;
     93        if (m->relocated)
     94                return;
    9495
    9596        module_process_pre_arch(m);
     
    246247
    247248        while (dp->d_tag != DT_NULL) {
    248                 if (dp->d_tag == DT_NEEDED) ++n;
     249                if (dp->d_tag == DT_NEEDED)
     250                        ++n;
    249251                ++dp;
    250252        }
  • uspace/lib/c/generic/rtld/rtld.c

    r47b2d7e3 r1433ecda  
    186186         * Ascending addresses
    187187         */
    188         offset = 0; i = 1;
     188        offset = 0;
     189        i = 1;
    189190        list_foreach(rtld->imodules, imodules_link, module_t, m) {
    190191                assert(i == m->id);
     
    200201         * Descending addresses
    201202         */
    202         offset = 0; i = 1;
     203        offset = 0;
     204        i = 1;
    203205        list_foreach(rtld->imodules, imodules_link, module_t, m) {
    204206                assert(i == m->id);
  • uspace/lib/c/generic/rtld/symbol.c

    r47b2d7e3 r1433ecda  
    5555                h = (h << 4) + *name++;
    5656                g = h & 0xf0000000;
    57                 if (g != 0) h ^= g >> 24;
     57                if (g != 0)
     58                        h ^= g >> 24;
    5859                h &= ~g;
    5960        }
  • uspace/lib/c/generic/str.c

    r47b2d7e3 r1433ecda  
    4949/** Check the condition if wchar_t is signed */
    5050#ifdef __WCHAR_UNSIGNED__
    51         #define WCHAR_SIGNED_CHECK(cond)  (true)
     51#define WCHAR_SIGNED_CHECK(cond)  (true)
    5252#else
    53         #define WCHAR_SIGNED_CHECK(cond)  (cond)
     53#define WCHAR_SIGNED_CHECK(cond)  (cond)
    5454#endif
    5555
     
    164164                        /* 0xxxxxxx (Plain ASCII) */
    165165                        return b & 0x7f;
    166                 }
    167                 else if ((b & 0xe0) == 0xc0 || (b & 0xf0) == 0xe0 ||
     166                } else if ((b & 0xe0) == 0xc0 || (b & 0xf0) == 0xe0 ||
    168167                    (b & 0xf8) == 0xf0) {
    169168                        /* Start byte */
    170169                        size_t start_offset = *offset;
    171170                        return str_decode(str, &start_offset, size);
    172                 }
    173                 else if ((b & 0xc0) != 0x80) {
     171                } else if ((b & 0xc0) != 0x80) {
    174172                        /* Not a continuation byte */
    175173                        return U_SPECIAL;
     
    936934                                ch += (src[idx + 1] & 0x03FF);
    937935                                idx += 2;
    938                         }
    939                         else
     936                        } else
    940937                                break;
    941938                } else {
     
    983980                        idx++;
    984981                } else {
    985                          dest[idx] = c;
     982                        dest[idx] = c;
    986983                }
    987984
     
    11101107        size_t len = str_length(str);
    11111108
    1112         wchar_t *wstr = calloc(len+1, sizeof(wchar_t));
     1109        wchar_t *wstr = calloc(len + 1, sizeof(wchar_t));
    11131110        if (wstr == NULL)
    11141111                return NULL;
  • uspace/lib/c/generic/str_error.c

    r47b2d7e3 r1433ecda  
    5757#define __errno_entry(name, num, desc) #name,
    5858
    59 static const char* err_name[] = {
     59static const char *err_name[] = {
    6060#include <abi/errno.in>
    6161};
     
    6464#define __errno_entry(name, num, desc) "[" #name "]" desc,
    6565
    66 static const char* err_desc[] = {
     66static const char *err_desc[] = {
    6767#include <abi/errno.in>
    6868};
  • uspace/lib/c/generic/task.c

    r47b2d7e3 r1433ecda  
    346346 * @param wait task_wait_t previously initialized by task_setup_wait.
    347347 */
    348 void task_cancel_wait(task_wait_t *wait) {
     348void task_cancel_wait(task_wait_t *wait)
     349{
    349350        async_forget(wait->aid);
    350351}
  • uspace/lib/c/generic/thread.c

    r47b2d7e3 r1433ecda  
    105105 * @return Zero on success or a code from @ref errno.h on failure.
    106106 */
    107 errno_t thread_create(void (* function)(void *), void *arg, const char *name,
     107errno_t thread_create(void (*function)(void *), void *arg, const char *name,
    108108    thread_id_t *tid)
    109109{
     
    157157
    158158        /* Unreachable */
    159         while (1);
     159        while (1)
     160                ;
    160161}
    161162
  • uspace/lib/c/generic/vfs/canonify.c

    r47b2d7e3 r1433ecda  
    119119typedef struct {
    120120        state_t s;
    121         void (* f)(token_t *, token_t *, token_t *);
     121        void (*f)(token_t *, token_t *, token_t *);
    122122} change_state_t;
    123123
  • uspace/lib/c/generic/vfs/vfs.c

    r47b2d7e3 r1433ecda  
    13171317                *pos += cnt;
    13181318                rc = vfs_write_short(file, *pos, bp, nbyte - nwr, &cnt);
    1319         } while (rc == EOK && ((ssize_t )nbyte - nwr - cnt) > 0);
     1319        } while (rc == EOK && ((ssize_t)nbyte - nwr - cnt) > 0);
    13201320
    13211321        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.