Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc #392

Merged
merged 5 commits into from
Sep 20, 2023
Merged

Misc #392

merged 5 commits into from
Sep 20, 2023

Conversation

gperciva
Copy link
Member

@gperciva gperciva commented Sep 6, 2023

No description provided.

This was imported into libcperciva on 2023-08-16, so the code in spiped
should follow suit.
This should have been part of:
    2019-10-15 tests/nc-server: add bit-limited echo server
    ee4d29e

We didn't notice earlier, because a pair of errors cancelled each other out:

1) there was no "success, return 0" in write_bps(), so it always
   returned a -1.

2) callback_read() did not check the returned value from the callback
   function, so that -1 was ignored.

Reported by:	cppcheck-2.11
I added sanity checks in:

    2022-08-23 perfests/{recv,send}-zeros: add sanity checks
    c87a40b

which were a bit confused (i.e. checking that a (size_t) was not <= 0).
At that time:

- buflen in recv-zeros/main.c was a (ssize_t), whereas
- buflen in send-zeros/main.c was a (size_t), and
- clang-tidy 14 and lower could not follow our PARSENUM().
  macro to understand that:

    if (PARSENUM(&buflen, argv[2], 1, SSIZE_MAX))
            goto err0;

  would always result in a positive, non-zero value in buflen.

This commit:

- makes both files use (size_t)buflen.
- adds bounds to PARSENUM(&count...
- eliminates the post-PARSENUM sanity checks.

  That last point will make clang-tidy versions below 15.0.0 (2022-09-6)
  complain about the code, but inspection shows that it's correct.
  And it's normal for clang-tidy to have tons of complaints anyway;
  I normally disable ~60 types of warnings.

- also, this commit cleans up the #includes.
    The XSI extensions specifying the -a and -o binary primaries...
    have been marked obsolescent... Scripts using these expressions
    should be converted to the forms given below...
        test "$1" -a "$2"
    should be written as:
        test "$1" && test "$2"
    https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html

https://www.shellcheck.net/wiki/SC2166

Reported by: shellcheck-0.9
@cperciva cperciva merged commit 50c24cd into master Sep 20, 2023
@gperciva gperciva deleted the misc branch September 20, 2023 16:36
@gperciva
Copy link
Member Author

Whoops! The first commit (move millisleep.h to libcperciva/util) was incorrect -- it hasn't actually been imported into libcperciva yet. That's part of the fork-func commit. I must have been on the fork-func branch in libcperciva when I was putting this PR together, sorry.

This isn't a big problem, but I thought that I should mention it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants