Changeset a35b458 in mainline for uspace/lib/http/src/receive-buffer.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (8 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/http/src/receive-buffer.c

    r3061bc1 ra35b458  
    4848        rb->receive = receive;
    4949        rb->client_data = client_data;
    50        
     50
    5151        rb->in = 0;
    5252        rb->out = 0;
    5353        rb->size = buffer_size;
    54        
     54
    5555        list_initialize(&rb->marks);
    56        
     56
    5757        rb->buffer = malloc(buffer_size);
    5858        if (rb->buffer == NULL)
     
    7373        if (rc != EOK)
    7474                return rc;
    75        
     75
    7676        memcpy(rb->buffer, buf, size);
    7777        rb->in = size;
     
    111111        if (a->offset > b->offset)
    112112                return EINVAL;
    113        
     113
    114114        size_t size = b->offset - a->offset;
    115115        void *buf = malloc(size);
    116116        if (buf == NULL)
    117117                return ENOMEM;
    118        
     118
    119119        memcpy(buf, rb->buffer + a->offset, size);
    120120        *out_buf = buf;
     
    127127        if (a->offset > b->offset)
    128128                return EINVAL;
    129        
     129
    130130        size_t size = b->offset - a->offset;
    131131        char *buf = malloc(size + 1);
    132132        if (buf == NULL)
    133133                return ENOMEM;
    134        
     134
    135135        memcpy(buf, rb->buffer + a->offset, size);
    136136        buf[size] = 0;
     
    156156                                min_mark = min(min_mark, mark->offset);
    157157                        }
    158                        
     158
    159159                        if (min_mark == 0)
    160160                                return ELIMIT;
    161                        
     161
    162162                        size_t new_in = rb->in - min_mark;
    163163                        memmove(rb->buffer, rb->buffer + min_mark, new_in);
     
    168168                        }
    169169                }
    170                
     170
    171171                size_t nrecv;
    172172                errno_t rc = rb->receive(rb->client_data, rb->buffer + rb->in, free, &nrecv);
    173173                if (rc != EOK)
    174174                        return rc;
    175                
     175
    176176                rb->in = nrecv;
    177177        }
    178        
     178
    179179        *c = rb->buffer[rb->out];
    180180        if (consume)
     
    194194                return EOK;
    195195        }
    196        
     196
    197197        return rb->receive(rb->client_data, buf, buf_size, nrecv);
    198198}
     
    248248                if (rc != EOK)
    249249                        return rc;
    250                
     250
    251251                if (!class(c))
    252252                        break;
    253                
     253
    254254                rc = recv_char(rb, &c, true);
    255255                if (rc != EOK)
    256256                        return rc;
    257257        }
    258        
     258
    259259        return EOK;
    260260}
     
    272272        if (rc != EOK)
    273273                return rc;
    274        
     274
    275275        if (c != '\r' && c != '\n') {
    276276                *nrecv = 0;
    277277                return EOK;
    278278        }
    279        
     279
    280280        rc = recv_char(rb, &c, true);
    281281        if (rc != EOK)
    282282                return rc;
    283        
     283
    284284        size_t nr;
    285285        rc = recv_discard(rb, (c == '\r' ? '\n' : '\r'), &nr);
    286286        if (rc != EOK)
    287287                return rc;
    288        
     288
    289289        *nrecv = 1 + nr;
    290290        return EOK;
     
    296296        size_t written = 0;
    297297        size_t nr;
    298        
     298
    299299        while (written < size) {
    300300                char c = 0;
     
    321321                line[written++] = c;
    322322        }
    323        
     323
    324324        return ELIMIT;
    325325}
Note: See TracChangeset for help on using the changeset viewer.