[SERVER-60616] Coverity analysis defect 120880: Unsigned compared against 0 Created: 12/Oct/21  Updated: 29/Oct/23  Resolved: 20/Oct/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.1.0-rc0
Fix Version/s: 5.2.0, 5.1.1

Type: Task Priority: Minor - P4
Reporter: Coverity Collector User Assignee: Neil Shweky (Inactive)
Resolution: Fixed Votes: 0
Labels: coverity, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2021-10-12 at 9.34.57 AM.png    
Issue Links:
Backports
Duplicate
is duplicated by SERVER-60617 Coverity analysis defect 120880: Unsi... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v5.1
Sprint: QE 2021-11-01
Participants:

 Description   

Unsigned compared against 0

An unsigned value can never be negative, so this test will always evaluate the same way. An unsigned value can never be less than 0
/src/mongo/db/exec/sbe/expressions/expression.cpp:478: NO_EFFECT 120880 This greater-than-or-equal-to-zero comparison of an unsigned value is always true. "n >= 0UL".



 Comments   
Comment by Kyle Suarez [ 09/Nov/21 ]

This is in both 5.2.0 as well as 5.1.1, so adding back the 5.2.0 fixVersion. CC neil.shweky

Comment by Githook User [ 08/Nov/21 ]

Author:

{'name': 'Neil Shweky', 'email': 'neilshweky@gmail.com', 'username': 'Neilshweky'}

Message: SERVER-60616: change hash to use kAnyNumberOfArgs

(cherry picked from commit 1c805a82af30bbc7b47bdbdf03b50c2ac3005c31)
Branch: v5.1
https://github.com/mongodb/mongo/commit/c08373c3767d76e5fe674aeef806996d75940e48

Comment by Githook User [ 20/Oct/21 ]

Author:

{'name': 'Neil Shweky', 'email': 'neilshweky@gmail.com', 'username': 'Neilshweky'}

Message: SERVER-60616: change hash to use kAnyNumberOfArgs
Branch: master
https://github.com/mongodb/mongo/commit/7a1ba713cbb09a605de4db2bb9ce69477ea11859

Comment by Kyle Suarez [ 12/Oct/21 ]

The hash builtin SBE function is using an arity checker function that has no effect because it will always be true. We have a kAnyNumberOfArgs function that can be used to trivially accept any number of arguments, used like so:

{"setUnion", BuiltinFn{kAnyNumberOfArgs, vm::Builtin::setUnion, false}},

Generated at Thu Feb 08 05:50:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.