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.

Reviewed by:	bapt, manu
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28525
This commit is contained in:
Kyle Evans 2021-02-11 18:58:27 -06:00
parent 18418e1936
commit b2c4ca8d28
2 changed files with 3 additions and 5 deletions

View File

@ -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;

View File

@ -434,9 +434,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';
@ -627,7 +625,6 @@ parse_cert(int fd) {
ssize_t linelen;
buf = NULL;
my_fd = -1;
sc = NULL;
line = NULL;
linecap = 0;