Changeset b7fd2a0 in mainline for uspace/lib/bithenge/src/blob.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (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:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/bithenge/src/blob.c

    r36f0738 rb7fd2a0  
    4949 * @return EOK on success or an error code from errno.h.
    5050 */
    51 int bithenge_init_random_access_blob(bithenge_blob_t *blob,
     51errno_t bithenge_init_random_access_blob(bithenge_blob_t *blob,
    5252    const bithenge_random_access_blob_ops_t *ops)
    5353{
     
    6767}
    6868
    69 static int sequential_buffer(bithenge_sequential_blob_t *blob, aoff64_t end)
     69static errno_t sequential_buffer(bithenge_sequential_blob_t *blob, aoff64_t end)
    7070{
    7171        bool need_realloc = false;
     
    8181        }
    8282        aoff64_t size = end - blob->data_size;
    83         int rc = blob->ops->read(blob, blob->buffer + blob->data_size, &size);
     83        errno_t rc = blob->ops->read(blob, blob->buffer + blob->data_size, &size);
    8484        if (rc != EOK)
    8585                return rc;
     
    100100}
    101101
    102 static int sequential_size(bithenge_blob_t *base, aoff64_t *size)
     102static errno_t sequential_size(bithenge_blob_t *base, aoff64_t *size)
    103103{
    104104        bithenge_sequential_blob_t *blob = blob_as_sequential(base);
    105         int rc;
     105        errno_t rc;
    106106        if (blob->ops->size) {
    107107                rc = blob->ops->size(blob, size);
     
    121121}
    122122
    123 static int sequential_read(bithenge_blob_t *base, aoff64_t offset,
     123static errno_t sequential_read(bithenge_blob_t *base, aoff64_t offset,
    124124    char *buffer, aoff64_t *size)
    125125{
     
    127127        aoff64_t end = offset + *size;
    128128        if (end > blob->data_size) {
    129                 int rc = sequential_buffer(blob, end);
     129                errno_t rc = sequential_buffer(blob, end);
    130130                if (rc != EOK)
    131131                        return rc;
     
    158158 * @return EOK on success or an error code from errno.h.
    159159 */
    160 int bithenge_init_sequential_blob(bithenge_sequential_blob_t *blob,
     160errno_t bithenge_init_sequential_blob(bithenge_sequential_blob_t *blob,
    161161    const bithenge_sequential_blob_ops_t *ops)
    162162{
     
    167167        // ops->size is optional
    168168
    169         int rc = bithenge_init_random_access_blob(sequential_as_blob(blob),
     169        errno_t rc = bithenge_init_random_access_blob(sequential_as_blob(blob),
    170170            &sequential_ops);
    171171        if (rc != EOK)
     
    195195}
    196196
    197 static int memory_size(bithenge_blob_t *base, aoff64_t *size)
     197static errno_t memory_size(bithenge_blob_t *base, aoff64_t *size)
    198198{
    199199        memory_blob_t *blob = blob_as_memory(base);
     
    204204}
    205205
    206 static int memory_read(bithenge_blob_t *base, aoff64_t offset, char *buffer,
     206static errno_t memory_read(bithenge_blob_t *base, aoff64_t offset, char *buffer,
    207207    aoff64_t *size)
    208208{
     
    240240 * function fails or the blob is destroyed.
    241241 * @return EOK on success or an error code from errno.h. */
    242 int bithenge_new_blob_from_buffer(bithenge_node_t **out, const void *buffer,
     242errno_t bithenge_new_blob_from_buffer(bithenge_node_t **out, const void *buffer,
    243243    size_t len, bool needs_free)
    244244{
    245         int rc;
     245        errno_t rc;
    246246        assert(buffer || !len);
    247247
     
    278278 * @param len The length of the data.
    279279 * @return EOK on success or an error code from errno.h. */
    280 int bithenge_new_blob_from_data(bithenge_node_t **out, const void *data,
     280errno_t bithenge_new_blob_from_data(bithenge_node_t **out, const void *data,
    281281    size_t len)
    282282{
     
    309309}
    310310
    311 static int subblob_size(bithenge_blob_t *base, aoff64_t *size)
     311static errno_t subblob_size(bithenge_blob_t *base, aoff64_t *size)
    312312{
    313313        subblob_t *blob = blob_as_subblob(base);
     
    316316                return EOK;
    317317        } else {
    318                 int rc = bithenge_blob_size(blob->source, size);
     318                errno_t rc = bithenge_blob_size(blob->source, size);
    319319                *size -= blob->offset;
    320320                return rc;
     
    322322}
    323323
    324 static int subblob_read(bithenge_blob_t *base, aoff64_t offset,
     324static errno_t subblob_read(bithenge_blob_t *base, aoff64_t offset,
    325325    char *buffer, aoff64_t *size)
    326326{
     
    335335}
    336336
    337 static int subblob_read_bits(bithenge_blob_t *base, aoff64_t offset,
     337static errno_t subblob_read_bits(bithenge_blob_t *base, aoff64_t offset,
    338338    char *buffer, aoff64_t *size, bool little_endian)
    339339{
     
    368368}
    369369
    370 static int new_subblob(bithenge_node_t **out, bithenge_blob_t *source,
     370static errno_t new_subblob(bithenge_node_t **out, bithenge_blob_t *source,
    371371    aoff64_t offset, aoff64_t size, bool size_matters)
    372372{
    373373        assert(out);
    374374        assert(source);
    375         int rc;
     375        errno_t rc;
    376376        subblob_t *blob = 0;
    377377
     
    436436 * @param offset The offset within the input blob at which the new blob will start.
    437437 * @return EOK on success or an error code from errno.h. */
    438 int bithenge_new_offset_blob(bithenge_node_t **out, bithenge_blob_t *source,
     438errno_t bithenge_new_offset_blob(bithenge_node_t **out, bithenge_blob_t *source,
    439439    aoff64_t offset)
    440440{
     
    449449 * @param size The size of the new blob.
    450450 * @return EOK on success or an error code from errno.h. */
    451 int bithenge_new_subblob(bithenge_node_t **out, bithenge_blob_t *source,
     451errno_t bithenge_new_subblob(bithenge_node_t **out, bithenge_blob_t *source,
    452452    aoff64_t offset, aoff64_t size)
    453453{
     
    461461 * @return EOK on success, or an error code from errno.h.
    462462 */
    463 int bithenge_blob_equal(bool *out, bithenge_blob_t *a, bithenge_blob_t *b)
     463errno_t bithenge_blob_equal(bool *out, bithenge_blob_t *a, bithenge_blob_t *b)
    464464{
    465465        assert(a);
     
    467467        assert(b);
    468468        assert(b->base.blob_ops);
    469         int rc;
     469        errno_t rc;
    470470        char buffer_a[4096], buffer_b[4096];
    471471        aoff64_t offset = 0, size_a = sizeof(buffer_a), size_b = sizeof(buffer_b);
Note: See TracChangeset for help on using the changeset viewer.