C static code analysis (2024)

maintainability

Why is this an issue?

More Info

The use of increment and decrement operators in method calls or in combination with other arithmetic operators is not recommended, because:

  • It can significantly impair the readability of the code.
  • It introduces additional side effects into a statement, with the potential for undefined behavior.
  • It is safer to use these operators in isolation from any other arithmetic operators.

Noncompliant code example

u8a = ++u8b + u8c--;foo = bar++ / 4;

Compliant solution

The following sequence is clearer and therefore safer:

++u8b;u8a = u8b + u8c;u8c--;foo = bar / 4;bar++;
C static code analysis (2024)
Top Articles
Latest Posts
Article information

Author: Roderick King

Last Updated:

Views: 5766

Rating: 4 / 5 (51 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Roderick King

Birthday: 1997-10-09

Address: 3782 Madge Knoll, East Dudley, MA 63913

Phone: +2521695290067

Job: Customer Sales Coordinator

Hobby: Gunsmithing, Embroidery, Parkour, Kitesurfing, Rock climbing, Sand art, Beekeeping

Introduction: My name is Roderick King, I am a cute, splendid, excited, perfect, gentle, funny, vivacious person who loves writing and wants to share my knowledge and understanding with you.