Skip to content

Commit

Permalink
perfests/{recv,send}-zeros: add sanity checks
Browse files Browse the repository at this point in the history
PARSENUM already ensures that (buflen > 0), but it's difficult for
static analysis programs to handle parsenum.h.

Reported by:	clang-tidy
  • Loading branch information
gperciva authored and cperciva committed Aug 24, 2022
1 parent b1ff4e8 commit c87a40b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions perftests/recv-zeros/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ main(int argc, char ** argv)
goto err0;
}

/* Sanity check. */
if (buflen <= 0) {
warnp("Can't have a buffer length <= 0!");
goto err0;
}

/* Allocate buffer. */
if ((buffer = malloc((size_t)buflen)) == NULL) {
warnp("malloc");
Expand Down
6 changes: 5 additions & 1 deletion perftests/send-zeros/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ main(int argc, char ** argv)
goto err0;
}

/* Sanity check */
/* Sanity check. */
if (buflen <= 0) {
warnp("Can't have a buffer length <= 0!");
goto err0;
}
if (count == 0) {
warnp("Can't send 0 blocks!");
goto err0;
Expand Down

0 comments on commit c87a40b

Please sign in to comment.