aboutsummaryrefslogtreecommitdiff
path: root/src/sg_ses_microcode.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2018-05-15 20:44:45 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2018-05-15 20:44:45 +0000
commit856fb91355bddbe7a15a9d11334c354d8ee7b6d3 (patch)
tree9446f14be2d17b1f0449a466e0762a9a3361ca7b /src/sg_ses_microcode.c
parent71e56cc16387a76971a04fda4ff9306ec704daf9 (diff)
downloadsg3_utils-856fb91355bddbe7a15a9d11334c354d8ee7b6d3.tar.gz
cleanup of error messages around sg_cmds_open_device(); add flock error msg for ddpt
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@772 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src/sg_ses_microcode.c')
-rw-r--r--src/sg_ses_microcode.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/sg_ses_microcode.c b/src/sg_ses_microcode.c
index f503180e..f8ffccd2 100644
--- a/src/sg_ses_microcode.c
+++ b/src/sg_ses_microcode.c
@@ -41,7 +41,7 @@
* RESULTS commands in order to send microcode to the given SES device.
*/
-static const char * version_str = "1.13 20180219"; /* ses4r02 */
+static const char * version_str = "1.14 20180513"; /* ses4r02 */
#define ME "sg_ses_microcode: "
#define MAX_XFER_LEN (128 * 1024 * 1024)
@@ -480,7 +480,8 @@ main(int argc, char * argv[])
{
bool last, got_stdin, is_reg;
bool want_file = false;
- int sg_fd, res, c, len, k, n, rsp_len, resid, act_len, din_len, verb;
+ int res, c, len, k, n, rsp_len, resid, act_len, din_len, verb;
+ int sg_fd = -1;
int infd = -1;
int do_help = 0;
int ret = 0;
@@ -686,9 +687,11 @@ main(int argc, char * argv[])
sg_fd = sg_cmds_open_device(device_name, false /* rw */, op->verbose);
if (sg_fd < 0) {
- pr2serr(ME "open error: %s: %s\n", device_name,
- safe_strerror(-sg_fd));
- return SG_LIB_FILE_ERROR;
+ if (op->verbose)
+ pr2serr(ME "open error: %s: %s\n", device_name,
+ safe_strerror(-sg_fd));
+ ret = sg_convert_errno(-sg_fd);
+ goto fini;
}
if (file_name && (! want_file))
@@ -896,21 +899,18 @@ fini:
free(dout.free_doutp);
if (free_dip)
free(free_dip);
- res = sg_cmds_close_device(sg_fd);
- if (res < 0) {
- pr2serr("close error: %s\n", safe_strerror(-res));
- if (0 == ret)
- return SG_LIB_FILE_ERROR;
+ if (sg_fd >= 0) {
+ res = sg_cmds_close_device(sg_fd);
+ if (res < 0) {
+ pr2serr("close error: %s\n", safe_strerror(-res));
+ if (0 == ret)
+ ret = sg_convert_errno(-res);
+ }
}
- if (ret && (0 == op->verbose)) {
- if (SG_LIB_CAT_INVALID_OP == ret)
- pr2serr("%sRECEIVE DIAGNOSTIC RESULTS command not supported\n",
- ((MODE_DNLD_STATUS == op->mc_mode) ?
- "" : "SEND DIAGNOSTIC or "));
- else if (ret > 0)
- pr2serr("Failed, exit status %d\n", ret);
- else if (ret < 0)
- pr2serr("Some error occurred\n");
+ if (0 == op->verbose) {
+ if (! sg_if_can2stderr("sg_ses_mocrocode failed: ", ret))
+ pr2serr("Some error occurred, try again with '-v' "
+ "or '-vv' for more information\n");
}
return (ret >= 0) ? ret : SG_LIB_CAT_OTHER;
}