aboutsummaryrefslogtreecommitdiff
path: root/src/sg_format.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2018-05-24 01:13:38 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2018-05-24 01:13:38 +0000
commit919290b79eb6649d6d05242180ddb3944ca9521b (patch)
treee2b2f839acafdc5493bb21e81e4361f37c8f4357 /src/sg_format.c
parent26e76bf6c671941fec1a8d2b3fb53fcd64993577 (diff)
downloadsg3_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_format.c')
-rw-r--r--src/sg_format.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/sg_format.c b/src/sg_format.c
index e447bdc1..a8646b74 100644
--- a/src/sg_format.c
+++ b/src/sg_format.c
@@ -22,6 +22,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <string.h>
+#include <errno.h>
#include <getopt.h>
#include <unistd.h>
#define __STDC_FORMAT_MACROS 1
@@ -37,7 +38,7 @@
#include "sg_pr2serr.h"
#include "sg_pt.h"
-static const char * version_str = "1.49 20180519";
+static const char * version_str = "1.50 20180522";
#define RW_ERROR_RECOVERY_PAGE 1 /* can give alternate with --mode=MP */
@@ -264,7 +265,7 @@ sg_ll_format_medium(int sg_fd, bool verify, bool immed, int format,
ptvp = construct_scsi_pt_obj();
if (NULL == ptvp) {
pr2serr("%s: out of memory\n", __func__);
- return -1;
+ return sg_convert_errno(ENOMEM);
}
set_scsi_pt_cdb(ptvp, fm_cdb, sizeof(fm_cdb));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
@@ -1016,28 +1017,28 @@ main(int argc, char **argv)
if (op->format && (op->tape >= 0)) {
pr2serr("Cannot choose both '--format' and '--tape='; disk "
"or tape, choose one only\n");
- return SG_LIB_SYNTAX_ERROR;
+ return SG_LIB_CONTRADICT;
}
if (op->ip_def && op->sec_init) {
pr2serr("'--ip_def' and '--security' contradict, choose "
"one\n");
- return SG_LIB_SYNTAX_ERROR;
+ return SG_LIB_CONTRADICT;
}
if (op->resize) {
if (op->format) {
pr2serr("both '--format' and '--resize' not "
"permitted\n");
usage();
- return SG_LIB_SYNTAX_ERROR;
+ return SG_LIB_CONTRADICT;
} else if (0 == op->blk_count) {
pr2serr("'--resize' needs a '--count' (other than "
"0)\n");
usage();
- return SG_LIB_SYNTAX_ERROR;
+ return SG_LIB_CONTRADICT;
} else if (0 != op->blk_size) {
pr2serr("'--resize' not compatible with '--size'\n");
usage();
- return SG_LIB_SYNTAX_ERROR;
+ return SG_LIB_CONTRADICT;
}
}
if ((op->pinfo > 0) || (op->rto_req > 0) || (op->fmtpinfo > 0)) {
@@ -1046,7 +1047,7 @@ main(int argc, char **argv)
"'--rto_req' together with\n'--fmtpinfo', "
"best use '--fmtpinfo' only\n");
usage();
- return SG_LIB_SYNTAX_ERROR;
+ return SG_LIB_CONTRADICT;
}
if (op->pinfo)
op->fmtpinfo |= 2;