aboutsummaryrefslogtreecommitdiff
path: root/lib/sg_lib.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2018-07-15 18:29:28 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2018-07-15 18:29:28 +0000
commit35431d98669788d1565c9a7b5d8619b8846a0df9 (patch)
tree2367642607a3c8d0fa9d6fbee318bfd553420f31 /lib/sg_lib.c
parentceb7178cbfe8f784f8148da8725098395abb0578 (diff)
downloadsg3_utils-35431d98669788d1565c9a7b5d8619b8846a0df9.tar.gz
sg_lib: fix bug in producing exit status strings
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@783 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'lib/sg_lib.c')
-rw-r--r--lib/sg_lib.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/sg_lib.c b/lib/sg_lib.c
index 9a9c223a..e027f539 100644
--- a/lib/sg_lib.c
+++ b/lib/sg_lib.c
@@ -1910,9 +1910,9 @@ bool sg_exit2str(int exit_status, bool longer, int b_len, char *b)
b[0] = '\0';
if (exit_status < 0)
return false;
- else if ((0 == exit_status) || (SG_LIB_OK_FALSE)) {
+ else if ((0 == exit_status) || (SG_LIB_OK_FALSE == exit_status)) {
if (longer)
- snprintf(b, b_len, "%s", ess->name);
+ goto fini;
return true;
}
@@ -1926,6 +1926,7 @@ bool sg_exit2str(int exit_status, bool longer, int b_len, char *b)
exit_status - 128);
return true;
}
+fini:
for ( ; ess->name; ++ess) {
if (exit_status == ess->value)
break;
@@ -1946,7 +1947,7 @@ sg_if_can2fp(const char * leadin, int exit_status, FILE * fp)
char b[256];
const char * s = leadin ? leadin : "";
- if ((0 == exit_status) || (SG_LIB_OK_FALSE))
+ if ((0 == exit_status) || (SG_LIB_OK_FALSE == exit_status))
return true; /* don't print anything */
else if (sg_exit2str(exit_status, false, sizeof(b), b)) {
fprintf(fp, "%s%s\n", s, b);