Revert "libdlog doesn't modify errno from outside PoV" 50/218850/1
authorHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 29 Nov 2019 01:48:58 +0000 (01:48 +0000)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 29 Nov 2019 01:49:34 +0000 (01:49 +0000)
This reverts commit 6afdbf69c184f8b1b466af16d65272ad9e7f757a.

Change-Id: Ie046f84788b84f748211df374d8d601db1280810
(cherry picked from commit c1bfe2b28c85594c5180c83f2fed0c1e9b116570)

src/libdlog/log.c

index 06b4207..755429e 100644 (file)
@@ -310,19 +310,6 @@ static int __write_to_log(log_id_t log_id, int prio, const char *tag, const char
        if (ret < 0)
                return ret;
 
-       /* DLog is often used to log errors, but people usually fail to
-        * handle errno correctly, forgetting that logging can also
-        * modify it, like this:
-        *
-        * if (foo() == -1) {
-        *     dlog_print(...);
-        *     if (errno == ...) // potentially uses DLog's errno
-        *
-        * Therefore we take an extra step to remedy this. It is fairly
-        * unfortunate to have to do this because it might encourage lazy
-        * coding, but it's probably more important that the system works. */
-       const int initial_errno = errno;
-
        /* Threads can be cancelled before they give up a lock.
         * Therefore cancellation is temporarily disabled.
         * This solution is comparatively simple and cheap.
@@ -347,7 +334,6 @@ static int __write_to_log(log_id_t log_id, int prio, const char *tag, const char
 
        pthread_setcancelstate(old_cancel_state, NULL);
 
-       errno = initial_errno;
        return ret;
 }