Ignore:
Timestamp:
2018-01-04T20:50:52Z (6 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/hostport.c

    rfacacc71 r46577995  
    5656 *         extra characters at the end. ENOMEM if out of memory
    5757 */
    58 int inet_hostport_parse(const char *str, inet_hostport_t **rhp,
     58errno_t inet_hostport_parse(const char *str, inet_hostport_t **rhp,
    5959    char **endptr)
    6060{
     
    6565        char *aend;
    6666        const char *pend;
    67         int rc;
     67        errno_t rc;
    6868
    6969        hp = calloc(1, sizeof(inet_hostport_t));
     
    137137 * @return EOK on success, ENOMEM if out of memory
    138138 */
    139 int inet_hostport_format(inet_hostport_t *hp, char **rstr)
    140 {
    141         int rc;
     139errno_t inet_hostport_format(inet_hostport_t *hp, char **rstr)
     140{
     141        errno_t rc;
    142142        int ret;
    143143        char *astr, *str;
     
    211211 * @return EOK on success, ENOENT on resolution failure
    212212 */
    213 int inet_hostport_lookup_one(inet_hostport_t *hp, ip_ver_t version,
     213errno_t inet_hostport_lookup_one(inet_hostport_t *hp, ip_ver_t version,
    214214    inet_ep_t *ep)
    215215{
    216216        dnsr_hostinfo_t *hinfo = NULL;
    217         int rc;
     217        errno_t rc;
    218218
    219219        inet_ep_init(ep);
     
    255255 *         ENOMEM if out of memory
    256256 */
    257 int inet_hostport_plookup_one(const char *str, ip_ver_t version, inet_ep_t *ep,
     257errno_t inet_hostport_plookup_one(const char *str, ip_ver_t version, inet_ep_t *ep,
    258258    char **endptr, const char **errmsg)
    259259{
    260260        inet_hostport_t *hp = NULL;
    261261        char *eptr;
    262         int rc;
     262        errno_t rc;
    263263
    264264        rc = inet_hostport_parse(str, &hp, endptr != NULL ? &eptr : NULL);
    265265        if (rc != EOK) {
    266                 switch (rc) {
    267                 case EINVAL:
     266                switch ((case_errno_t) rc) {
     267                case (case_errno_t) EINVAL:
    268268                        if (errmsg != NULL)
    269269                                *errmsg = "Invalid format";
    270270                        goto error;
    271                 case ENOMEM:
     271                case (case_errno_t) ENOMEM:
    272272                        if (errmsg != NULL)
    273273                                *errmsg = "Out of memory";
    274274                        goto error;
    275                 case EOK:
     275                case (case_errno_t) EOK:
    276276                        break;
    277277                default:
Note: See TracChangeset for help on using the changeset viewer.