Project

General

Profile

Actions

Bug #14596

open

cstyle should allow empty increment with for loop

Added by Toomas Soome almost 2 years ago. Updated 11 months ago.

Status:
Feedback
Priority:
Normal
Assignee:
Category:
tools - gate/build tools
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:
External Bug:

Description

Current cstyle can not handle constructs like 'for (expr; cond;)', even adding space before ')' does not help. Add expression to allow this for loop case.

Testing done: previously failing check is happy now.

All tests passing following code:

int
main()
{
        for (;;) {
        }

        for (int i = 0;;) {
        }

        for (int i = 0;
            i < 0; i++) {
        }

        for (int i = 0;
            i < 100;
            i++) {
        }
}

Some error cases:

       for (  ;  ;  ) {
        }

tsoome@beastie:~$ cstyle -pP cstyle.c 
cstyle.c: 4: comma or semicolon preceded by blank
cstyle.c: 4: whitespace after left paren
cstyle.c: 4: whitespace before right paren

       for (int i = 0 ; ; ) {
        }

tsoome@beastie:~$ cstyle -pP cstyle.c 
cstyle.c: 7: comma or semicolon preceded by blank
cstyle.c: 7: whitespace before right paren
tsoome@beastie:~$

        for (int i = 0;
            i < 0;i++) {
        }

tsoome@beastie:~$ cstyle -pP cstyle.c 
cstyle.c: 11: comma or semicolon followed by non-blank: 
tsoome@beastie:~$ 

       for (int i = 0;
            i < 100;
            i++ ) {
        }

tsoome@beastie:~$ cstyle -pP cstyle.c 
cstyle.c: 16: whitespace before right paren
tsoome@beastie:~$


Related issues

Related to illumos gate - Bug #14609: loader: os console in options menu should use first name from listClosedToomas Soome

Actions
Related to illumos gate - Bug #15540: cstyle: for loop check is broken when macro is usedIn ProgressToomas Soome

Actions
Actions #1

Updated by Electric Monk almost 2 years ago

  • Gerrit CR set to 2082
Actions #2

Updated by Toomas Soome almost 2 years ago

  • Related to Bug #14609: loader: os console in options menu should use first name from list added
Actions #3

Updated by Toomas Soome about 1 year ago

  • Status changed from In Progress to Pending RTI
Actions #4

Updated by Toomas Soome about 1 year ago

  • Description updated (diff)
Actions #5

Updated by Electric Monk 12 months ago

  • Status changed from Pending RTI to Closed
  • % Done changed from 90 to 100

git commit 543a8da84d26ec70222ecd1638b72c1e6c763275

commit  543a8da84d26ec70222ecd1638b72c1e6c763275
Author: Toomas Soome <tsoome@me.com>
Date:   2023-02-27T15:01:34.000Z

    14596 cstyle should allow empty increment with for loop
    Reviewed by: Andy Stormont <andyjstormont@gmail.com>
    Approved by: Dan McDonald <danmcd@mnx.io>

Actions #6

Updated by Rich Lowe 11 months ago

  • Status changed from Closed to Feedback

This broke cstyle in mysterious and unbecoming ways.
Notably, a whole lot of complaints about multiple keywords on a line, and stuff after {, neither of which are true.

Actions #7

Updated by Toomas Soome 11 months ago

  • Related to Bug #15540: cstyle: for loop check is broken when macro is used added
Actions #8

Updated by Electric Monk 11 months ago

git commit fcfad32eae7db0a40025885d6c711a60de8c2d5e

commit  fcfad32eae7db0a40025885d6c711a60de8c2d5e
Author: Patrick Mooney <pmooney@pfmooney.com>
Date:   2023-04-08T16:29:52.000Z

    backout: 14596 cstyle should allow empty increment with for loop (needs more work)

Actions

Also available in: Atom PDF