[CDRIVER-2181] Coverity analysis defect 100078: Logically dead code Created: 09/Jun/17  Updated: 28/Oct/23  Resolved: 04/Aug/17

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.8.0

Type: Bug Priority: Trivial - P5
Reporter: Coverity Collector User Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Code can never be reached because of a logical contradiction

Defect 100078 (STATIC_C)
Checker DEADCODE (subcategory none)
File: /src/jsonsl/jsonsl.c
Function jsonsl_util_unescape_ex
/src/jsonsl/jsonsl.c, line: 1364
Condition "--len == 0UL", taking false branch. Now the value of "len" is at least 1.
/src/jsonsl/jsonsl.c, line: 1382
Decrementing "len". The value of "len" is now at least 1.
/src/jsonsl/jsonsl.c, line: 1389
Condition "len < 6UL", taking false branch. Now the value of "len" is at least 6.
/src/jsonsl/jsonsl.c, line: 1427
Assigning: "len" -= "5UL".
/src/jsonsl/jsonsl.c, line: 1347
Decrementing "len". The value of "len" is now at least 0.
/src/jsonsl/jsonsl.c, line: 1347
Condition "len", taking true branch. Now the value of "len" is at least 1.
/src/jsonsl/jsonsl.c, line: 1354
Condition "len < 2UL", taking false branch. Now the value of "len" is at least 2.
/src/jsonsl/jsonsl.c, line: 1364
Decrementing "len". The value of "len" is now at least 1.
/src/jsonsl/jsonsl.c, line: 1364
At condition "-len == 0UL", the value of "-len" must be at least 1.
/src/jsonsl/jsonsl.c, line: 1364
The condition "--len == 0UL" cannot be true.
/src/jsonsl/jsonsl.c, line: 1365
Execution cannot reach this statement: "break;".



 Comments   
Comment by Githook User [ 04/Aug/17 ]

Author:

{'username': 'ajdavis', 'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis'}

Message: delete redundant code in jsonsl.c

Merge two upstream fixes:

https://github.com/mnunberg/jsonsl/pull/36
https://github.com/mnunberg/jsonsl/pull/37

CDRIVER-2180 and CDRIVER-2181.
Branch: master
https://github.com/mongodb/libbson/commit/bfcf5b76ebdd1e9c7af7831711121bb96054d9bf

Comment by A. Jesse Jiryu Davis [ 03/Aug/17 ]

Fix submitted upstream: https://github.com/mnunberg/jsonsl/pull/37

Generated at Wed Feb 07 21:14:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.