Date: Sat, 20 Feb 2021 19:49:21 GMT From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 26682c1fa74c - stable/12 - pkg(7): address minor nits (mostly clang-analyze complaints) Message-ID: <202102201949.11KJnLXM079738@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=26682c1fa74c32fe3fdd250bb1481714197b0b51 commit 26682c1fa74c32fe3fdd250bb1481714197b0b51 Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2021-02-12 00:58:27 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2021-02-20 19:49:04 +0000 pkg(7): address minor nits (mostly clang-analyze complaints) - One (1) spurious whitespace. - One (1) occurrence of "random(3) bad, arc4random(3)" good. - Three (3) writes that will never be seen. The latter two points are complaints from clang-analyze. Switching to arc4random(3) is decidedly a good idea because we weren't doing any kind of PRNG seeding anyways. The discarded assignments are arguably good for future-proofing, but it's better to improve the S/N ratio from clang-analyze. (cherry picked from commit b2c4ca8d2872bc4410626f2b1ceafa49de5828ce) --- usr.sbin/pkg/dns_utils.c | 5 +++-- usr.sbin/pkg/pkg.c | 3 --- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/usr.sbin/pkg/dns_utils.c b/usr.sbin/pkg/dns_utils.c index 78ebdd426f8b..f3bde529daca 100644 --- a/usr.sbin/pkg/dns_utils.c +++ b/usr.sbin/pkg/dns_utils.c @@ -87,7 +87,7 @@ compute_weight(struct dns_srvinfo **d, int first, int last) int *chosen; totalweight = 0; - + for (i = 0; i <= last; i++) totalweight += d[i]->weight; @@ -98,7 +98,8 @@ compute_weight(struct dns_srvinfo **d, int first, int last) for (i = 0; i <= last; i++) { for (;;) { - chosen[i] = random() % (d[i]->weight * 100 / totalweight); + chosen[i] = arc4random_uniform(d[i]->weight * 100 / + totalweight); for (j = 0; j < i; j++) { if (chosen[i] == chosen[j]) break; diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index 50b196fd9b30..54eaf0882372 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -433,9 +433,7 @@ sha256_fd(int fd, char out[SHA256_DIGEST_LENGTH * 2 + 1]) int ret; SHA256_CTX sha256; - my_fd = -1; fp = NULL; - r = 0; ret = 1; out[0] = '\0'; @@ -626,7 +624,6 @@ parse_cert(int fd) { ssize_t linelen; buf = NULL; - my_fd = -1; sc = NULL; line = NULL; linecap = 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202102201949.11KJnLXM079738>