nvme-cli-2.11-1.fc42

List of Findings

Error: CPPCHECK_WARNING (CWE-404): [#def1]
nvme-cli-2.11-build/nvme-cli-2.11/fabrics.c:449: error[resourceLeak]: Resource leak: f
#  447|   	argv = calloc(MAX_DISC_ARGS, sizeof(char *));
#  448|   	if (!argv)
#  449|-> 		return -1;
#  450|   
#  451|   	argv[0] = "discover";

Error: GCC_ANALYZER_WARNING (CWE-401): [#def2]
nvme-cli-2.11-build/nvme-cli-2.11/nbft.c: scope_hint: In function ‘read_nbft_files’
nvme-cli-2.11-build/nvme-cli-2.11/nbft.c:55:24: warning[-Wanalyzer-malloc-leak]: leak of ‘entry’
nvme-cli-2.11-build/nvme-cli-2.11/nbft.c: scope_hint: In function ‘read_nbft_files’
#   53|   	count = scandir(path, &dent, nbft_filter, NULL);
#   54|   	if (count < 0)
#   55|-> 		return -errno;
#   56|   
#   57|   	for (i = 0; i < count; i++) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def3]
nvme-cli-2.11-build/nvme-cli-2.11/nbft.c:61:33: warning[-Wanalyzer-malloc-leak]: leak of ‘entry’
nvme-cli-2.11-build/nvme-cli-2.11/nbft.c: scope_hint: In function ‘read_nbft_files’
#   59|   		ret = nvme_nbft_read(&nbft, filename);
#   60|   		if (!ret) {
#   61|-> 			entry = calloc(1, sizeof(*entry));
#   62|   			entry->nbft = nbft;
#   63|   			list_add_tail(nbft_list, &entry->node);

Error: GCC_ANALYZER_WARNING (CWE-476): [#def4]
nvme-cli-2.11-build/nvme-cli-2.11/nbft.c:62:37: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘entry’
nvme-cli-2.11-build/nvme-cli-2.11/nbft.c: scope_hint: In function ‘read_nbft_files’
#   60|   		if (!ret) {
#   61|   			entry = calloc(1, sizeof(*entry));
#   62|-> 			entry->nbft = nbft;
#   63|   			list_add_tail(nbft_list, &entry->node);
#   64|   		}

Error: CPPCHECK_WARNING (CWE-404): [#def5]
nvme-cli-2.11-build/nvme-cli-2.11/nvme-rpmb.c:226: error[resourceLeak]: Resource leak: fp
#  224|   			temp_folder, msg ? msg : "");
#  225|   	}
#  226|-> }
#  227|   
#  228|   /* Various definitions used in RPMB related support */

Error: GCC_ANALYZER_WARNING (CWE-401): [#def6]
nvme-cli-2.11-build/nvme-cli-2.11/nvme-rpmb.c: scope_hint: In function ‘rpmb_nonce_init’
nvme-cli-2.11-build/nvme-cli-2.11/nvme-rpmb.c:323:19: warning[-Wanalyzer-malloc-leak]: leak of ‘rpmb_md5(&num, 4)’
#  321|   	int num = rand();
#  322|   	unsigned char *hash = rpmb_md5((unsigned char *)&num, sizeof(num));
#  323|-> 	if (hash) memcpy(req->nonce, hash, sizeof(req->nonce));
#  324|   }
#  325|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def7]
nvme-cli-2.11-build/nvme-cli-2.11/nvme-rpmb.c: scope_hint: In function ‘rpmb_cmd_option’
nvme-cli-2.11-build/nvme-cli-2.11/nvme-rpmb.c:967:33: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘msg_buf’ where non-null expected
<built-in>: note: argument 1 of ‘__builtin_memcpy’ must be non-null
#  965|   				msg_size = strlen(cfg.msg);
#  966|   				msg_buf = (unsigned char *)malloc(msg_size);
#  967|-> 				memcpy(msg_buf, cfg.msg, msg_size);
#  968|   			} else {
#  969|   				err = read_file(cfg.msgfile, &msg_buf, &msg_size);

Error: CPPCHECK_WARNING (CWE-457): [#def8]
nvme-cli-2.11-build/nvme-cli-2.11/nvme.c:4632: warning[uninitvar]: Uninitialized variable: result_def
# 4630|   	}
# 4631|   
# 4632|-> 	if (err || !cfg.changed || err_def || result != result_def ||
# 4633|   	    (buf && buf_def && !strcmp(buf, buf_def)))
# 4634|   		get_feature_id_print(cfg, err, result, buf);

Error: CPPCHECK_WARNING (CWE-457): [#def9]
nvme-cli-2.11-build/nvme-cli-2.11/nvme.c:5351: warning[uninitvar]: Uninitialized variable: err
# 5349|   	}
# 5350|   
# 5351|-> 	if (err)
# 5352|   		free(bar);
# 5353|   	else

Error: CPPCHECK_WARNING (CWE-404): [#def10]
nvme-cli-2.11-build/nvme-cli-2.11/nvme.c:9638: error[resourceLeak]: Resource leak: fd
# 9636|   	if (cnt != 1) {
# 9637|   		nvme_show_error("Must specify either --import, --export or --revoke");
# 9638|-> 		return -EINVAL;
# 9639|   	} else if (cfg.export) {
# 9640|   		err = nvme_scan_tls_keys(cfg.keyring, __scan_tls_key, fd);

Error: CPPCHECK_WARNING (CWE-404): [#def11]
nvme-cli-2.11-build/nvme-cli-2.11/nvme.c:9666: error[resourceLeak]: Resource leak: fd
# 9664|   			nvme_show_error("Failed to revoke key '%s'",
# 9665|   					nvme_strerror(errno));
# 9666|-> 			return err;
# 9667|   		}
# 9668|   

Error: GCC_ANALYZER_WARNING (CWE-126): [#def12]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/huawei/huawei-nvme.c: scope_hint: In function ‘huawei_get_nvme_info’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/huawei/huawei-nvme.c:96:9: warning[-Wanalyzer-out-of-bounds]: stack-based buffer over-read
nvme-cli-2.11-build/nvme-cli-2.11/plugins/huawei/huawei-nvme.c:96:9: note: read of 760 bytes from after the end of ‘path’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/huawei/huawei-nvme.c:96:9: note: valid subscripts for ‘path’ are ‘[0]’ to ‘[263]’
#   94|   		return err;
#   95|   
#   96|-> 	strncpy(item->node, node, sizeof(item->node));
#   97|   	item->node[sizeof(item->node) - 1] = '\0';
#   98|   	item->block = S_ISBLK(nvme_stat_info.st_mode);

Error: CPPCHECK_WARNING (CWE-457): [#def13]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/innogrit/innogrit-nvme.c:72: error[uninitvar]: Uninitialized variable: pdrvinfo->signature
#   70|   	for (ilogid = 0xe1; ilogid < 0xe2; ilogid++) {
#   71|   		getlogpage(dev, ilogid, 0, data, 4096, NULL);
#   72|-> 		if (pdrvinfo->signature == 0x5A)
#   73|   			return 1;
#   74|   	}

Error: CPPCHECK_WARNING (CWE-457): [#def14]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/innogrit/innogrit-nvme.c:114: error[uninitvar]: Uninitialized variable: pevlog->signature
#  112|   		}
#  113|   
#  114|-> 		if (pevlog->signature == EVLOG_SIG) {
#  115|   			errcnt = 0;
#  116|   		} else {

Error: GCC_ANALYZER_WARNING (CWE-688): [#def15]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/innogrit/innogrit-nvme.c: scope_hint: In function ‘getvsc_eventlog’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/innogrit/innogrit-nvme.c:135:25: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘fp’ where non-null expected
nvme-cli-2.11-build/nvme-cli-2.11/plugins/innogrit/innogrit-nvme.c:2: included_from: Included from here.
/usr/include/stdio.h:735:15: note: argument 4 of ‘fwrite’ must be non-null
#  133|   			printf("get eventlog by vsc command\n");
#  134|   			start_flag = 1;
#  135|-> 			fwrite(data, 1, 4096, fp);
#  136|   			rxlen += 4096;
#  137|   		}

Error: GCC_ANALYZER_WARNING (CWE-688): [#def16]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/innogrit/innogrit-nvme.c: scope_hint: In function ‘getlogpage_eventlog’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/innogrit/innogrit-nvme.c:169:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘fp’ where non-null expected
/usr/include/stdio.h:735:15: note: argument 4 of ‘fwrite’ must be non-null
#  167|   			return IG_ERROR;
#  168|   		}
#  169|-> 		fwrite(data, 1, 4096, fp);
#  170|   	}
#  171|   	printf("\n");

Error: GCC_ANALYZER_WARNING (CWE-775): [#def17]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/innogrit/innogrit-nvme.c: scope_hint: In function ‘innogrit_vsc_getcdump’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/innogrit/innogrit-nvme.c:241:24: warning[-Wanalyzer-file-leak]: leak of FILE ‘fp’
#  239|   	ret = parse_and_open(&dev, argc, argv, desc, opts);
#  240|   	if (ret)
#  241|-> 		return ret;
#  242|   
#  243|   	ivsctype = getvsctype(dev);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def18]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/innogrit/innogrit-nvme.c:241:24: warning[-Wanalyzer-malloc-leak]: leak of ‘fp’
#  239|   	ret = parse_and_open(&dev, argc, argv, desc, opts);
#  240|   	if (ret)
#  241|-> 		return ret;
#  242|   
#  243|   	ivsctype = getvsctype(dev);

Error: CPPCHECK_WARNING (CWE-404): [#def19]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/innogrit/innogrit-nvme.c:305: error[resourceLeak]: Resource leak: fp
#  303|   	if (itotal == 0) {
#  304|   		printf("no cdump data\n");
#  305|-> 		return 0;
#  306|   	}
#  307|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def20]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/innogrit/innogrit-nvme.c:311:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘fp’ where non-null expected
/usr/include/stdio.h:735:15: note: argument 4 of ‘fwrite’ must be non-null
#  309|   		memset(data, 0, 4096);
#  310|   		strcpy((char *)data, "cdumpstart");
#  311|-> 		fwrite(data, 1, strlen((char *)data), fp);
#  312|   		for (icur = 0; icur < itotal; icur += 4096) {
#  313|   			memset(data, 0, 4096);

Error: CPPCHECK_WARNING (CWE-456): [#def21]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/intel/intel-nvme.c:1348: error[uninitdata]: Memory is allocated but not initialized: intel
# 1346|   	struct intel_vu_log *intel = malloc(sizeof(struct intel_vu_log));
# 1347|   	struct intel_vu_nlog *intel_nlog = (struct intel_vu_nlog *)buf;
# 1348|-> 	struct intel_assert_dump *ad = (struct intel_assert_dump *) intel->reserved;
# 1349|   	struct intel_event_header *ehdr = (struct intel_event_header *)intel->reserved;
# 1350|   	struct nvme_dev *dev;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def22]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/intel/intel-nvme.c: scope_hint: In function ‘get_internal_log’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/intel/intel-nvme.c:1420:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘intel’ where non-null expected
<built-in>: note: argument 1 of ‘__builtin_memcpy’ must be non-null
# 1418|   	if (err)
# 1419|   		goto out;
# 1420|-> 	memcpy(intel, buf, sizeof(*intel));
# 1421|   
# 1422|   	/* for 1.1 Fultondales will use old nlog, but current assert/event */

Error: GCC_ANALYZER_WARNING (CWE-404): [#def23]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c: scope_hint: In function ‘parse_params’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:393:32: warning[-Wanalyzer-va-list-leak]: missing call to ‘va_end’
nvme-cli-2.11-build/nvme-cli-2.11/ccan/ccan/str/str.h:8: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/ccan/ccan/list/list.h:7: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/nvme-print.h:8: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:15: included_from: Included from here.
#  391|   			printf("No enough parameters. abort...\n");
#  392|   			va_end(argp);
#  393|-> 			return 1;
#  394|   		}
#  395|   

Error: GCC_ANALYZER_WARNING (CWE-775): [#def24]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c: scope_hint: In function ‘mb_high_latency_log_print’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:655:16: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen("log_c3.csv", "w+")’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:19: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:651:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:651:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:651:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:652:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:652:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:653:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:653:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:654:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:654:9: note: in expansion of macro ‘fPRINT_PARAM1’
#  653|   	fPRINT_PARAM1("Timestamp                        Type    QID    CID    NSID     StartLBA      NumLBA   Latency\n");
#  654|   	fPRINT_PARAM1("---------------------------------------------------------------------------------------------\n");
#  655|-> 	return 0;
#  656|   }
#  657|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def25]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:655:16: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen("log_c3.csv", "w+")’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:651:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:651:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:651:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:652:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:652:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:653:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:653:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:654:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:654:9: note: in expansion of macro ‘fPRINT_PARAM1’
#  653|   	fPRINT_PARAM1("Timestamp                        Type    QID    CID    NSID     StartLBA      NumLBA   Latency\n");
#  654|   	fPRINT_PARAM1("---------------------------------------------------------------------------------------------\n");
#  655|-> 	return 0;
#  656|   }
#  657|   

Error: GCC_ANALYZER_WARNING (CWE-775): [#def26]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:753:15: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen("log_c3.csv", "w+")’
#  751|   		return err;
#  752|   
#  753|-> 	fdi = fopen(FID_C3_LOG_FILENAME, "w+");
#  754|   
#  755|   	glp_high_latency_show_bar(fdi, DO_PRINT_FLAG);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def27]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:753:15: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen("log_c3.csv", "w+")’
#  751|   		return err;
#  752|   
#  753|-> 	fdi = fopen(FID_C3_LOG_FILENAME, "w+");
#  754|   
#  755|   	glp_high_latency_show_bar(fdi, DO_PRINT_FLAG);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def28]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:756:15: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen("log_c3.csv", "w+")’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:651:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:651:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:651:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:652:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:652:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:653:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:653:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:654:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:654:9: note: in expansion of macro ‘fPRINT_PARAM1’
#  754|   
#  755|   	glp_high_latency_show_bar(fdi, DO_PRINT_FLAG);
#  756|-> 	err = nvme_get_log_simple(dev_fd(dev), GLP_ID_VU_GET_HIGH_LATENCY_LOG, sizeof(buf), &buf);
#  757|   
#  758|   	while (1) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def29]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:756:15: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen("log_c3.csv", "w+")’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:651:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:651:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:651:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:652:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:652:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:653:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:653:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:654:9: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:654:9: note: in expansion of macro ‘fPRINT_PARAM1’
#  754|   
#  755|   	glp_high_latency_show_bar(fdi, DO_PRINT_FLAG);
#  756|-> 	err = nvme_get_log_simple(dev_fd(dev), GLP_ID_VU_GET_HIGH_LATENCY_LOG, sizeof(buf), &buf);
#  757|   
#  758|   	while (1) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def30]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c: scope_hint: In function ‘mb_selective_download’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:844:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(cfg.fw, 0)’
#  842|   	}
#  843|   
#  844|-> 	fw_fd = open(cfg.fw, O_RDONLY);
#  845|   	if (fw_fd < 0) {
#  846|   		fprintf(stderr, "no firmware file provided\n");

Error: GCC_ANALYZER_WARNING (CWE-688): [#def31]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c: scope_hint: In function ‘ioLatencyHistogramOutput’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:929:9: warning[-Wanalyzer-null-argument]: use of NULL ‘fd’ where non-null expected
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:945:9: note: in expansion of macro ‘fPRINT_PARAM2’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:945:9: note: in expansion of macro ‘fPRINT_PARAM2’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:945:9: note: in expansion of macro ‘fPRINT_PARAM2’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:946:9: note: in expansion of macro ‘fPRINT_PARAM2’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:946:9: note: in expansion of macro ‘fPRINT_PARAM2’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:950:17: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:950:17: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:950:17: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:951:17: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:951:17: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:952:17: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:952:17: note: in expansion of macro ‘fPRINT_PARAM1’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/memblaze/memblaze-nvme.c:4: included_from: Included from here.
/usr/include/stdio.h:735:15: note: argument 4 of ‘fwrite’ must be non-null
#  927|   	len = snprintf(string, sizeof(string), "%-11d %-11s %-11s %-11u\n",
#  928|   		       index, subString0, subString1, pHistogram[index]);
#  929|-> 	fwrite(string, 1, len, fd);
#  930|   	if (print)
#  931|   		printf("%s", string);

Error: CPPCHECK_WARNING (CWE-758): [#def32]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/micron/micron-nvme.c:1068: error[shiftTooManyBitsSigned]: Shifting signed 32-bit value by 31 bits is undefined behaviour
# 1066|   	/* For M51CX models, PCIe errors are cleared using 0xC3 feature */
# 1067|   	if (model == M51CX) {
# 1068|-> 		err = nvme_set_features_simple(dev_fd(dev), fid, 0, (1 << 31), false,
# 1069|   					       &result);
# 1070|   		if (!err)

Error: GCC_ANALYZER_WARNING (CWE-457): [#def33]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/micron/micron-nvme.c: scope_hint: In function ‘GetTimestampInfo’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/micron/micron-nvme.c:1644:27: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘*strOSDirName’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/micron/micron-nvme.c:12: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/plugins/micron/micron-nvme.c:11: included_from: Included from here.
/usr/include/string.h:187:14: note: argument 1 of ‘strdup’ must be a pointer to a null-terminated string
# 1642|   	num += sprintf((char *)(outstr + num), "\nPackage Version: 1.4");
# 1643|   	if (num) {
# 1644|-> 		strPDir = strdup(strOSDirName);
# 1645|   		strDest = dirname(strPDir);
# 1646|   		WriteData(outstr, num, strDest, "timestamp_info.txt", "timestamp");

Error: CPPCHECK_WARNING (CWE-401): [#def34]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/micron/micron-nvme.c:1826: error[memleakOnRealloc]: Common realloc mistake: 'buffer' nulled but not freed upon failure
# 1824|   	offset = bs;
# 1825|   	err = 0;
# 1826|-> 	buffer = (unsigned char *)realloc(buffer, (size_t)(*logSize));
# 1827|   	if (buffer) {
# 1828|   		while (!err && offset != *logSize) {

Error: CPPCHECK_WARNING (CWE-758): [#def35]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/micron/micron-nvme.c:2659: error[shiftTooManyBitsSigned]: Shifting signed 32-bit value by 31 bits is undefined behaviour
# 2657|   	}
# 2658|   
# 2659|-> 	err = nvme_set_features_simple(dev_fd(dev), fid, 1 << 31, 0, 0, &result);
# 2660|   	if (!err)
# 2661|   		err = (int)result;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def36]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/netapp/netapp-nvme.c: scope_hint: In function ‘netapp_ontapdevices_print_regular’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/netapp/netapp-nvme.c:449:25: warning[-Wanalyzer-null-argument]: use of NULL ‘formatstr’ where non-null expected
nvme-cli-2.11-build/nvme-cli-2.11/plugins/netapp/netapp-nvme.c:17: included_from: Included from here.
/usr/include/stdio.h:363:12: note: argument 1 of ‘printf’ must be non-null
#  447|   					devices[i].log_data);
#  448|   
#  449|-> 			printf(formatstr, devices[i].dev, vsname, nspath,
#  450|   					devices[i].nsid, uuid_str, size);
#  451|   			return;

Error: CPPCHECK_WARNING (CWE-758): [#def37]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-clear-features.c:19: error[shiftTooManyBitsSigned]: Shifting signed 32-bit value by 31 bits is undefined behaviour
#   17|   {
#   18|   	__u32 result = 0;
#   19|-> 	__u32 clear = 1 << 31;
#   20|   	struct nvme_dev *dev;
#   21|   	__u8 uuid_index = 0;

Error: GCC_ANALYZER_WARNING: [#def38]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-hardware-component-log.c: scope_hint: In function ‘get_hwcomp_log_data’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-hardware-component-log.c:197:21: warning[-Wanalyzer-imprecise-fp-arithmetic]: use of floating-point arithmetic here might yield unexpected results
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-hardware-component-log.c:10: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-hardware-component-log.c:191:9: note: in expansion of macro ‘print_info’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-hardware-component-log.c:197:21: note: only use operands of an integer type inside the size argument
#  195|   
#  196|   	args.len = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32);
#  197|-> 	log->desc = calloc(1, args.len);
#  198|   	if (!log->desc) {
#  199|   		fprintf(stderr, "error: ocp: calloc: %s\n", strerror(errno));

Error: GCC_ANALYZER_WARNING (CWE-688): [#def39]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-nvme.c: scope_hint: In function ‘extract_dump_get_log’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-nvme.c:783:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘data’ where non-null expected
nvme-cli-2.11-build/nvme-cli-2.11/nvme.h:25: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-nvme.c: scope_hint: In function ‘extract_dump_get_log’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-nvme.c:26: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-nvme.c:1437:17: note: in expansion of macro ‘nvme_show_result’
<built-in>: note: argument 1 of ‘__builtin_memset’ must be non-null
#  781|   
#  782|   	for (i = 0; i < total_loop_cnt; i++) {
#  783|-> 		memset(data, 0, transfersize);
#  784|   
#  785|   		struct nvme_get_log_args args = {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def40]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-nvme.c: scope_hint: In function ‘error_injection_set’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-nvme.c:2768:23: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(*cfg.file, 0)’
# 2766|   
# 2767|   	if (cfg->file && strlen(cfg->file)) {
# 2768|-> 		ffd = open(cfg->file, O_RDONLY);
# 2769|   		if (ffd < 0) {
# 2770|   			nvme_show_error("Failed to open file %s: %s", cfg->file, strerror(errno));

Error: CPPCHECK_WARNING (CWE-476): [#def41]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-telemetry-decode.c:441: warning[nullPointer]: Possible null pointer dereference: pdata
#  439|   
#  440|   	for (size_t i = 0; i < data_size; ++i) {
#  441|-> 		sprintf(temp_buffer, "%02X", pdata[i]);
#  442|   		strcat(description_str, temp_buffer);
#  443|   	}

Error: CPPCHECK_WARNING (CWE-476): [#def42]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-telemetry-decode.c:528: error[nullPointer]: Null pointer dereference
#  526|   			// for 2.5 Spec defined strings (id < 0x1D).
#  527|   			if ((description == NULL) && (identifier < 0x1D))
#  528|-> 				memcpy(description,
#  529|   				       statistic_identifiers_map[identifier].description,
#  530|   				       peach_statistic_entry->ascii_id_length + 1);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def43]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-telemetry-decode.c: scope_hint: In function ‘parse_event_fifo’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-telemetry-decode.c:954:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘description’ where non-null expected
nvme-cli-2.11-build/nvme-cli-2.11/nvme.h:30: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-telemetry-decode.c:8: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-telemetry-decode.c:1329:62: note: in expansion of macro ‘json_create_array’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-telemetry-decode.c:1148:39: note: in expansion of macro ‘json_create_object’
<built-in>: note: argument 1 of ‘__builtin_memset’ must be non-null
#  952|   	char *description = (char *)malloc((40 + 1) * sizeof(char));
#  953|   
#  954|-> 	memset(description, 0, sizeof(40));
#  955|   
#  956|   	status =

Error: GCC_ANALYZER_WARNING (CWE-775): [#def44]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c: scope_hint: In function ‘nvme_dump_evtlog’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1279:17: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(file, "rb")’
# 1277|   	fd = fopen(output, "w+");
# 1278|   	if (!fd) {
# 1279|-> 		fprintf(stderr, "Failed to open %s file to write\n", output);
# 1280|   		err = ENOENT;
# 1281|   		goto ret;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def45]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1279:17: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(file, "rb")’
# 1277|   	fd = fopen(output, "w+");
# 1278|   	if (!fd) {
# 1279|-> 		fprintf(stderr, "Failed to open %s file to write\n", output);
# 1280|   		err = ENOENT;
# 1281|   		goto ret;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def46]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1285:72: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(file, "rb")’
# 1283|   
# 1284|   	while (length > 0) {
# 1285|-> 		info = (struct sfx_nvme_evtlog_info *)(pevent_log_info + offset);
# 1286|   
# 1287|   		if ((info->magic1 == 0x474F4C545645) &&

Error: GCC_ANALYZER_WARNING (CWE-401): [#def47]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1285:72: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(file, "rb")’
# 1283|   
# 1284|   	while (length > 0) {
# 1285|-> 		info = (struct sfx_nvme_evtlog_info *)(pevent_log_info + offset);
# 1286|   
# 1287|   		if ((info->magic1 == 0x474F4C545645) &&

Error: GCC_ANALYZER_WARNING (CWE-775): [#def48]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1420:14: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(file, "wb+")’
# 1418|   	}
# 1419|   
# 1420|-> 	fd = fopen(file, "wb+");
# 1421|   	if (!fd) {
# 1422|   		fprintf(stderr, "Failed to open %s file to write\n", file);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def49]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1420:14: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(file, "wb+")’
# 1418|   	}
# 1419|   
# 1420|-> 	fd = fopen(file, "wb+");
# 1421|   	if (!fd) {
# 1422|   		fprintf(stderr, "Failed to open %s file to write\n", file);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def50]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1431:26: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(file, "wb+")’
# 1429|   	length = log_len;
# 1430|   	while (length > 0) {
# 1431|-> 		args.lpo = offset;
# 1432|   		if (length > single_len) {
# 1433|   			args.len = single_len;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def51]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1431:26: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(file, "wb+")’
# 1429|   	length = log_len;
# 1430|   	while (length > 0) {
# 1431|-> 		args.lpo = offset;
# 1432|   		if (length > single_len) {
# 1433|   			args.len = single_len;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def52]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1454:9: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(file, "wb+")’
# 1452|   	}
# 1453|   
# 1454|-> 	printf("\nDump-evtlog: Success\n");
# 1455|   
# 1456|   	if (parse) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def53]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1454:9: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(file, "wb+")’
# 1452|   	}
# 1453|   
# 1454|-> 	printf("\nDump-evtlog: Success\n");
# 1455|   
# 1456|   	if (parse) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def54]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1457:17: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(file, "wb+")’
# 1455|   
# 1456|   	if (parse) {
# 1457|-> 		nvme_free_huge(&mh);
# 1458|   		pevent_log_info = nvme_alloc_huge(log_len, &mh);
# 1459|   		if (!pevent_log_info) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def55]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1457:17: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(file, "wb+")’
# 1455|   
# 1456|   	if (parse) {
# 1457|-> 		nvme_free_huge(&mh);
# 1458|   		pevent_log_info = nvme_alloc_huge(log_len, &mh);
# 1459|   		if (!pevent_log_info) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def56]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1458:35: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(file, "wb+")’
# 1456|   	if (parse) {
# 1457|   		nvme_free_huge(&mh);
# 1458|-> 		pevent_log_info = nvme_alloc_huge(log_len, &mh);
# 1459|   		if (!pevent_log_info) {
# 1460|   			fprintf(stderr, "Failed to alloc enough memory 0x%x to parse evtlog\n", log_len);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def57]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1458:35: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(file, "wb+")’
# 1456|   	if (parse) {
# 1457|   		nvme_free_huge(&mh);
# 1458|-> 		pevent_log_info = nvme_alloc_huge(log_len, &mh);
# 1459|   		if (!pevent_log_info) {
# 1460|   			fprintf(stderr, "Failed to alloc enough memory 0x%x to parse evtlog\n", log_len);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def58]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1466:22: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(file, "rb")’
# 1464|   
# 1465|   		fclose(fd);
# 1466|-> 		fd = fopen(file, "rb");
# 1467|   		if (!fd) {
# 1468|   			fprintf(stderr, "Failed to open %s file to read\n", file);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def59]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1466:22: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(file, "rb")’
# 1464|   
# 1465|   		fclose(fd);
# 1466|-> 		fd = fopen(file, "rb");
# 1467|   		if (!fd) {
# 1468|   			fprintf(stderr, "Failed to open %s file to read\n", file);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def60]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1472:21: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(file, "rb")’
# 1470|   			goto free_pevent;
# 1471|   		}
# 1472|-> 		if (fread(pevent_log_info, 1, log_len, fd) != log_len) {
# 1473|   			fprintf(stderr, "Failed to read evtlog to buffer\n");
# 1474|   			goto close_fd;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def61]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1472:21: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(file, "rb")’
# 1470|   			goto free_pevent;
# 1471|   		}
# 1472|-> 		if (fread(pevent_log_info, 1, log_len, fd) != log_len) {
# 1473|   			fprintf(stderr, "Failed to read evtlog to buffer\n");
# 1474|   			goto close_fd;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def62]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1473:25: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(file, "rb")’
# 1471|   		}
# 1472|   		if (fread(pevent_log_info, 1, log_len, fd) != log_len) {
# 1473|-> 			fprintf(stderr, "Failed to read evtlog to buffer\n");
# 1474|   			goto close_fd;
# 1475|   		}

Error: GCC_ANALYZER_WARNING (CWE-401): [#def63]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/scaleflux/sfx-nvme.c:1473:25: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(file, "rb")’
# 1471|   		}
# 1472|   		if (fread(pevent_log_info, 1, log_len, fd) != log_len) {
# 1473|-> 			fprintf(stderr, "Failed to read evtlog to buffer\n");
# 1474|   			goto close_fd;
# 1475|   		}

Error: GCC_ANALYZER_WARNING (CWE-688): [#def64]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/sed/sedopal_cmd.c: scope_hint: In function ‘sedopal_set_key’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/sed/sedopal_cmd.c:145:29: warning[-Wanalyzer-null-argument]: use of NULL where non-null expected
nvme-cli-2.11-build/nvme-cli-2.11/plugins/sed/sedopal_cmd.c:7: included_from: Included from here.
/usr/include/string.h:159:12: note: argument 2 of ‘strncmp’ must be non-null
#  143|   		if (sedopal_ask_new_key) {
#  144|   			pass = sedopal_get_password(SEDOPAL_REENTER_PW_PROMPT);
#  145|-> 			if (strncmp((char *)key->key, pass, key->key_len)) {
#  146|   				fprintf(stderr,
#  147|   					"Error: passwords don't match\n");

Error: GCC_ANALYZER_WARNING (CWE-775): [#def65]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/shannon/shannon-nvme.c: scope_hint: In function ‘set_additional_feature’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/shannon/shannon-nvme.c:309:24: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘ffd’
#  307|   	err = parse_and_open(&dev, argc, argv, desc, opts);
#  308|   	if (err)
#  309|-> 		return err;
#  310|   
#  311|   	if (!cfg.feature_id) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def66]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/shannon/shannon-nvme.c:329:28: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(cfg.file, 0)’
#  327|   		if (strlen(cfg.file)) {
#  328|   			ffd = open(cfg.file, O_RDONLY);
#  329|-> 			if (ffd <= 0) {
#  330|   				fprintf(stderr, "no firmware file provided\n");
#  331|   				err = EINVAL;

Error: GCC_ANALYZER_WARNING: [#def67]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/shannon/shannon-nvme.c:335:23: warning[-Wanalyzer-fd-use-without-check]: ‘read’ on possibly invalid file descriptor ‘ffd’
#  333|   			}
#  334|   		}
#  335|-> 		err = read(ffd, (void *)buf, cfg.data_len);
#  336|   		if (err < 0) {
#  337|   			fprintf(stderr, "failed to read data buffer from input file\n");

Error: CPPCHECK_WARNING (CWE-457): [#def68]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-internal-logs.c:400: warning[uninitvar]: Uninitialized variable: nlog_header->totalnlogs
#  398|   				return err;
#  399|   			}
#  400|-> 			count = nlog_header->totalnlogs;
#  401|   			core_num = core < 0 ? nlog_header->corecount : 0;
#  402|   			if (!header_size) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def69]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-internal-logs.c: scope_hint: In function ‘solidigm_get_internal_log’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-internal-logs.c:872:15: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(cfg.out_dir)’
#  870|   	}
#  871|   
#  872|-> 	dir = opendir(cfg.out_dir);
#  873|   	if (dir)
#  874|   		closedir(dir);

Error: GCC_ANALYZER_WARNING (CWE-457): [#def70]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry.c: scope_hint: In function ‘solidigm_get_telemetry_log’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry.c:150:23: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘dev’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry.c:9: included_from: Included from here.
#  148|   		__u8 mdts = 0;
#  149|   
#  150|-> 		err = nvme_get_telemetry_max(dev_fd(dev), NULL, &max_data_tx);
#  151|   		if (err < 0) {
#  152|   			SOLIDIGM_LOG_WARNING("identify_ctrl: %s",

Error: GCC_ANALYZER_WARNING (CWE-457): [#def71]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry.c:187:26: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘dev’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry.c:20: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry.c:114:17: note: in expansion of macro ‘SOLIDIGM_LOG_WARNING’
#  185|   	if (!cfg.is_input_file) {
#  186|   		/* Redundant close() to make static code analysis happy */
#  187|-> 		close(dev->direct.fd);
#  188|   		dev_close(dev);
#  189|   	}

Error: GCC_ANALYZER_WARNING (CWE-457): [#def72]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry/data-area.c: scope_hint: In function ‘telemetry_log_structure_parse’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry/data-area.c:173:26: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘array_size_dimension[0]’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry/telemetry-log.h:12: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry/header.h:8: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry/data-area.c:9: included_from: Included from here.
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry/data-area.c:465:17: note: in expansion of macro ‘json_object_add_value_array’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry/data-area.c:395:28: note: in expansion of macro ‘json_create_object’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry/data-area.c:422:53: note: in expansion of macro ‘json_create_object’
#  171|   	}
#  172|   	if (array_rank > 1) {
#  173|-> 		uint32_t linear_pos_per_index = array_size_dimension[0];
#  174|   		uint32_t prev_index_offset_bit = 0;
#  175|   		struct json_object *dimension_output;

Error: CPPCHECK_WARNING (CWE-457): [#def73]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-telemetry/nlog.c:124: warning[uninitvar]: Uninitialized variable: str_mismatches
#  122|   				       offset_tail_mismatches[best_offset][i]);
#  123|   
#  124|-> 		SOLIDIGM_LOG_WARNING("%s:%d with %d header mismatches ( %s). Configuration file may be missing format headers.",
#  125|   				      name, media_bank, smaller_tail_count, str_mismatches);
#  126|   	}

Error: CPPCHECK_WARNING (CWE-457): [#def74]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/solidigm/solidigm-workload-tracker.c:477: warning[uninitvar]: Uninitialized variable: dest
#  475|   static void join_fields(char *dest, struct field *fields)
#  476|   {
#  477|-> 	strcat(dest, fields[0].name);
#  478|   	for (int i = 1; i < MAX_FIELDS; i++) {
#  479|   		char *name = fields[i].name;

Error: CPPCHECK_WARNING (CWE-758): [#def75]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/wdc/wdc-nvme.c:8553: error[shiftTooManyBitsSigned]: Shifting signed 32-bit value by 31 bits is undefined behaviour
# 8551|   	int ret;
# 8552|   	__u32 result;
# 8553|-> 	__u32 value = 1 << 31; /* Bit 31 - clear PCIe correctable count */
# 8554|   
# 8555|   	ret = nvme_set_features_simple(fd, WDC_NVME_CLEAR_PCIE_CORR_FEATURE_ID, 0, value,

Error: CPPCHECK_WARNING (CWE-758): [#def76]
nvme-cli-2.11-build/nvme-cli-2.11/plugins/wdc/wdc-nvme.c:9025: error[shiftTooManyBitsSigned]: Shifting signed 32-bit value by 31 bits is undefined behaviour
# 9023|   	int ret = -1;
# 9024|   	__u32 result;
# 9025|-> 	__u32 value = 1 << 31; /* Bit 31 - Clear Firmware Update History Log */
# 9026|   
# 9027|   	ret = nvme_set_features_simple(fd, WDC_NVME_CLEAR_FW_ACT_HIST_VU_FID, 0, value,

Error: GCC_ANALYZER_WARNING (CWE-775): [#def77]
nvme-cli-2.11-build/nvme-cli-2.11/util/cleanup.h:34:12: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘ffd’
nvme-cli-2.11-build/nvme-cli-2.11/plugins/ocp/ocp-nvme.c: scope_hint: In function ‘error_injection_set’
#   32|   static inline void cleanup_fd(int *fd)
#   33|   {
#   34|-> 	if (*fd > STDERR_FILENO)
#   35|   		close(*fd);
#   36|   }

Error: GCC_ANALYZER_WARNING (CWE-688): [#def78]
nvme-cli-2.11-build/nvme-cli-2.11/util/mem.c: scope_hint: In function ‘nvme_realloc’
nvme-cli-2.11-build/nvme-cli-2.11/util/mem.c:34:17: warning[-Wanalyzer-null-argument]: use of NULL where non-null expected
<built-in>: note: argument 1 of ‘__builtin_memcpy’ must be non-null
#   32|   
#   33|   	if (p) {
#   34|-> 		memcpy(result, p, min(old_len, len));
#   35|   		free(p);
#   36|   	}

Error: GCC_ANALYZER_WARNING (CWE-476): [#def79]
nvme-cli-2.11-build/nvme-cli-2.11/util/utils.c: scope_hint: In function ‘hex_to_ascii’
nvme-cli-2.11-build/nvme-cli-2.11/util/utils.c:56:41: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘text’
#   54|   				int dec = hex_to_int(hex[0]);
#   55|   
#   56|-> 				text[0] = dec;
#   57|   			}
#   58|   		}

Error: CPPCHECK_WARNING (CWE-401): [#def80]
nvme-cli-2.11-build/nvme-cli-2.11/util/utils.c:191: error[leakNoVarFunctionCall]: Allocation with hex_to_ascii, sprintf doesn't release it.
#  189|   
#  190|   		sprintf(buffer, "%"PRIx64, __builtin_bswap64(lval_lo));
#  191|-> 		sprintf(datastr, "%s", hex_to_ascii(buffer));
#  192|   	} else if (strstr(sfield, "Timestamp")) {
#  193|   		char ts_buf[128];

Error: GCC_ANALYZER_WARNING (CWE-401): [#def81]
nvme-cli-2.11-build/nvme-cli-2.11/util/utils.c: scope_hint: In function ‘process_field_size_8.part.0’
nvme-cli-2.11-build/nvme-cli-2.11/util/utils.c:204:1: warning[-Wanalyzer-malloc-leak]: leak of ‘hex_to_ascii(&buffer)’
#  202|   		sprintf(datastr, "0x%"PRIx64"", le64_to_cpu(lval_lo));
#  203|   	}
#  204|-> }
#  205|   
#  206|   void process_field_size_7(int offset, char *sfield, __u8 *buf, char *datastr)

Scan Properties

analyzer-version-clippy1.82.0
analyzer-version-cppcheck2.16.0
analyzer-version-gcc14.2.1
analyzer-version-gcc-analyzer15.0.0
analyzer-version-shellcheck0.10.0
analyzer-version-unicontrol0.0.2
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-7.us-west-2.compute.internal
mock-configfedora-rawhide-gcc-latest-x86_64
project-namenvme-cli-2.11-1.fc42
store-results-to/tmp/tmpqeu9h3i3/nvme-cli-2.11-1.fc42.tar.xz
time-created2024-11-13 02:04:35
time-finished2024-11-13 02:06:55
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-gcc-latest-x86_64' '-t' 'clippy,cppcheck,gcc,unicontrol,shellcheck' '-o' '/tmp/tmpqeu9h3i3/nvme-cli-2.11-1.fc42.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install=gcc-latest' '--gcc-analyzer-bin=/opt/gcc-latest/bin/gcc' '/tmp/tmpqeu9h3i3/nvme-cli-2.11-1.fc42.src.rpm'
tool-versioncsmock-3.7.1.20241107.094801.gb3f0f26.pr_192-1.el9