Page MenuHomeFreeBSD

D40521.diff
No OneTemporary

D40521.diff

diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c
--- a/sbin/camcontrol/camcontrol.c
+++ b/sbin/camcontrol/camcontrol.c
@@ -3827,11 +3827,8 @@
struct scsi_read_defect_data_hdr_10 *hdr10 = NULL;
struct scsi_read_defect_data_hdr_12 *hdr12 = NULL;
size_t hdr_size = 0, entry_size = 0;
- int use_12byte = 0;
- int hex_format = 0;
u_int8_t *defect_list = NULL;
u_int8_t list_format = 0;
- int list_type_set = 0;
u_int32_t dlist_length = 0;
u_int32_t returned_length = 0, valid_len = 0;
u_int32_t num_returned = 0, num_valid = 0;
@@ -3839,11 +3836,11 @@
u_int32_t starting_offset = 0;
u_int8_t returned_format, returned_type;
unsigned int i;
- int summary = 0, quiet = 0;
int c, error = 0;
- int lists_specified = 0;
- int get_length = 1, first_pass = 1;
- int mads = 0;
+ int mads = 0, lists_specified = 0;
+ bool summary = false, quiet = false, list_type_set = false;
+ bool get_length = true, use_12byte = false, first_pass = true;
+ bool hex_format = false;
while ((c = getopt(argc, argv, combinedopt)) != -1) {
switch(c){
@@ -3860,7 +3857,7 @@
if (status == SCSI_NV_FOUND) {
list_format = defect_list_type_map[
entry_num].value;
- list_type_set = 1;
+ list_type_set = true;
} else {
warnx("%s: %s %s option %s", __func__,
(status == SCSI_NV_AMBIGUOUS) ?
@@ -3878,10 +3875,10 @@
arglist |= CAM_ARG_PLIST;
break;
case 'q':
- quiet = 1;
+ quiet = true;
break;
case 's':
- summary = 1;
+ summary = true;
break;
case 'S': {
char *endptr;
@@ -3895,14 +3892,14 @@
break;
}
case 'X':
- hex_format = 1;
+ hex_format = true;
break;
default:
break;
}
}
- if (list_type_set == 0) {
+ if (!list_type_set) {
error = 1;
warnx("no defect list format specified");
goto defect_bailout;
@@ -3922,7 +3919,7 @@
* This implies a summary, and was the previous behavior.
*/
if (lists_specified == 0)
- summary = 1;
+ summary = true;
ccb = cam_getccb(device);
@@ -3934,7 +3931,7 @@
* if you ask for more data than the drive has. Once we know the
* length, we retry the command with the returned length.
*/
- if (use_12byte == 0)
+ if (!use_12byte)
dlist_length = sizeof(*hdr10);
else
dlist_length = sizeof(*hdr12);
@@ -3983,7 +3980,7 @@
valid_len = ccb->csio.dxfer_len - ccb->csio.resid;
- if (use_12byte == 0) {
+ if (!use_12byte) {
hdr10 = (struct scsi_read_defect_data_hdr_10 *)defect_list;
hdr_size = sizeof(*hdr10);
hdr_max = SRDDH10_MAX_LENGTH;
@@ -4037,8 +4034,8 @@
num_valid = min(returned_length, valid_len - hdr_size);
num_valid /= entry_size;
- if (get_length != 0) {
- get_length = 0;
+ if (get_length) {
+ get_length = false;
if ((ccb->ccb_h.status & CAM_STATUS_MASK) ==
CAM_SCSI_STATUS_ERROR) {
@@ -4059,10 +4056,10 @@
if ((sense_key == SSD_KEY_RECOVERED_ERROR)
&& (asc == 0x1c) && (ascq == 0x00)
&& (returned_length > 0)) {
- if ((use_12byte == 0)
+ if (!use_12byte
&& (returned_length >= max_possible_size)) {
- get_length = 1;
- use_12byte = 1;
+ get_length = true;
+ use_12byte = true;
goto retry_12byte;
}
dlist_length = returned_length + hdr_size;
@@ -4077,9 +4074,9 @@
* command can support. Retry with the 12
* byte command.
*/
- if (use_12byte == 0) {
- get_length = 1;
- use_12byte = 1;
+ if (!use_12byte) {
+ get_length = true;
+ use_12byte = true;
goto retry_12byte;
}
dlist_length = returned_length + hdr_size;
@@ -4093,9 +4090,9 @@
* error and no data. Retry with the 12
* byte command.
*/
- if (use_12byte == 0) {
- get_length = 1;
- use_12byte = 1;
+ if (!use_12byte) {
+ get_length = true;
+ use_12byte = true;
goto retry_12byte;
}
dlist_length = returned_length + hdr_size;
@@ -4108,11 +4105,11 @@
if (returned_length == 0)
dlist_length = SRDD10_MAX_LENGTH;
else {
- if ((use_12byte == 0)
+ if (!use_12byte
&& (returned_length >=
max_possible_size)) {
- get_length = 1;
- use_12byte = 1;
+ get_length = true;
+ use_12byte = true;
goto retry_12byte;
}
dlist_length = returned_length +
@@ -4128,17 +4125,17 @@
CAM_EPF_ALL, stderr);
goto defect_bailout;
} else {
- if ((use_12byte == 0)
+ if (!use_12byte
&& (returned_length >= max_possible_size)) {
- get_length = 1;
- use_12byte = 1;
+ get_length = true;
+ use_12byte = true;
goto retry_12byte;
}
dlist_length = returned_length + hdr_size;
}
- if (summary != 0) {
+ if (summary) {
fprintf(stdout, "%u", num_returned);
- if (quiet == 0) {
+ if (!quiet) {
fprintf(stdout, " defect%s",
(num_returned != 1) ? "s" : "");
}
@@ -4222,7 +4219,7 @@
goto defect_bailout;
}
- if (first_pass != 0) {
+ if (first_pass) {
fprintf(stderr, "Got %d defect", num_returned);
if ((lists_specified == 0) || (num_returned == 0)) {
@@ -4233,7 +4230,7 @@
else
fprintf(stderr, "s:\n");
- first_pass = 0;
+ first_pass = false;
}
/*
@@ -4258,7 +4255,7 @@
0 : 1;
sector &= ~SDD_EXT_PHYS_FLAG_MASK;
}
- if (hex_format == 0)
+ if (!hex_format)
fprintf(stdout, "%d:%d:%d%s",
scsi_3btoul(dlist[i].cylinder),
dlist[i].head,
@@ -4294,7 +4291,7 @@
mads = (bfi & SDD_EXT_BFI_MADS) ? 1 : 0;
bfi &= ~SDD_EXT_BFI_FLAG_MASK;
}
- if (hex_format == 0)
+ if (!hex_format)
fprintf(stdout, "%d:%d:%d%s",
scsi_3btoul(dlist[i].cylinder),
dlist[i].head,
@@ -4323,7 +4320,7 @@
(defect_list + hdr_size);
for (i = 0; i < num_valid; i++) {
- if (hex_format == 0)
+ if (!hex_format)
fprintf(stdout, "%u\n",
scsi_4btoul(dlist[i].address));
else
@@ -4346,7 +4343,7 @@
(defect_list + hdr_size);
for (i = 0; i < num_valid; i++) {
- if (hex_format == 0)
+ if (!hex_format)
fprintf(stdout, "%ju\n",
(uintmax_t)scsi_8btou64(
dlist[i].address));

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 9, 10:31 PM (10 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31174504
Default Alt Text
D40521.diff (5 KB)

Event Timeline