nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.37k stars 323 forks source link

Fix an unused variable issue in nxt_term_parse() as found by clang-analyzer and coverity #1441

Closed ac000 closed 3 days ago

ac000 commented 4 days ago

The following changes since commit ba234b4db2d137b7dcf63188cc19e0493ebbc01a:

  Version bump (2024-09-17 22:42:09 +0100)

are available in the Git repository at:

  git@github.com:ac000/unit.git ca-fix

for you to fetch changes up to bba84a73a259b7cb93e3c0a52a0aa7253e53042c:

  src/test: Add an extra test case to nxt_term_parse_test.c (2024-09-24 14:55:04 +0100)

----------------------------------------------------------------

The first patch fixes a clang-analyzer and coverity issue where we assign
a value and then assign again without using it inbetween.

The second patch adds a test case for strings with trailing whitespace.

----------------------------------------------------------------
Andrew Clayton (2):
      Resolve unused assignment in nxt_term_parse()
      src/test: Add an extra test case to nxt_term_parse_test.c

 src/nxt_time_parse.c           | 24 +++++++++---------------
 src/test/nxt_term_parse_test.c |  1 +
 2 files changed, 10 insertions(+), 15 deletions(-)
ac000 commented 3 days ago
$ git range-diff d2603475...bba84a73
1:  b401e6b6 < -:  -------- Rename st_space to st_next in nxt_term_parse()
2:  d2603475 < -:  -------- Remove some dead code from nxt_term_parse()
-:  -------- > 1:  bba84a73 src/test: Add an extra test case to nxt_term_parse_test.c
ac000 commented 3 days ago

Thanks @hongzhidao !

ac000 commented 3 days ago

Rebased with master

$ git range-diff bba84a73...a9d687e7
-:  -------- > 1:  355f038f Compile with -funsigned-char
1:  06a7f650 = 2:  b358e7fb Resolve unused assignment in nxt_term_parse()
2:  bba84a73 = 3:  a9d687e7 src/test: Add an extra test case to nxt_term_parse_test.c