diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2018-05-24 01:13:38 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2018-05-24 01:13:38 +0000 |
commit | 919290b79eb6649d6d05242180ddb3944ca9521b (patch) | |
tree | e2b2f839acafdc5493bb21e81e4361f37c8f4357 /src/sg_sat_phy_event.c | |
parent | 26e76bf6c671941fec1a8d2b3fb53fcd64993577 (diff) | |
download | sg3_utils-919290b79eb6649d6d05242180ddb3944ca9521b.tar.gz |
add SG_LIB_LOGIC_ERROR and SG_LIB_CONTRADICT; implement across many utilities and increase usage of sg_convert_errno()
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@774 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src/sg_sat_phy_event.c')
-rw-r--r-- | src/sg_sat_phy_event.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/sg_sat_phy_event.c b/src/sg_sat_phy_event.c index 87b7ce54..d7f4e17a 100644 --- a/src/sg_sat_phy_event.c +++ b/src/sg_sat_phy_event.c @@ -11,6 +11,7 @@ #include <stdlib.h> #include <stdarg.h> #include <stdbool.h> +#include <errno.h> #include <string.h> #include <getopt.h> #define __STDC_FORMAT_MACROS 1 @@ -367,7 +368,7 @@ int main(int argc, char * argv[]) bool raw = false; bool reset = false; bool ck_cond = false; /* set to true to read register(s) back */ - int sg_fd, c, k, j, res, id, len, vendor; + int sg_fd, c, k, j, res, id, len, vendor, err; char * device_name = 0; char ebuff[EBUFF_SZ]; uint8_t inBuff[READ_LOG_EXT_RESPONSE_LEN]; @@ -454,10 +455,11 @@ int main(int argc, char * argv[]) } if ((sg_fd = open(device_name, O_RDWR)) < 0) { + err = errno; snprintf(ebuff, EBUFF_SZ, "sg_sat_phy_event: error opening file: %s", device_name); perror(ebuff); - return SG_LIB_FILE_ERROR; + return sg_convert_errno(err); } ret = do_read_log_ext(sg_fd, SATA_PHY_EVENT_LPAGE, false /* page_in_log */, @@ -494,9 +496,10 @@ int main(int argc, char * argv[]) res = close(sg_fd); if (res < 0) { - pr2serr("close error: %s\n", safe_strerror(-res)); + err = errno; + pr2serr("close error: %s\n", safe_strerror(err)); if (0 == ret) - return SG_LIB_FILE_ERROR; + ret = sg_convert_errno(err); } return (ret >= 0) ? ret : SG_LIB_CAT_OTHER; } |