if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
}
else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
d_raw((unsigned char *)&log, sizeof(log));
} else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
d_raw((unsigned char *)&stats, sizeof(stats));
} else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
err = EIO;
} else
printf("Successfully wrote log to %s\n", cfg.file);
+ close(output);
+out_free:
free(intel);
+ close(fd);
return err;
}
fid, result);
} else {
printf("Could not read feature id 0xE2.\n");
+ close(fd);
return err;
}
break;
printf("%d not supported.\n", option);
return EINVAL;
}
+ close(fd);
return fd;
}
if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
nvme_select_to_string(0), result);
} else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
} else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
if (parse_params(cfg.param, 2, ¶m1, ¶m2)) {
printf("setfeature: invalid formats %s\n", cfg.param);
- exit(EINVAL);
+ close(fd);
+ return EINVAL;
}
if ((param1 == 1) && (param2 < P2MIN || param2 > P2MAX)) {
printf("setfeature: invalid high io latency threshold %d\n", param2);
- exit(EINVAL);
+ close(fd);
+ return EINVAL;
}
cfg.value = (param1 << MB_FEAT_HIGH_LATENCY_VALUE_SHIFT) | param2;
} else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
}
if (NULL != fdi) fclose(fdi);
+ close(fd);
return err;
}
if (err < 0) {
perror("fstat");
err = errno;
+ goto out_close;
}
fw_size = sb.st_size;
if (fw_size & 0x3) {
fprintf(stderr, "Invalid size:%d for f/w image\n", fw_size);
err = EINVAL;
- goto out;
+ goto out_close;
}
if (posix_memalign(&fw_buf, getpagesize(), fw_size)) {
fprintf(stderr, "No memory for f/w size:%d\n", fw_size);
err = ENOMEM;
- goto out;
+ goto out_close;
}
- if (read(fw_fd, fw_buf, fw_size) != ((ssize_t)(fw_size)))
- return EIO;
+ if (read(fw_fd, fw_buf, fw_size) != ((ssize_t)(fw_size))) {
+ err = errno;
+ goto out_free;
+ }
while (fw_size > 0) {
xfer = min(xfer, fw_size);
err = nvme_fw_download(&args);
if (err < 0) {
perror("fw-download");
- goto out;
+ goto out_free;
} else if (err != 0) {
nvme_show_status(err);
- goto out;
+ goto out_free;
}
fw_buf += xfer;
fw_size -= xfer;
fprintf(stderr, "Update successful! Please power cycle for changes to take effect\n");
}
+out_free:
+ free(fw_buf);
+out_close:
+ close(fw_fd);
out:
+ close(fd);
return err;
}
fPRINT_PARAM1("Unsupported io latency histogram revision\n");
}
- fclose(fdi);
+ if (fdi)
+ fclose(fdi);
return 1;
}
printf("NVMe Status:%s(%x)\n", nvme_status_to_string(err), err);
};
*/
+ close(fd);
return err;
}
fid, result);
} else {
printf("Could not read feature id 0xE2.\n");
+ close(fd);
return err;
}
break;
break;
default:
printf("%d not supported.\n", option);
- return EINVAL;
+ err = EINVAL;
}
- return fd;
+ close(fd);
+ return err;
}
};
fd = parse_and_open(argc, argv, desc, opts);
-
if (fd < 0)
return fd;
if (strlen(cfg.select) != 3) {
fprintf(stderr, "Invalid select flag\n");
- err = EINVAL;
- goto out;
+ close(fd);
+ return EINVAL;
}
for (int i = 0; i < 3; i++) {
selectNo = 26;
} else {
fprintf(stderr, "Invalid select flag\n");
- err = EINVAL;
- goto out;
+ close(fd);
+ return EINVAL;
}
fw_fd = open(cfg.fw, O_RDONLY);
if (fw_fd < 0) {
fprintf(stderr, "no firmware file provided\n");
- err = EINVAL;
- goto out;
+ close(fd);
+ return EINVAL;
}
err = fstat(fw_fd, &sb);
if (err < 0) {
perror("fstat");
err = errno;
+ goto out;
}
fw_size = sb.st_size;
goto out;
}
- if (read(fw_fd, fw_buf, fw_size) != ((ssize_t) (fw_size)))
- return EIO;
+ if (read(fw_fd, fw_buf, fw_size) != ((ssize_t) (fw_size))) {
+ err = errno;
+ goto out_free;
+ }
while (fw_size > 0) {
xfer = min(xfer, fw_size);
err = nvme_fw_download(&args);
if (err < 0) {
perror("fw-download");
- goto out;
+ goto out_free;
} else if (err != 0) {
nvme_show_status(err);
- goto out;
+ goto out_free;
}
fw_buf += xfer;
fw_size -= xfer;
"Update successful! Power cycle for changes to take effect\n");
}
+out_free:
+ free(fw_buf);
out:
+ close(fw_fd);
+ close(fd);
return err;
}
}
}
}
+ close(fd);
return err;
}
sscanf(argv[optind], "/dev/nvme%d", &ctrlIdx);
if ((eModel = GetDriveModel(ctrlIdx)) == UNKNOWN_MODEL) {
printf ("Unsupported drive model for vs-pcie-stats command\n");
- close(fd);
goto out;
}
res = fgets(correctable, sizeof(correctable), fp);
if (res == NULL) {
printf("Failed to retrieve error count\n");
+ pclose(fp);
goto out;
}
pclose(fp);
res = fgets(uncorrectable, sizeof(uncorrectable), fp);
if (res == NULL) {
printf("Failed to retrieve error count\n");
+ pclose(fp);
goto out;
}
pclose(fp);
}
out:
+ close(fd);
return err;
}
res = fgets(correctable, sizeof(correctable), fp);
if (res == NULL) {
printf("Failed to retrieve error count\n");
+ pclose(fp);
goto out;
}
pclose(fp);
printf("Device correctable errors detected: %s\n", correctable);
err = 0;
out:
- if (fd > 0)
- close(fd);
+ close(fd);
return err;
}
if (model == UNKNOWN_MODEL) {
fprintf(stderr, "ERROR : Unsupported drive for vs-drive-info cmd");
+ close(fd);
return -1;
}
err = nvme_submit_admin_passthru(fd, &admin_cmd, NULL);
if (err) {
fprintf(stderr, "ERROR : drive-info opcode failed with 0x%x\n", err);
+ close(fd);
return -1;
}
} else {
err = nvme_identify_ctrl(fd, &ctrl);
if (err) {
fprintf(stderr, "ERROR : identify_ctrl() failed with 0x%x\n", err);
+ close(fd);
return -1;
}
dinfo.hw_ver_major = ctrl.vs[820];
}
}
+ close(fd);
return 0;
}
}
}
out:
- if (fd > 0)
- close(fd);
+ close(fd);
return err;
}
enable = 0;
} else if (strcmp(opt.option, "status")) {
printf("Invalid control option %s specified\n", opt.option);
+ close(fd);
return -1;
}
err = nvme_get_features(&g_args);
if (err != 0) {
printf("Failed to retrieve latency monitoring feature status\n");
+ close(fd);
return err;
}
} else if (result == 0) {
printf("\n");
}
+ close(fd);
return err;
}
if (enable == 1) {
if (opt.threshold > 2550) {
printf("The maximum threshold value cannot be more than 2550 ms\n");
+ close(fd);
return -1;
}
/* timing mask is in terms of 10ms units, so min allowed is 10ms */
else if ((opt.threshold % 10) != 0) {
printf("The threshold value should be multiple of 10 ms\n");
+ close(fd);
return -1;
}
opt.threshold /= 10;
} else if (strcmp(opt.command, "all")) {
printf("Invalid command %s specified for option %s\n",
opt.command, opt.option);
+ close(fd);
return -1;
}
if (err) {
if (err < 0)
printf("Unable to retrieve latency stats log the drive\n");
+ close(fd);
return err;
}
/* print header and each log entry */
log[i].deac, log[i].prinfo, log[i].fua, log[i].lr);
}
printf("\n");
+ close(fd);
return err;
}
cmd_str = "Trim";
} else if (strcmp(opt.command, "all")) {
printf("Invalid command option %s to display latency stats\n", opt.command);
+ close(fd);
return -1;
}
if (err) {
if (err < 0)
printf("Unable to retrieve latency stats log the drive\n");
+ close(fd);
return err;
}
printf("Micron IO %s Command Latency Statistics\n"
printf("%2d %8s %8s %8"PRIu64"\n",
bucket, start, end, cmd_stats[b]);
}
+ close(fd);
return err;
}
err = nvme_set_features_simple(fd, fid, 1, 0, 0, &result);
if (err == 0) err = (int)result;
+ close(fd);
return err;
}
fd = parse_and_open(argc, argv, desc, opts);
if (fd < 0)
- goto out;
+ return fd;
/* if telemetry type is specified, check for data area */
if (strlen(cfg.type) != 0) {
cfg.log = 0x08;
} else if (strcmp(cfg.type, "host")) {
printf ("telemetry type (host or controller) should be specified i.e. -t=host\n");
- close(fd);
goto out;
}
if (cfg.data_area <= 0 || cfg.data_area > 3) {
printf ("data area must be selected using -d option ie --d=1,2,3\n");
- close(fd);
goto out;
}
telemetry_option = 1;
} else if (cfg.data_area > 0) {
printf ("data area option is valid only for telemetry option (i.e --type=host|controller)\n");
- close(fd);
goto out;
}
sscanf(argv[optind], "/dev/nvme%d", &ctrlIdx);
if ((eModel = GetDriveModel(ctrlIdx)) == UNKNOWN_MODEL) {
printf ("Unsupported drive model for vs-internal-log collection\n");
- close(fd);
goto out;
}
WriteData(buffer, logSize, dir, cfg.package, msg);
free(buffer);
}
- close(fd);
goto out;
}
err = ZipAndRemoveDir(strMainDirName, cfg.package);
out:
+ close(fd);
return err;
}
if (ret)
fprintf(stderr, "ERROR : OCP : Failure reading the C0 Log Page, ret = %d\n",
ret);
-
+ close(fd);
return ret;
}
fprintf(stderr,
"ERROR : OCP : Failure reading the C3 Log Page, ret = %d\n",
ret);
-
+ close(fd);
return ret;
}
fd = parse_and_open(argc, argv, desc, opts);
+ if (fd < 0) {
+ return fd;
+ }
err = nvme_get_nsid_log(fd, false, 0xca, cfg.namespace_id,
sizeof(smart_log), (void *)&smart_log);
}
else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
};
fd = parse_and_open(argc, argv, desc, opts);
+ if (fd < 0) {
+ return fd;
+ }
err = nvme_get_log_simple(fd, cfg.write ? 0xc3 : 0xc1, sizeof(stats), (void *)&stats);
if (!err) {
d_raw((unsigned char *)&stats, sizeof(stats));
} else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
};
fd = parse_and_open(argc, argv, desc, opts);
-
if (fd < 0) {
return fd;
}
data_buf = malloc(buf_size);
if (!data_buf) {
fprintf(stderr, "malloc fail, errno %d\r\n", errno);
+ close(fd);
return -1;
}
}
free(data_buf);
+ close(fd);
return 0;
}
if (ioctl(fd, SFX_GET_FREESPACE, &ctx)) {
fprintf(stderr, "vu ioctl fail, errno %d\r\n", errno);
+ close(fd);
return -1;
}
show_cap_info(&ctx);
+ close(fd);
return err;
}
if (change_sanity_check(fd, cap_in_4k, &shrink)) {
printf("ScaleFlux change-capacity: fail\n");
+ close(fd);
return err;
}
if (!cfg.force && shrink && !sfx_confirm_change("Changing Cap may irrevocably delete this device's data")) {
+ close(fd);
return 0;
}
printf("ScaleFlux change-capacity: success\n");
ioctl(fd, BLKRRPART);
}
+ close(fd);
return err;
}
if (!cfg.feature_id) {
fprintf(stderr, "feature-id required param\n");
+ close(fd);
return EINVAL;
}
if (cfg.feature_id == SFX_FEAT_CLR_CARD) {
/*Warning for clean card*/
if (!cfg.force && !sfx_confirm_change("Going to clean device's data, confirm umount fs and try again")) {
+ close(fd);
return 0;
} else {
return sfx_clean_card(fd);
perror("identify-namespace");
else
nvme_show_status(err);
+ close(fd);
return err;
}
/*
*/
if ((ns.flbas & 0xf) != 1) {
printf("Please change-sector size to 4K, then retry\n");
+ close(fd);
return EFAULT;
}
}
} else if (cfg.feature_id == SFX_FEAT_UP_P_CAP) {
if (cfg.value <= 0) {
fprintf(stderr, "Invalid Param\n");
+ close(fd);
return EINVAL;
}
/*Warning for change pacp by GB*/
if (!cfg.force && !sfx_confirm_change("Changing physical capacity may irrevocably delete this device's data")) {
+ close(fd);
return 0;
}
}
if (err < 0) {
perror("ScaleFlux-set-feature");
+ close(fd);
return errno;
} else if (!err) {
printf("ScaleFlux set-feature:%#02x (%s), value:%d\n", cfg.feature_id,
} else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
};
fd = parse_and_open(argc, argv, desc, opts);
-
if (fd < 0) {
return fd;
}
if (!cfg.feature_id) {
fprintf(stderr, "feature-id required param\n");
+ close(fd);
return EINVAL;
}
err = nvme_sfx_get_features(fd, cfg.namespace_id, cfg.feature_id, &result);
if (err < 0) {
perror("ScaleFlux-get-feature");
+ close(fd);
return errno;
} else if (!err) {
printf("ScaleFlux get-feature:%02x (%s), value:%d\n", cfg.feature_id,
} else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
};
fd = parse_and_open(argc, argv, desc, opts);
+ if (fd < 0)
+ return fd;
err = nvme_get_log_simple(fd, 0xc5, sizeof(logPageMap), &logPageMap);
if (!err) {
if (strcmp(cfg.output_format,"json")) {
if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
};
fd = parse_and_open(argc, argv, desc, opts);
+ if (fd < 0) {
+ printf ("\nDevice not found \n");
+ return -1;
+ }
+
if (strcmp(cfg.output_format,"json"))
printf("Seagate Extended SMART Information :\n");
} else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
if(!strcmp(cfg.output_format,"json"))
json_temp_stats(temperature, PcbTemp, SocTemp, maxTemperature, MaxSocTemp, cf_err, scCurrentTemp, scMaxTemp);
+ close(fd);
return err;
}
/* EOF Temperature Stats information */
};
fd = parse_and_open(argc, argv, desc, opts);
+ if (fd < 0) {
+ printf ("\nDevice not found \n");;
+ return -1;
+ }
+
if(strcmp(cfg.output_format,"json"))
printf("Seagate PCIe error counters Information :\n");
} else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
/* EOF PCIE error-log information */
};
fd = parse_and_open(argc, argv, desc, opts);
+ if (fd < 0) {
+ printf ("\nDevice not found \n");;
+ return -1;
+ }
err = nvme_set_features_simple(fd, 0xE1, 0, 0xCB, cfg.save, &result);
if (err < 0) {
perror("set-feature");
- return errno;
}
+ close(fd);
return err;
}
free(log);
}
+ close(fd);
return err;
}
free(log);
}
- return err;
+ close(fd);
+ return err;
}
void seaget_d_raw(unsigned char *buf, int len, int fd)
dump_fd = open(cfg.file, flags, mode);
if (dump_fd < 0) {
perror(cfg.file);
+ close(fd);
return EINVAL;
}
}
free(log);
}
-
+out:
if(strlen(cfg.file))
close(dump_fd);
+ close(fd);
return err;
}
};
fd = parse_and_open(argc, argv, desc, opts);
+ if (fd < 0)
+ return fd;
err = nvme_get_nsid_log(fd, false, 0xca, cfg.namespace_id,
sizeof(smart_log), &smart_log);
if (!err) {
}
else if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
end:
if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
end:
if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}
}
}
-
+ close(fd);
return result;
}
int badblock = data[0];
printf("Transcend NVME badblock count: %d\n",badblock);
}
-
+ close(fd);
return result;
}
{
char f[PATH_MAX] = {0};
const char *dump_type;
+ int ret;
if (file != NULL) {
strncpy(f, file, PATH_MAX - 1);
else
dump_type = "_crash_dump";
- if (wdc_get_serial_name(fd, f, PATH_MAX, dump_type) == -1) {
+ ret = wdc_get_serial_name(fd, f, PATH_MAX, dump_type);
+ if (ret)
fprintf(stderr, "ERROR : WDC : failed to generate file name\n");
- return -1;
- }
- return wdc_do_crash_dump(fd, f, type);
+ else
+ ret = wdc_do_crash_dump(fd, f, type); \
+ close(fd);
+ return ret;
}
static int wdc_do_drive_log(int fd, char *file)
if (!wdc_check_device(r, fd)) {
nvme_free_tree(r);
+ close(fd);
return -1;
}
capabilities = wdc_get_drive_capabilities(r, fd);
if (cfg.file != NULL) {
strncpy(f, cfg.file, PATH_MAX - 1);
}
- if (wdc_get_serial_name(fd, f, PATH_MAX, "drive_log") == -1) {
+ ret = wdc_get_serial_name(fd, f, PATH_MAX, "drive_log");
+ if (ret)
fprintf(stderr, "ERROR : WDC : failed to generate file name\n");
- nvme_free_tree(r);
- return -1;
- }
- ret = wdc_do_drive_log(fd, f);
+ else
+ ret = wdc_do_drive_log(fd, f);
}
nvme_free_tree(r);
+ close(fd);
return ret;
}
if (!wdc_check_device(r, fd)) {
nvme_free_tree(r);
+ close(fd);
return -1;
}
}
}
nvme_free_tree(r);
+ close(fd);
return ret;
}
if (!wdc_check_device(r, fd)) {
nvme_free_tree(r);
+ close(fd);
return -1;
}
}
}
nvme_free_tree(r);
+ close(fd);
return ret;
}
if (!wdc_check_device(r, fd)) {
nvme_free_tree(r);
+ close(fd);
return -1;
}
nvme_show_status(ret);
}
nvme_free_tree(r);
+ close(fd);
return ret;
}
r = nvme_scan(NULL);
if (!wdc_check_device(r, fd)) {
nvme_free_tree(r);
+ close(fd);
return -1;
}
nvme_show_status(ret);
}
nvme_free_tree(r);
+ close(fd);
return ret;
}
__u8 *byte_raw;
if (bd_data->field_id == 0x00) {
- raw = (__u64*)&bd_data->raw_value[1];
+ raw = (__u64*)&bd_data->raw_value[0];
printf("Additional Smart Log for NVME device:%s namespace-id:%x\n",
devicename, WDC_DE_GLOBAL_NSID);
printf("key normalized raw\n");
out:
nvme_free_tree(r);
+ close(fd);
return ret;
}
} else {
fprintf(stderr, "ERROR : WDC : Unable to read C0 Log Page V1 data\n");
ret = -1;
- goto out;
}
if (data)
free(data);
out:
+ nvme_free_tree(r);
+ close(fd);
return ret;
}
} else {
fprintf(stderr, "ERROR : WDC : Unable to read Hardware Revision Log Page data\n");
ret = -1;
- goto out;
}
free_buf:
free(data);
out:
+ nvme_free_tree(r);
+ close(fd);
return ret;
}
fprintf(stderr, "ERROR : WDC : Failure reading the Latency Monitor (C3) Log Page, ret = %d\n", ret);
out:
+ nvme_free_tree(r);
+ close(fd);
return ret;
}
fprintf(stderr, "ERROR : WDC : Failure reading the Error Recovery (C1) Log Page, ret = 0x%x\n", ret);
out:
+ nvme_free_tree(r);
+ close(fd);
return ret;
}
fprintf(stderr, "ERROR : WDC : Failure reading the Device Capabilities (C4) Log Page, ret = 0x%x\n", ret);
out:
+ nvme_free_tree(r);
+ close(fd);
return ret;
}
fprintf(stderr, "ERROR : WDC : Failure reading the Unsupported Requirements (C5) Log Page, ret = 0x%x\n", ret);
out:
+ nvme_free_tree(r);
+ close(fd);
return ret;
}
out:
nvme_free_tree(r);
+ close(fd);
return ret;
}
out:
nvme_free_tree(r);
+ close(fd);
return ret;
}
out:
nvme_free_tree(r);
+ close(fd);
return ret;
}
/* to retrieve fw activate history data */
if ((data = (__u8*) malloc(sizeof (__u8) * WDC_NVME_SMART_CLOUD_ATTR_LEN)) == NULL) {
fprintf(stderr, "ERROR : WDC : malloc : %s\n", strerror(errno));
- return -1;
+ ret = -1;
+ goto out;
}
/* Get the 0xC0 log data */
fprintf(stderr, "ERROR : WDC : Failure reading the FW Activate History, ret = %d\n", ret);
out:
nvme_free_tree(r);
+ close(fd);
return ret;
}
goto out;
}
- if (capabilities & WDC_DRIVE_CAP_CLEAR_FW_ACT_HISTORY) {
+ if (capabilities & WDC_DRIVE_CAP_CLEAR_FW_ACT_HISTORY)
ret = wdc_do_clear_fw_activate_history_vuc(fd);
- }
- else {
+ else
ret = wdc_do_clear_fw_activate_history_fid(fd);
- }
out:
nvme_free_tree(r);
+ close(fd);
return ret;
}
out:
nvme_free_tree(r);
+ close(fd);
return ret;
}
{
fprintf(stderr, "ERROR : WDC : %s: Failed to get headerPayloadSize from file directory 0x%x\n",
__func__, ret);
- goto end;
+ return ret;
}
fileIdOffsetsBufferSize = WDC_DE_FILE_HEADER_SIZE + (headerPayloadSize * WDC_DE_FILE_OFFSET_SIZE);
continue;
(*maxNumOfEntries)++;
}
- end:
- if (!fileIdOffsetsBuffer)
- free(fileIdOffsetsBuffer);
+end:
+ free(fileIdOffsetsBuffer);
return ret;
}
char d[PATH_MAX] = {0};
char k[PATH_MAX] = {0};
char *d_ptr;
- int fd;
+ int fd, ret;
nvme_root_t r;
__u64 capabilities = 0;
capabilities = wdc_get_drive_capabilities(r, fd);
if ((capabilities & WDC_DRIVE_CAP_DRIVE_ESSENTIALS) != WDC_DRIVE_CAP_DRIVE_ESSENTIALS) {
fprintf(stderr, "ERROR : WDC: unsupported device for this command\n");
- nvme_free_tree(r);
- return -1;
+ ret = -1;
+ goto out;
}
if (cfg.dirName != NULL) {
d_ptr = NULL;
}
- return wdc_do_drive_essentials(r, fd, d_ptr, k);
+ ret = wdc_do_drive_essentials(r, fd, d_ptr, k);
+out:
+ nvme_free_tree(r);
+ close(fd);
+ return ret;
}
static int wdc_do_drive_resize(int fd, uint64_t new_size)
nvme_show_status(ret);
nvme_free_tree(r);
+ close(fd);
return ret;
}
(cfg.op_option != 0xF))
{
fprintf(stderr, "ERROR : WDC: unsupported OP option parameter\n");
+ close(fd);
return -1;
}
nvme_show_status(ret);
nvme_free_tree(r);
+ close(fd);
return ret;
}
ret = validate_output_format(cfg.output_format);
if (ret < 0) {
fprintf(stderr, "%s: ERROR : WDC : invalid output format\n", __func__);
+ close(fd);
return ret;
}
ret = 0;
out:
nvme_free_tree(r);
+ close(fd);
return ret;
}
fprintf(stderr, "ERROR : WDC : Failure reading NAND statistics, ret = %d\n", ret);
nvme_free_tree(r);
+ close(fd);
return ret;
}
out:
nvme_free_tree(r);
+ close(fd);
return ret;
}
fmt = validate_output_format(cfg.output_format);
if (fmt < 0) {
fprintf(stderr, "ERROR : WDC %s invalid output format\n", __func__);
+ close(fd);
return fmt;
}
if (ret) {
fprintf(stderr, "ERROR : WDC %s: Identify Controller failed\n", __func__);
+ close(fd);
return ret;
}
if (ret < 0)
{
fprintf(stderr, "ERROR : WDC: %s: failure to get pci ids, ret = %d\n", __func__, ret);
- return -1;
+ goto out;
}
switch (read_device_id) {
out:
nvme_show_status(ret);
nvme_free_tree(r);
+ close(fd);
return ret;
}
if (fmt < 0) {
fprintf(stderr, "ERROR : WDC : invalid output format\n");
ret = fmt;
- goto END;
+ goto out;
}
/* check if command is supported */
capabilities = wdc_get_drive_capabilities(r, fd);
if ((capabilities & WDC_DRIVE_CAP_TEMP_STATS) != WDC_DRIVE_CAP_TEMP_STATS) {
fprintf(stderr, "ERROR : WDC: unsupported device for this command\n");
- nvme_free_tree(r);
- return -1;
+ ret = -1;
+ goto out;
}
/* get the temperature stats or report errors */
ret = nvme_identify_ctrl(fd, &id_ctrl);
if (ret != 0)
- goto END;
+ goto out;
ret = nvme_get_log_smart(fd, NVME_NSID_ALL, false, &smart_log);
if (ret != 0)
- goto END;
+ goto out;
/* convert from Kelvin to degrees Celsius */
temperature = ((smart_log.temperature[1] << 8) | smart_log.temperature[0]) - 273;
else
printf("%s: Invalid format\n", __func__);
-END:
+out:
nvme_show_status(ret);
nvme_free_tree(r);
+ close(fd);
return ret;
}
capabilities & WDC_DRIVE_CAP_HW_REV_LOG_PAGE ? "Supported" : "Not Supported");
printf("capabilities : Supported\n");
nvme_free_tree(r);
+ close(fd);
return 0;
}
}
nvme_free_tree(r);
+ close(fd);
return 0;
}
}
nvme_free_tree(r);
+ close(fd);
return ret;
}
int xfer_size = 0;
int fd;
int len;
- int err;
+ int err = 0;
struct config {
char *file;
OPT_END()
};
- err = fd = parse_and_open(argc, argv, desc, opts);
+ fd = parse_and_open(argc, argv, desc, opts);
if (fd < 0) {
goto ret;
}
}
}
} while (more);
- free(buf);
}
+ free(buf);
return err;
}
if (err > 0)
nvme_show_status(err);
+ close(fd);
return err;
}