Move setting of error text to crypt_log to catch all errors.
authorMilan Broz <gmazyland@gmail.com>
Sun, 9 Oct 2011 13:46:24 +0000 (13:46 +0000)
committerMilan Broz <gmazyland@gmail.com>
Sun, 9 Oct 2011 13:46:24 +0000 (13:46 +0000)
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@626 36d66b0a-2a48-0410-832c-cd162a569da5

lib/setup.c

index 3550101..01f3bca 100644 (file)
@@ -94,15 +94,6 @@ int crypt_get_debug_level(void)
        return _debug_level;
 }
 
-
-void crypt_log(struct crypt_device *cd, int level, const char *msg)
-{
-       if (cd && cd->log)
-               cd->log(level, msg, cd->log_usrptr);
-       else if (_default_log)
-               _default_log(level, msg, NULL);
-}
-
 static void crypt_set_error(struct crypt_device *cd, const char *error)
 {
        size_t size = strlen(error);
@@ -120,6 +111,17 @@ static void crypt_set_error(struct crypt_device *cd, const char *error)
        }
 }
 
+void crypt_log(struct crypt_device *cd, int level, const char *msg)
+{
+       if (cd && cd->log)
+               cd->log(level, msg, cd->log_usrptr);
+       else if (_default_log)
+               _default_log(level, msg, NULL);
+
+       if (level == CRYPT_LOG_ERROR)
+               crypt_set_error(cd, msg);
+}
+
 __attribute__((format(printf, 5, 6)))
 void logger(struct crypt_device *cd, int level, const char *file,
            int line, const char *format, ...)
@@ -139,9 +141,6 @@ void logger(struct crypt_device *cd, int level, const char *file,
                } else if (_debug_level)
                        printf("# %s\n", target);
 #endif
-
-               if (level == CRYPT_LOG_ERROR)
-                       crypt_set_error(cd, target);
        }
 
        va_end(argp);