Changeset 904b1bc in mainline for uspace/lib


Ignore:
Timestamp:
2018-05-22T10:36:58Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a4eb3ba2
Parents:
4f8772d4
git-author:
Jiri Svoboda <jiri@…> (2018-05-21 17:36:30)
git-committer:
Jiri Svoboda <jiri@…> (2018-05-22 10:36:58)
Message:

Fix remaining ccheck issues.

Location:
uspace/lib
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/compress/inflate.c

    r4f8772d4 r904b1bc  
    319319    uint16_t *symbol)
    320320{
    321         uint16_t code = 0; /* Decoded bits */
    322         size_t first = 0;  /* First code of the given length */
    323         size_t index = 0;  /* Index of the first code of the given length
    324                               in the symbol table */
    325 
    326         size_t len;  /* Current number of bits in the code */
     321        /* Decode bits */
     322        uint16_t code = 0;
     323
     324        /* First code of the given length */
     325        size_t first = 0;
     326
     327        /*
     328         * Index of the first code of the given length
     329         * in the symbol table
     330         */
     331        size_t index = 0;
     332
     333        /* Current number of bits in the code */
     334        size_t len;
     335
    327336        for (len = 1; len <= MAX_HUFFMAN_BIT; len++) {
    328337                /* Get next bit */
  • uspace/lib/drv/generic/logbuf.c

    r4f8772d4 r904b1bc  
    4040#define REMAINDER_STR_FMT " (%zu)..."
    4141/** Expected max size of the remainder string.
    42  * String + terminator + number width (enough for 4GB).*/
     42 * String + terminator + number width (enough for 4GB).
     43 */
    4344#define REMAINDER_STR_LEN (5 + 1 + 10)
    4445
     
    5051/** Space between two groups. */
    5152#define SPACE_GROUP "  "
     53
     54/** Formats the dump with space before, takes care of type casting (ugly). */
     55#define _FORMAT(digits, bits) \
     56        snprintf(dump, dump_size, "%s%0" #digits PRIx##bits, \
     57            space_before, ((uint##bits##_t *)buf)[0]);
    5258
    5359/** Dump one item into given buffer.
     
    7783        buf += index * item_size;
    7884
    79 /* Formats the dump with space before, takes care of type casting (ugly). */
    80 #define _FORMAT(digits, bits) \
    81         snprintf(dump, dump_size, "%s%0" #digits PRIx##bits, \
    82             space_before, ((uint##bits##_t *)buf)[0]);
    83 
    8485        switch (item_size) {
    8586        case 4:
     
    9091                return _FORMAT(2, 8);
    9192        }
    92 #undef _FORMAT
    9393}
    9494
  • uspace/lib/hound/src/protocol.c

    r4f8772d4 r904b1bc  
    7979
    8080
    81 /****
     81/*
    8282 * CLIENT
    83  ****/
     83 */
    8484
    8585/** Well defined service name */
     
    309309    int flags, pcm_format_t format, size_t bsize)
    310310{
    311         const format_convert_t c = { .f = {
    312                 .channels = format.channels,
    313                 .rate = format.sampling_rate / 100,
    314                 .format = format.sample_format,
    315         }};
     311        const format_convert_t c = {
     312                .f = {
     313                        .channels = format.channels,
     314                        .rate = format.sampling_rate / 100,
     315                        .format = format.sample_format,
     316                }
     317        };
     318
    316319        return async_req_4_0(exch, IPC_M_HOUND_STREAM_ENTER, CAP_HANDLE_RAW(id),
    317320            flags, c.arg, bsize);
     
    362365}
    363366
    364 /****
     367/*
    365368 * SERVER
    366  ****/
     369 */
    367370
    368371static void hound_server_read_data(void *stream);
     
    463466                        if (conn)
    464467                                ret = async_data_write_accept(
    465                                     (void**)&conn_name, true, 0, 0, 0, 0);
     468                                    (void **)&conn_name, true, 0, 0, 0, 0);
    466469
    467470                        if (ret == EOK)
     
    559562                case IPC_M_HOUND_STREAM_ENTER:
    560563                        /* check interface functions */
    561                         if (!server_iface || !server_iface->is_record_context
    562                             || !server_iface->add_stream
    563                             || !server_iface->rem_stream) {
     564                        if (!server_iface || !server_iface->is_record_context ||
     565                            !server_iface->add_stream ||
     566                            !server_iface->rem_stream) {
    564567                                async_answer_0(chandle, ENOTSUP);
    565568                                break;
     
    569572                        id = (cap_handle_t) IPC_GET_ARG1(call);
    570573                        flags = IPC_GET_ARG2(call);
    571                         const format_convert_t c = {.arg = IPC_GET_ARG3(call)};
     574                        const format_convert_t c = { .arg = IPC_GET_ARG3(call) };
    572575                        const pcm_format_t f = {
    573                             .sampling_rate = c.f.rate * 100,
    574                             .channels = c.f.channels,
    575                             .sample_format = c.f.format,
     576                                .sampling_rate = c.f.rate * 100,
     577                                .channels = c.f.channels,
     578                                .sample_format = c.f.format,
    576579                        };
    577580                        size_t bsize = IPC_GET_ARG4(call);
     
    587590                            server_iface->server, id);
    588591                        if (rec) {
    589                                 if(server_iface->stream_data_read) {
     592                                if (server_iface->stream_data_read) {
    590593                                        async_answer_0(chandle, EOK);
    591594                                        /* start answering read calls */
     
    631634        errno_t ret_answer = EOK;
    632635        /* accept data write or drain */
    633         while (async_data_write_receive_call(&chandle, &call, &size)
    634             || (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) {
     636        while (async_data_write_receive_call(&chandle, &call, &size) ||
     637            (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) {
    635638                /* check drain first */
    636639                if (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN) {
     
    660663                }
    661664        }
    662         const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT
    663             ? EOK : EINVAL;
     665        const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT ?
     666            EOK : EINVAL;
    664667
    665668        async_answer_0(chandle, ret);
     
    678681        errno_t ret_answer = EOK;
    679682        /* accept data read and drain */
    680         while (async_data_read_receive_call(&chandle, &call, &size)
    681             || (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) {
     683        while (async_data_read_receive_call(&chandle, &call, &size) ||
     684            (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) {
    682685                /* drain does not make much sense but it is allowed */
    683686                if (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN) {
     
    704707                }
    705708        }
    706         const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT
    707             ? EOK : EINVAL;
     709        const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT ?
     710            EOK : EINVAL;
    708711
    709712        async_answer_0(chandle, ret);
     
    711714
    712715
    713 /***
     716/*
    714717 * SERVER SIDE
    715  ***/
     718 */
    716719
    717720/**
  • uspace/lib/label/include/std/fat.h

    r4f8772d4 r904b1bc  
    5151
    5252typedef struct fat_bs {
    53         uint8_t         ji[3];          /**< Jump instruction. */
     53        /** Jump instruction */
     54        uint8_t         ji[3];
    5455        uint8_t         oem_name[8];
     56
    5557        /* BIOS Parameter Block */
    56         uint16_t        bps;            /**< Bytes per sector. */
    57         uint8_t         spc;            /**< Sectors per cluster. */
    58         uint16_t        rscnt;          /**< Reserved sector count. */
    59         uint8_t         fatcnt;         /**< Number of FATs. */
    60         uint16_t        root_ent_max;   /**< Maximum number of root directory
    61                                              entries. */
    62         uint16_t        totsec16;       /**< Total sectors. 16-bit version. */
    63         uint8_t         mdesc;          /**< Media descriptor. */
    64         uint16_t        sec_per_fat;    /**< Sectors per FAT12/FAT16. */
    65         uint16_t        sec_per_track;  /**< Sectors per track. */
    66         uint16_t        headcnt;        /**< Number of heads. */
    67         uint32_t        hidden_sec;     /**< Hidden sectors. */
    68         uint32_t        totsec32;       /**< Total sectors. 32-bit version. */
     58
     59        /** Bytes per sector */
     60        uint16_t        bps;
     61        /** Sectors per cluster */
     62        uint8_t         spc;
     63        /** Reserved sector count */
     64        uint16_t        rscnt;
     65        /** Number of FATs */
     66        uint8_t         fatcnt;
     67        /** Maximum number of root directory entries */
     68        uint16_t        root_ent_max;
     69        /** Total sectors. 16-bit version */
     70        uint16_t        totsec16;
     71        /** Media descriptor */
     72        uint8_t         mdesc;
     73        /** Sectors per FAT12/FAT16 */
     74        uint16_t        sec_per_fat;
     75        /** Sectors per track */
     76        uint16_t        sec_per_track;
     77        /** Number of heads */
     78        uint16_t        headcnt;
     79        /** Hidden sectors */
     80        uint32_t        hidden_sec;
     81        /** Total sectors. 32-bit version */
     82        uint32_t        totsec32;
    6983
    7084        union {
  • uspace/lib/posix/src/fnmatch.c

    r4f8772d4 r904b1bc  
    3333 */
    3434
    35 /* This file contains an implementation of the fnmatch() pattern matching
     35/*
     36 * This file contains an implementation of the fnmatch() pattern matching
    3637 * function. There is more code than necessary to account for the possibility
    3738 * of adding POSIX-like locale support to the system in the future. Functions
     
    5455#define INVALID_PATTERN -1
    5556
    56 /* Type for collating element, simple identity with characters now,
     57/*
     58 * Type for collating element, simple identity with characters now,
    5759 * but may be extended for better locale support.
    5860 */
     
    7072 * @return Matching collating element or COLL_ELM_INVALID.
    7173 */
    72 static coll_elm_t _coll_elm_get(const char* str)
     74static coll_elm_t _coll_elm_get(const char *str)
    7375{
    7476        if (str[0] == '\0' || str[1] != '\0') {
     
    306308}
    307309
    308 /**
    309  * Matches the beginning of the given string against a bracket expression
    310  * the pattern begins with.
    311  *
    312  * @param pattern Pointer to the beginning of a bracket expression in a pattern.
    313  *     On success, the pointer is moved to the first character after the
    314  *     bracket expression.
    315  * @param str Unmatched part of the string.
    316  * @param flags Flags given to fnmatch().
    317  * @return INVALID_PATTERN if the pattern is invalid, 0 if there is no match
    318  *     or the number of matched characters on success.
    319  */
    320 static int _match_bracket_expr(const char **pattern, const char *str, int flags)
    321 {
    322         const bool pathname = (flags & FNM_PATHNAME) != 0;
    323         const bool special_period = (flags & FNM_PERIOD) != 0;
    324         const char *p = *pattern;
    325         bool negative = false;
    326         int matched = 0;
    327 
    328         #define _matched(match) { \
     310#define _matched(match) { \
    329311                int _match = match; \
    330312                if (_match < 0) { \
     
    337319        }
    338320
     321/**
     322 * Matches the beginning of the given string against a bracket expression
     323 * the pattern begins with.
     324 *
     325 * @param pattern Pointer to the beginning of a bracket expression in a pattern.
     326 *     On success, the pointer is moved to the first character after the
     327 *     bracket expression.
     328 * @param str Unmatched part of the string.
     329 * @param flags Flags given to fnmatch().
     330 * @return INVALID_PATTERN if the pattern is invalid, 0 if there is no match
     331 *     or the number of matched characters on success.
     332 */
     333static int _match_bracket_expr(const char **pattern, const char *str, int flags)
     334{
     335        const bool pathname = (flags & FNM_PATHNAME) != 0;
     336        const bool special_period = (flags & FNM_PERIOD) != 0;
     337        const char *p = *pattern;
     338        bool negative = false;
     339        int matched = 0;
     340
    339341        assert(*p == '[');  /* calling code should ensure this */
    340342        p++;
     
    342344        if (*str == '\0' || (pathname && *str == '/') ||
    343345            (pathname && special_period && *str == '.' && *(str - 1) == '/')) {
    344                 /* No bracket expression matches end of string,
     346                /*
     347                 * No bracket expression matches end of string,
    345348                 * slash in pathname match or initial period with FNM_PERIOD
    346349                 * option.
     
    398401                return negative ? 0 : matched;
    399402        }
    400 
    401         #undef _matched
    402403}
    403404
     
    416417static bool _partial_match(const char **pattern, const char **string, int flags)
    417418{
    418         /* Only a single *-delimited subpattern is matched here.
     419        /*
     420         * Only a single *-delimited subpattern is matched here.
    419421         * So in this function, '*' is understood as the end of pattern.
    420422         */
     
    473475
    474476                if (*p == '\0') {
    475                         /* End of pattern, must match end of string or
     477                        /*
     478                         * End of pattern, must match end of string or
    476479                         * an end of subdirectory name (optional).
    477480                         */
     
    628631#include <stdio.h>
    629632
     633#define fnmatch_test(x) { if (x) printf("SUCCESS: "#x"\n"); else { printf("FAILED: "#x"\n"); fail++; } }
     634#define match(s1, s2, flags) fnmatch_test(fnmatch(s1, s2, flags) == 0)
     635#define nomatch(s1, s2, flags) fnmatch_test(fnmatch(s1, s2, flags) == FNM_NOMATCH)
     636
    630637void __posix_fnmatch_test()
    631638{
    632639        int fail = 0;
    633640
    634         #undef assert
    635         #define assert(x) { if (x) printf("SUCCESS: "#x"\n"); else { printf("FAILED: "#x"\n"); fail++; } }
    636         #define match(s1, s2, flags) assert(fnmatch(s1, s2, flags) == 0)
    637         #define nomatch(s1, s2, flags) assert(fnmatch(s1, s2, flags) == FNM_NOMATCH)
    638641
    639642        static_assert(FNM_PATHNAME == FNM_FILE_NAME);
  • uspace/lib/usb/include/usb/classes/hub.h

    r4f8772d4 r904b1bc  
    149149        uint8_t characteristics;
    150150
    151 #define HUB_CHAR_POWER_PER_PORT_FLAG    (1 << 0)
    152 #define HUB_CHAR_NO_POWER_SWITCH_FLAG   (1 << 1)
    153 #define HUB_CHAR_COMPOUND_DEVICE        (1 << 2)
    154 #define HUB_CHAR_OC_PER_PORT_FLAG       (1 << 3)
    155 #define HUB_CHAR_NO_OC_FLAG             (1 << 4)
    156 
    157 /* These are invalid for superspeed hub */
    158 #define HUB_CHAR_TT_THINK_16            (1 << 5)
    159 #define HUB_CHAR_TT_THINK_8             (1 << 6)
    160 #define HUB_CHAR_INDICATORS_FLAG        (1 << 7)
    161151
    162152        /** Unused part of characteristics field */
     
    179169        uint8_t max_current;
    180170} __attribute__((packed)) usb_hub_descriptor_header_t;
     171
     172/*
     173 * USB hub characteristics
     174 */
     175#define HUB_CHAR_POWER_PER_PORT_FLAG    (1 << 0)
     176#define HUB_CHAR_NO_POWER_SWITCH_FLAG   (1 << 1)
     177#define HUB_CHAR_COMPOUND_DEVICE        (1 << 2)
     178#define HUB_CHAR_OC_PER_PORT_FLAG       (1 << 3)
     179#define HUB_CHAR_NO_OC_FLAG             (1 << 4)
     180
     181/* These are invalid for superspeed hub */
     182#define HUB_CHAR_TT_THINK_16            (1 << 5)
     183#define HUB_CHAR_TT_THINK_8             (1 << 6)
     184#define HUB_CHAR_INDICATORS_FLAG        (1 << 7)
    181185
    182186/** One bit for the device and one bit for every port */
  • uspace/lib/usbhost/src/ddf_helpers.c

    r4f8772d4 r904b1bc  
    6666 */
    6767static errno_t register_endpoint(ddf_fun_t *fun, usb_pipe_desc_t *pipe_desc,
    68      const usb_endpoint_descriptors_t *ep_desc)
     68    const usb_endpoint_descriptors_t *ep_desc)
    6969{
    7070        assert(fun);
     
    9292}
    9393
    94  /**
    95   * DDF usbhc_iface callback. Unregister endpoint that makes the other end of
    96   * the pipe described.
    97   *
    98   * @param fun DDF function of the device in question.
    99   * @param pipe_desc Pipe description.
    100   * @return Error code.
    101   */
     94/**
     95 * DDF usbhc_iface callback. Unregister endpoint that makes the other end of
     96 * the pipe described.
     97 *
     98 * @param fun DDF function of the device in question.
     99 * @param pipe_desc Pipe description.
     100 * @return Error code.
     101 */
    102102static errno_t unregister_endpoint(ddf_fun_t *fun, const usb_pipe_desc_t *pipe_desc)
    103103{
     
    182182        }
    183183
    184         /* If the driver didn't name the dev when enumerating,
     184        /*
     185         * If the driver didn't name the dev when enumerating,
    185186         * do it in some generic way.
    186187         */
     
    281282        assert(dev);
    282283
    283         const usb_target_t target = {{
    284                 .address = dev->address,
    285                 .endpoint = ifreq->endpoint,
    286                 .stream = ifreq->stream,
    287         }};
     284        const usb_target_t target = {
     285                {
     286                        .address = dev->address,
     287                        .endpoint = ifreq->endpoint,
     288                        .stream = ifreq->stream,
     289                }
     290        };
    288291
    289292        if (!usb_target_is_valid(&target))
  • uspace/lib/usbhost/src/usb2_bus.c

    r4f8772d4 r904b1bc  
    8989}
    9090
    91 static const usb_target_t usb2_default_target = {{
    92         .address = USB_ADDRESS_DEFAULT,
    93         .endpoint = 0,
    94 }};
     91static const usb_target_t usb2_default_target = {
     92        {
     93                .address = USB_ADDRESS_DEFAULT,
     94                .endpoint = 0,
     95        }
     96};
    9597
    9698/**
     
    120122
    121123        usb_endpoint_descriptors_t ep0_desc = {
    122             .endpoint.max_packet_size = CTRL_PIPE_MIN_PACKET_SIZE,
     124                .endpoint.max_packet_size = CTRL_PIPE_MIN_PACKET_SIZE,
    123125        };
    124126
  • uspace/lib/usbhost/src/utility.c

    r4f8772d4 r904b1bc  
    8484        }
    8585
    86         const usb_target_t control_ep = {{
    87                 .address = dev->address,
    88                 .endpoint = 0,
    89         }};
     86        const usb_target_t control_ep = {
     87                {
     88                        .address = dev->address,
     89                        .endpoint = 0,
     90                }
     91        };
    9092
    9193        usb_standard_device_descriptor_t desc = { 0 };
     
    123125int hc_get_device_desc(device_t *device, usb_standard_device_descriptor_t *desc)
    124126{
    125         const usb_target_t control_ep = {{
    126                 .address = device->address,
    127                 .endpoint = 0,
    128         }};
     127        const usb_target_t control_ep = {
     128                {
     129                        .address = device->address,
     130                        .endpoint = 0,
     131                }
     132        };
    129133
    130134        /* Get std device descriptor */
     
    147151int hc_get_hub_desc(device_t *device, usb_hub_descriptor_header_t *desc)
    148152{
    149         const usb_target_t control_ep = {{
    150                 .address = device->address,
    151                 .endpoint = 0,
    152         }};
    153 
    154         const usb_descriptor_type_t type = device->speed >= USB_SPEED_SUPER
    155                 ? USB_DESCTYPE_SSPEED_HUB : USB_DESCTYPE_HUB;
     153        const usb_target_t control_ep = {
     154                {
     155                        .address = device->address,
     156                        .endpoint = 0,
     157                }
     158        };
     159
     160        const usb_descriptor_type_t type = device->speed >= USB_SPEED_SUPER ?
     161            USB_DESCTYPE_SSPEED_HUB : USB_DESCTYPE_HUB;
    156162
    157163        const usb_device_request_setup_packet_t get_hub_desc = {
    158                 .request_type = SETUP_REQUEST_TYPE_DEVICE_TO_HOST
    159                     | (USB_REQUEST_TYPE_CLASS << 5)
    160                     | USB_REQUEST_RECIPIENT_DEVICE,
     164                .request_type = SETUP_REQUEST_TYPE_DEVICE_TO_HOST |
     165                    (USB_REQUEST_TYPE_CLASS << 5) |
     166                    USB_REQUEST_RECIPIENT_DEVICE,
    161167                .request = USB_DEVREQ_GET_DESCRIPTOR,
    162168                .value = uint16_host2usb(type << 8),
     
    244250void hc_reset_toggles(const usb_transfer_batch_t *batch, endpoint_reset_toggle_t reset_cb)
    245251{
    246         if (batch->ep->transfer_type != USB_TRANSFER_CONTROL
    247             || batch->dir != USB_DIRECTION_OUT)
     252        if (batch->ep->transfer_type != USB_TRANSFER_CONTROL ||
     253            batch->dir != USB_DIRECTION_OUT)
    248254                return;
    249255
    250256        const usb_device_request_setup_packet_t *request = &batch->setup.packet;
    251         device_t * const dev = batch->ep->device;
    252 
    253         switch (request->request)
    254         {
    255         /* Clear Feature ENPOINT_STALL */
     257        device_t *const dev = batch->ep->device;
     258
     259        switch (request->request) {
     260                /* Clear Feature ENPOINT_STALL */
    256261        case USB_DEVREQ_CLEAR_FEATURE: /*resets only cleared ep */
    257262                /* 0x2 ( HOST to device | STANDART | TO ENPOINT) */
     
    273278        case USB_DEVREQ_SET_CONFIGURATION:
    274279        case USB_DEVREQ_SET_INTERFACE:
    275                 /* Recipient must be device, this resets all endpoints,
     280                /*
     281                 * Recipient must be device, this resets all endpoints,
    276282                 * In fact there should be no endpoints but EP 0 registered
    277283                 * as different interfaces use different endpoints,
    278284                 * unless you're changing configuration or alternative
    279                  * interface of an already setup device. */
     285                 * interface of an already setup device.
     286                 */
    280287                if (!(request->request_type & SETUP_REQUEST_TYPE_DEVICE_TO_HOST))
    281288                        for (usb_endpoint_t i = 0; i < 2 * USB_ENDPOINT_MAX; ++i)
Note: See TracChangeset for help on using the changeset viewer.