Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 9350bfdd in mainline


Ignore:
Timestamp:
2011-07-28T22:51:32Z (10 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master
Children:
7ae249d
Parents:
955c2b0
Message:

Fix the case when errno is non-zero on entry to getcwd().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/unistd.c

    r955c2b0 r9350bfdd  
    110110                return NULL;
    111111        }
     112       
     113        /* Save the original value to comply with the "no modification on
     114         * success" semantics.
     115         */
     116        int orig_errno = errno;
     117        errno = EOK;
     118       
    112119        char *ret = getcwd(buf, size);
    113         /* Check errno to avoid shadowing possible ENOMEM. */
    114         if (ret == NULL && errno == EOK) {
    115                 errno = ERANGE;
    116         }
     120        if (ret == NULL) {
     121                /* Check errno to avoid shadowing other possible errors. */
     122                if (errno == EOK) {
     123                        errno = ERANGE;
     124                }
     125        } else {
     126                /* Success, restore previous errno value. */
     127                errno = orig_errno;
     128        }
     129       
    117130        return ret;
    118131}
Note: See TracChangeset for help on using the changeset viewer.