Changeset bde5c04 in mainline


Ignore:
Timestamp:
2017-12-04T19:32:55Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0fb1755
Parents:
8e3498b
Message:

Avoid mixing error codes and transfer sizes.

Location:
uspace/srv
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/rfb/rfb.c

    r8e3498b rbde5c04  
    418418}
    419419
    420 static ssize_t rfb_tile_encode_raw(rfb_t *rfb, cpixel_ctx_t *cpixel,
     420static size_t rfb_tile_encode_raw(rfb_t *rfb, cpixel_ctx_t *cpixel,
    421421    rfb_rectangle_t *tile, void *buf)
    422422{
    423         ssize_t size = tile->width * tile->height * cpixel->size;
     423        size_t size = tile->width * tile->height * cpixel->size;
    424424        if (buf == NULL)
    425425                return size;
     
    435435}
    436436
    437 static ssize_t rfb_tile_encode_solid(rfb_t *rfb, cpixel_ctx_t *cpixel,
    438     rfb_rectangle_t *tile, void *buf)
     437static size_t rfb_tile_encode_solid(rfb_t *rfb, cpixel_ctx_t *cpixel,
     438    rfb_rectangle_t *tile, void *buf, size_t *size)
    439439{
    440440        /* Check if it is single color */
     
    443443                for (uint16_t x = tile->x; x < tile->x + tile->width; x++) {
    444444                        if (pixelmap_get_pixel(&rfb->framebuffer, x, y) != the_color)
    445                                 return -1;
     445                                return EINVAL;
    446446                }
    447447        }
     
    450450        if (buf)
    451451                cpixel_encode(rfb, cpixel, buf, the_color);
    452         return cpixel->size;
     452        *size = cpixel->size;
     453        return EOK;
    453454}
    454455
     
    474475                       
    475476                        uint8_t tile_enctype = RFB_TILE_ENCODING_SOLID;
    476                         ssize_t tile_size = rfb_tile_encode_solid(rfb, &cpixel, &tile, buf);
    477                         if (tile_size < 0) {
     477                        size_t tile_size;
     478                        int rc = rfb_tile_encode_solid(rfb, &cpixel, &tile, buf,
     479                            &tile_size);
     480                        if (rc != EOK) {
    478481                                tile_size = rfb_tile_encode_raw(rfb, &cpixel, &tile, buf);
    479482                                tile_enctype = RFB_TILE_ENCODING_RAW;
  • uspace/srv/net/udp/service.c

    r8e3498b rbde5c04  
    570570
    571571        rc = async_data_read_finalize(callid, &enext->epp.remote,
    572             max(size, (ssize_t)sizeof(inet_ep_t)));
     572            max(size, (size_t)sizeof(inet_ep_t)));
    573573        if (rc != EOK) {
    574574                async_answer_0(iid, rc);
     
    596596{
    597597        ipc_callid_t callid;
    598         ssize_t msg_size;
     598        size_t msg_size;
    599599        udp_crcv_queue_entry_t *enext;
    600600        void *data;
    601601        size_t size;
    602         ssize_t off;
     602        size_t off;
    603603        int rc;
    604604
     
    623623        msg_size = enext->msg->data_size;
    624624
    625         rc = async_data_read_finalize(callid, data, max(msg_size - off,
    626             (ssize_t)size));
     625        if (off > msg_size) {
     626                async_answer_0(callid, EINVAL);
     627                async_answer_0(iid, EINVAL);
     628                return;
     629        }
     630
     631        rc = async_data_read_finalize(callid, data, min(msg_size - off, size));
    627632        if (rc != EOK) {
    628633                async_answer_0(iid, rc);
Note: See TracChangeset for help on using the changeset viewer.