Skip to content

"If" statement indenting disagrees with actual logic #16

@jimahlstrom

Description

@jimahlstrom

In files anf.c and anr.c at line 111 the following appears:
 if (nev < nel)
  if((a->lidx += a->lincr) > a->lidx_max) a->lidx = a->lidx_max;
 else
  if((a->lidx -= a->ldecr) < a->lidx_min) a->lidx = a->lidx_min;

But the C compiler interprets this as:
 if (nev < nel) {
  if((a->lidx += a->lincr) > a->lidx_max)
   a->lidx = a->lidx_max;
  else if((a->lidx -= a->ldecr) < a->lidx_min)
   a->lidx = a->lidx_min;
 }

That is, the "else" goes with the nearest "if". If the indenting is correct, we must add curly braces. If the logic is correct we must change the indentation and again add curly braces for clarity.

Which is correct, the indenting or the logic?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions