Fixed findings

List of Findings

Error: CPPCHECK_WARNING (CWE-457): [#def1]
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c:4634: warning[uninitvar]: Uninitialized variable: result_def
# 4632|   		cfg.sel = 8;
# 4633|   
# 4634|-> 	if (err || !changed || err_def || result != result_def ||
# 4635|   	    (buf && buf_def && !strcmp(buf, buf_def)))
# 4636|   		get_feature_id_print(cfg, err, result, buf);

Error: GCC_ANALYZER_WARNING (CWE-476): [#def2]
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c: scope_hint: In function ‘mmap_registers’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c:5353:9: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘dev’
# 5351|   		prot |= PROT_WRITE;
# 5352|   
# 5353|-> 	sprintf(path, "/sys/class/nvme/%s/device/resource0", dev->name);
# 5354|   	fd = open(path, writable ? O_RDWR : O_RDONLY);
# 5355|   	if (fd < 0) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def3]
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c: scope_hint: In function ‘set_feature’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c:6425:39: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(cfg.file, 0)’
# 6423|   		} else {
# 6424|   			if (strlen(cfg.file))
# 6425|-> 				ffd = open(cfg.file, O_RDONLY);
# 6426|   
# 6427|   			if (ffd < 0) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def4]
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c: scope_hint: In function ‘sec_send’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c:6539:26: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(cfg.file, 0)’
# 6537|   		sec_size = cfg.tl;
# 6538|   	} else {
# 6539|-> 		sec_fd = open(cfg.file, O_RDONLY);
# 6540|   		if (sec_fd < 0) {
# 6541|   			nvme_show_error("Failed to open %s: %s", cfg.file, strerror(errno));

Error: GCC_ANALYZER_WARNING (CWE-775): [#def5]
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c: scope_hint: In function ‘dir_send’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c:6685:31: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(cfg.file, 0)’
# 6683|   	if (buf) {
# 6684|   		if (strlen(cfg.file)) {
# 6685|-> 			ffd = open(cfg.file, O_RDONLY);
# 6686|   			if (ffd <= 0) {
# 6687|   				nvme_show_error("Failed to open file %s: %s",

Error: GCC_ANALYZER_WARNING: [#def6]
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c:6692:23: warning[-Wanalyzer-fd-use-without-check]: ‘read’ on possibly invalid file descriptor ‘ffd’
# 6690|   			}
# 6691|   		}
# 6692|-> 		err = read(ffd, (void *)buf, cfg.data_len);
# 6693|   		if (err < 0) {
# 6694|   			nvme_show_error("failed to read data buffer from input file %s",

Error: GCC_ANALYZER_WARNING: [#def7]
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c: scope_hint: In function ‘passthru’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c:8797:29: warning[-Wanalyzer-fd-use-without-check]: ‘read’ on possibly invalid file descriptor ‘mfd’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c:43: included_from: Included from here.
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c: scope_hint: In function ‘passthru’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c: scope_hint: In function ‘passthru’
# 8795|   
# 8796|   		if (cfg.write) {
# 8797|-> 			if (read(mfd, mdata, cfg.metadata_len) < 0) {
# 8798|   				err = -errno;
# 8799|   				nvme_show_perror("failed to read metadata write buffer");

Error: GCC_ANALYZER_WARNING (CWE-476): [#def8]
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.h:97:16: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘dev’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c: scope_hint: In function ‘ns_rescan’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c:31: included_from: Included from here.
#   95|   static inline int __dev_fd(struct nvme_dev *dev, const char *func, int line)
#   96|   {
#   97|-> 	if (dev->type != NVME_DEV_DIRECT) {
#   98|   		fprintf(stderr,
#   99|   			"warning: %s:%d not a direct transport!\n",

Error: CPPCHECK_WARNING (CWE-457): [#def9]
nvme-cli-2.10.2-build/nvme-cli-2.10.2/plugins/innogrit/innogrit-nvme.c:119: warning[uninitvar]: Uninitialized variables: peventlogadd.ms, peventlogadd.iindex
#  117|   	}
#  118|   
#  119|-> 	qsort(peventlogadd, icount, sizeof(struct eventlog_addindex), sort_eventlog_fn);
#  120|   
#  121|   	for (i = 0; i < icount; i++)

Error: GCC_ANALYZER_WARNING (CWE-688): [#def10]
nvme-cli-2.10.2-build/nvme-cli-2.10.2/plugins/innogrit/innogrit-nvme.c: scope_hint: In function ‘setfilecontent’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/plugins/innogrit/innogrit-nvme.c:134:14: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘fopen(filenamea, "a+")’ where non-null expected
nvme-cli-2.10.2-build/nvme-cli-2.10.2/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
#  132|   		return true;
#  133|   	fp = fopen(filenamea, "a+");
#  134|-> 	rc = fwrite(buffer, 1, buffersize, fp);
#  135|   	fclose(fp);
#  136|   	if (rc != buffersize)

Error: GCC_ANALYZER_WARNING (CWE-775): [#def11]
nvme-cli-2.10.2-build/nvme-cli-2.10.2/util/cleanup.h:20:12: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘ffd’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.h:126:15: note: in expansion of macro ‘DEFINE_CLEANUP_FUNC’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.c: scope_hint: In function ‘dir_send’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.h:126:15: note: in expansion of macro ‘DEFINE_CLEANUP_FUNC’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/nvme.h:126:15: note: in expansion of macro ‘DEFINE_CLEANUP_FUNC’
#   18|   DECLARE_CLEANUP_FUNC(name, type)		\
#   19|   {						\
#   20|-> 	if (*__p)				\
#   21|   		free_fn(*__p);			\
#   22|   }

Error: GCC_ANALYZER_WARNING (CWE-1341): [#def12]
nvme-cli-2.10.2-build/nvme-cli-2.10.2/util/cleanup.h:35:17: warning[-Wanalyzer-fd-double-close]: double ‘close’ of file descriptor ‘open(&file_path, 577, 420)’
nvme-cli-2.10.2-build/nvme-cli-2.10.2/plugins/solidigm/solidigm-internal-logs.c: scope_hint: In function ‘log_save’
#   33|   {
#   34|   	if (*fd > STDERR_FILENO)
#   35|-> 		close(*fd);
#   36|   }
#   37|   #define _cleanup_fd_ __cleanup__(cleanup_fd)

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