Changeset 46577995 in mainline for uspace/lib/c/generic/inet/host.c


Ignore:
Timestamp:
2018-01-04T20:50:52Z (8 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/c/generic/inet/host.c

    rfacacc71 r46577995  
    5454 *         extra characters at the end. ENOMEM if out of memory
    5555 */
    56 int inet_host_parse(const char *str, inet_host_t **rhost,
     56errno_t inet_host_parse(const char *str, inet_host_t **rhost,
    5757    char **endptr)
    5858{
     
    6161        char *name;
    6262        char *aend;
    63         int rc;
     63        errno_t rc;
    6464
    6565        host = calloc(1, sizeof(inet_host_t));
     
    106106 * @return EOK on success, ENOMEM if out of memory
    107107 */
    108 int inet_host_format(inet_host_t *host, char **rstr)
    109 {
    110         int rc;
     108errno_t inet_host_format(inet_host_t *host, char **rstr)
     109{
     110        errno_t rc;
    111111        char *str = NULL;
    112112
     
    161161 * @reutrn EOK on success, ENOENT on resolurion failure
    162162 */
    163 int inet_host_lookup_one(inet_host_t *host, ip_ver_t version, inet_addr_t *addr)
     163errno_t inet_host_lookup_one(inet_host_t *host, ip_ver_t version, inet_addr_t *addr)
    164164{
    165165        dnsr_hostinfo_t *hinfo = NULL;
    166         int rc;
     166        errno_t rc;
    167167
    168168        switch (host->hform) {
     
    201201 *         ENOMEM if out of memory
    202202 */
    203 int inet_host_plookup_one(const char *str, ip_ver_t version, inet_addr_t *addr,
     203errno_t inet_host_plookup_one(const char *str, ip_ver_t version, inet_addr_t *addr,
    204204    char **endptr, const char **errmsg)
    205205{
    206206        inet_host_t *host = NULL;
    207207        char *eptr;
    208         int rc;
     208        errno_t rc;
    209209
    210210        rc = inet_host_parse(str, &host, endptr != NULL ? &eptr : NULL);
    211211        if (rc != EOK) {
    212                 switch (rc) {
    213                 case EINVAL:
     212                switch ((case_errno_t) rc) {
     213                case (case_errno_t) EINVAL:
    214214                        if (errmsg != NULL)
    215215                                *errmsg = "Invalid format";
    216216                        goto error;
    217                 case ENOMEM:
     217                case (case_errno_t) ENOMEM:
    218218                        if (errmsg != NULL)
    219219                                *errmsg = "Out of memory";
Note: See TracChangeset for help on using the changeset viewer.