Changeset 46577995 in mainline for uspace/lib/bithenge/src/file.c


Ignore:
Timestamp:
2018-01-04T20:50:52Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
e211ea04
Parents:
facacc71
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 20:47:53)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 20:50:52)
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.

After this commit, HelenOS is free of code that mixes error codes with non-error
values on the assumption that error codes are negative.

File:
1 edited

Legend:

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

    rfacacc71 r46577995  
    6363}
    6464
    65 static int file_size(bithenge_blob_t *base, aoff64_t *size)
     65static errno_t file_size(bithenge_blob_t *base, aoff64_t *size)
    6666{
    6767        file_blob_t *blob = blob_as_file(base);
     
    7070}
    7171
    72 static int file_read(bithenge_blob_t *base, aoff64_t offset, char *buffer,
     72static errno_t file_read(bithenge_blob_t *base, aoff64_t offset, char *buffer,
    7373    aoff64_t *size)
    7474{
     
    7878
    7979        size_t amount_read;
    80         int rc = vfs_read(blob->fd, &offset, buffer, *size, &amount_read);
     80        errno_t rc = vfs_read(blob->fd, &offset, buffer, *size, &amount_read);
    8181        if (rc != EOK)
    8282                return errno;
     
    9898};
    9999
    100 static int new_file_blob(bithenge_node_t **out, int fd, bool needs_close)
     100static errno_t new_file_blob(bithenge_node_t **out, int fd, bool needs_close)
    101101{
    102102        assert(out);
    103103
    104104        struct stat stat;
    105         int rc = vfs_stat(fd, &stat);
     105        errno_t rc = vfs_stat(fd, &stat);
    106106        if (rc != EOK) {
    107107                if (needs_close)
     
    141141 * @param filename The name of the file.
    142142 * @return EOK on success or an error code from errno.h. */
    143 int bithenge_new_file_blob(bithenge_node_t **out, const char *filename)
     143errno_t bithenge_new_file_blob(bithenge_node_t **out, const char *filename)
    144144{
    145145        assert(filename);
    146146
    147147        int fd;
    148         int rc = vfs_lookup_open(filename, WALK_REGULAR, MODE_READ, &fd);
     148        errno_t rc = vfs_lookup_open(filename, WALK_REGULAR, MODE_READ, &fd);
    149149        if (rc != EOK)
    150150                return rc;
     
    158158 * @param fd The file descriptor.
    159159 * @return EOK on success or an error code from errno.h. */
    160 int bithenge_new_file_blob_from_fd(bithenge_node_t **out, int fd)
     160errno_t bithenge_new_file_blob_from_fd(bithenge_node_t **out, int fd)
    161161{
    162162        return new_file_blob(out, fd, false);
     
    168168 * @param file The file pointer.
    169169 * @return EOK on success or an error code from errno.h. */
    170 int bithenge_new_file_blob_from_file(bithenge_node_t **out, FILE *file)
     170errno_t bithenge_new_file_blob_from_file(bithenge_node_t **out, FILE *file)
    171171{
    172172        int fd = fileno(file);
Note: See TracChangeset for help on using the changeset viewer.