From 4a7395b0171d7f84aeaf10e7e10376c2cea2c4dd Mon Sep 17 00:00:00 2001 From: "REDMOND\\brodes" Date: Thu, 12 Feb 2026 11:11:43 -0500 Subject: [PATCH] C++ Suggested code clean up. --- .../UncheckedLeapYearAfterYearModification.ql | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/cpp/ql/src/Likely Bugs/Leap Year/UncheckedLeapYearAfterYearModification.ql b/cpp/ql/src/Likely Bugs/Leap Year/UncheckedLeapYearAfterYearModification.ql index 5ebd8af4392..e7bd8fe8ff0 100644 --- a/cpp/ql/src/Likely Bugs/Leap Year/UncheckedLeapYearAfterYearModification.ql +++ b/cpp/ql/src/Likely Bugs/Leap Year/UncheckedLeapYearAfterYearModification.ql @@ -233,32 +233,29 @@ class IgnorableAssignmentBitwiseOperation extends IgnorableOperation instanceof class IgnorablePointerOrCharArithmetic extends IgnorableOperation { IgnorablePointerOrCharArithmetic() { this instanceof BinaryArithmeticOperation and - ( - this.(BinaryArithmeticOperation).getAnOperand().getUnspecifiedType() instanceof PointerType + exists(Expr op | op = this.(BinaryArithmeticOperation).getAnOperand() | + op.getUnspecifiedType() instanceof PointerType or - this.(BinaryArithmeticOperation).getAnOperand().getUnspecifiedType() instanceof CharType + op.getUnspecifiedType() instanceof CharType or // Operations on calls to functions that accept char or char* - this.(BinaryArithmeticOperation) - .getAnOperand() - .(Call) - .getAnArgument() - .getUnspecifiedType() - .stripType() instanceof CharType + op.(Call).getAnArgument().getUnspecifiedType().stripType() instanceof CharType or // Operations on calls to functions named like "strlen", "wcslen", etc // NOTE: workaround for cases where the wchar_t type is not a char, but an unsigned short // unclear if there is a best way to filter cases like these out based on type info. - this.(BinaryArithmeticOperation).getAnOperand().(Call).getTarget().getName().matches("%len%") + op.(Call).getTarget().getName().matches("%len%") ) or exists(AssignArithmeticOperation a | a.getRValue() = this | - a.getAnOperand().getUnspecifiedType() instanceof PointerType - or - a.getAnOperand().getUnspecifiedType() instanceof CharType - or - // Operations on calls to functions that accept char or char* - a.getAnOperand().(Call).getAnArgument().getUnspecifiedType().stripType() instanceof CharType + exists(Expr op | op = a.getAnOperand() | + op.getUnspecifiedType() instanceof PointerType + or + op.getUnspecifiedType() instanceof CharType + or + // Operations on calls to functions that accept char or char* + op.(Call).getAnArgument().getUnspecifiedType().stripType() instanceof CharType + ) or // Operations on calls to functions named like "strlen", "wcslen", etc this.(BinaryArithmeticOperation).getAnOperand().(Call).getTarget().getName().matches("%len%")