From 9032e61b88dccd145f34c9a98f3933f3073dd49d Mon Sep 17 00:00:00 2001 From: Sansar Choinyambuu Date: Fri, 16 Sep 2011 11:17:32 +0200 Subject: [PATCH] Fixed bug at checking error code from file stat --- src/libpts/pts/pts.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/libpts/pts/pts.c b/src/libpts/pts/pts.c index 3a8c464fe4..d46196974b 100644 --- a/src/libpts/pts/pts.c +++ b/src/libpts/pts/pts.c @@ -273,29 +273,28 @@ static char* get_filename(char *pathname) METHOD(pts_t, is_path_valid, bool, private_pts_t *this, char *path, pts_error_code_t *error_code) { - int error; struct stat st; - + *error_code = 0; - error = stat(path, &st); - if (error == 0) + + if (!stat(path, &st)) { return TRUE; } - else if (error == ENOENT || error == ENOTDIR) + else if (errno == ENOENT || errno == ENOTDIR) { DBG1(DBG_PTS, "file/directory does not exist %s", path); *error_code = TCG_PTS_FILE_NOT_FOUND; } - else if (error == EFAULT) + else if (errno == EFAULT) { DBG1(DBG_PTS, "bad address %s", path); *error_code = TCG_PTS_INVALID_PATH; } else { - DBG1(DBG_PTS, "error: %s occurred while validating path: %s", - strerror(error), path); + DBG1(DBG_PTS, "error: %s occured while validating path: %s", + strerror(errno), path); return FALSE; } -- 2.47.3