Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix misleading indentation in stb_divide.h #1195

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

musicinmybrain
Copy link

With -Wmisleading-indentation (part of -Wall), gcc 11.2.1 warns:

  In file included from test_c_compilation.c:22:
  ../stb_divide.h: In function 'test':
  ../stb_divide.h:316:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    316 |    if (show) printf("(%+11d,%+2d)  ", q,r); stbdiv_check(q,r,a,b, "trunc",a);
        |    ^~
  ../stb_divide.h:316:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    316 |    if (show) printf("(%+11d,%+2d)  ", q,r); stbdiv_check(q,r,a,b, "trunc",a);
        |                                             ^~~~~~~~~~~~
  ../stb_divide.h:318:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    318 |    if (show) printf("(%+11d,%+2d)  ", q,r); stbdiv_check(q,r,a,b, "floor",b);
        |    ^~
  ../stb_divide.h:318:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    318 |    if (show) printf("(%+11d,%+2d)  ", q,r); stbdiv_check(q,r,a,b, "floor",b);
        |                                             ^~~~~~~~~~~~
  ../stb_divide.h:320:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    320 |    if (show) printf("(%+11d,%+2d)\n", q,r); stbdiv_check(q,r,a,b, "euclidean",1);
        |    ^~
  ../stb_divide.h:320:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    320 |    if (show) printf("(%+11d,%+2d)\n", q,r); stbdiv_check(q,r,a,b, "euclidean",1);
        |                                             ^~~~~~~~~~~~

This commit moves each call to stbdiv_check(…) to the following line to make clear that it is unconditional and to resolve the warning.

(This is a trivial fix; no need to add me to the list of contributors.)

With -Wmisleading-indentation (part of -Wall), gcc 11.2.1 warns:

  In file included from test_c_compilation.c:22:
  ../stb_divide.h: In function 'test':
  ../stb_divide.h:316:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    316 |    if (show) printf("(%+11d,%+2d)  ", q,r); stbdiv_check(q,r,a,b, "trunc",a);
        |    ^~
  ../stb_divide.h:316:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    316 |    if (show) printf("(%+11d,%+2d)  ", q,r); stbdiv_check(q,r,a,b, "trunc",a);
        |                                             ^~~~~~~~~~~~
  ../stb_divide.h:318:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    318 |    if (show) printf("(%+11d,%+2d)  ", q,r); stbdiv_check(q,r,a,b, "floor",b);
        |    ^~
  ../stb_divide.h:318:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    318 |    if (show) printf("(%+11d,%+2d)  ", q,r); stbdiv_check(q,r,a,b, "floor",b);
        |                                             ^~~~~~~~~~~~
  ../stb_divide.h:320:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    320 |    if (show) printf("(%+11d,%+2d)\n", q,r); stbdiv_check(q,r,a,b, "euclidean",1);
        |    ^~
  ../stb_divide.h:320:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    320 |    if (show) printf("(%+11d,%+2d)\n", q,r); stbdiv_check(q,r,a,b, "euclidean",1);
        |                                             ^~~~~~~~~~~~

This commit moves each call to stbdiv_check(…) to the following line to
make clear that it is unconditional and to resolve the warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants