sqc 0.4.13

Software Code Quality - CERT C compliance checker
[metadata]
id = "INT14-C"
type = "recommendation"
category = "INT"
number = 14
title = "Avoid performing bitwise and arithmetic operations on the same data"
description = """
Avoid performing bitwise and arithmetic operations on the same data. In
particular, bitwise operations are frequently performed on arithmetic values as
a form of premature optimization. Bitwise operators include the unary
operator~and the binary operators<<,>>,&,^, and|. Although such operations are
valid and will compile, they can reduce code readability. Declaring a variable
as containing a numeric value or a bitmap makes the programmer's intentions
clearer and the code more maintainable. Bitmapped types may be defined to
further separate bit collections from numeric types. Doing so may make it easier
to verify that bitwise operations are performed only on variables that represent
bitmaps. typedef uint32_t bitmap32_t; bitmap32_t x = 0x000007f3; x = (x << 2) |
3; /* Shifts in two 1-bits from the right */
"""
severity = "Medium"
likelihood = "Unlikely"
priority = "P4"
level = "L3"
cert_version = "2016 Edition (Wiki)"
last_modified = "May 20, 2025"

[rules.cert_c.INT14-C]
enabled = true

[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/INT14-C.+Avoid+performing+bitwise+and+arithmetic+operations+on+the+same+data"