git: d281fece432f - main - kldxref: Appease a Coverity warning

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 22 Dec 2023 15:50:13 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=d281fece432f97b4424b852f23dfe1f974b9e30d

commit d281fece432f97b4424b852f23dfe1f974b9e30d
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-12-22 15:49:40 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-12-22 15:49:40 +0000

    kldxref: Appease a Coverity warning
    
    While parsing .dynamic, nsym is set when parsing the symbol table from
    .dynsym.  That parsing also sets ef->ef_symtab to a non-NULL value.
    The value of nsym isn't validated until after a check for
    ef->ef_symtab being NULL, so nsym always has a valid value when it is
    read.  However, that chain of events is a bit much for static analysis
    to follow, so initialize nsym to 0 before parsing sections to quiet
    the warning.
    
    Reported by:    Coverity Scan
    CID:            1532339
    Sponsored by:   DARPA
---
 usr.sbin/kldxref/ef.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/usr.sbin/kldxref/ef.c b/usr.sbin/kldxref/ef.c
index 46d3dc1f4578..fd0782ff1dd0 100644
--- a/usr.sbin/kldxref/ef.c
+++ b/usr.sbin/kldxref/ef.c
@@ -361,6 +361,7 @@ ef_parse_dynamic(elf_file_t ef, const GElf_Phdr *phdyn)
 		goto out;
 	}
 
+	nsym = 0;
 	for (i = 0; i < nshdr; i++) {
 		switch (shdr[i].sh_type) {
 		case SHT_HASH: