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

Remove a few misleading-indentation warnings #313

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

Conversation

fedepell
Copy link

@fedepell fedepell commented Nov 24, 2024

Remove two GCC (tested on 13.2.0) warnings from code.

I believe if accepted would be good also to put to the pregenerated ones (in include/flatcc/reflection/), but I didn't do that as I supposed maintainer takes usually care of that :-) (can add to PR if needed!)

Example output I see:

/home/foo/bar/generated/flatbuffers_common_builder.h: In function 'flatbuffers_char_array_copy_from_pe':
/home/foo/bar/generated/flatbuffers_common_builder.h:341:3: error: this 'for' clause does not guard... [-Werror=misleading-indentation]
  341 |   for (i = 0; i < n; ++i) N ## _copy_from_pe(&p[i], &p2[i]); return p; }\
      |   ^~~
/home/foo/bar/generated/flatbuffers_common_builder.h:360:1: note: in expansion of macro '__flatbuffers_define_fixed_array_primitives'
  360 | __ ## NS ## define_fixed_array_primitives(NS, N, T)\
      | ^~
/home/foo/bar/generated/flatbuffers_common_builder.h:668:1: note: in expansion of macro '__flatbuffers_build_scalar'
  668 | __flatbuffers_build_scalar(flatbuffers_, flatbuffers_char, char)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/foo/bar/generated/flatbuffers_common_builder.h:341:62: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  341 |   for (i = 0; i < n; ++i) N ## _copy_from_pe(&p[i], &p2[i]); return p; }\
      |                                                              ^~~~~~
/home/foo/bar/generated/flatbuffers_common_builder.h:360:1: note: in expansion of macro '__flatbuffers_define_fixed_array_primitives'
  360 | __ ## NS ## define_fixed_array_primitives(NS, N, T)\
      | ^~
/home/foo/bar/generated/flatbuffers_common_builder.h:668:1: note: in expansion of macro '__flatbuffers_build_scalar'
  668 | __flatbuffers_build_scalar(flatbuffers_, flatbuffers_char, char)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/foo/bar/generated/flatbuffers_common_builder.h:340:69: error: this 'else' clause does not guard... [-Werror=misleading-indentation]
  340 | { size_t i; if (NS ## is_native_pe()) memcpy(p, p2, n * sizeof(T)); else\
      |                                                                     ^~~~~
  341 |   for (i = 0; i < n; ++i) N ## _copy_from_pe(&p[i], &p2[i]); return p; }\
      |                                                                      
/home/foo/bar/generated/flatbuffers_common_builder.h:360:1: note: in expansion of macro '__flatbuffers_define_fixed_array_primitives'
  360 | __ ## NS ## define_fixed_array_primitives(NS, N, T)\
      | ^~
/home/foo/bar/generated/flatbuffers_common_builder.h:668:1: note: in expansion of macro '__flatbuffers_build_scalar'
  668 | __flatbuffers_build_scalar(flatbuffers_, flatbuffers_char, char)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/foo/bar/generated/flatbuffers_common_builder.h:341:62: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
  341 |   for (i = 0; i < n; ++i) N ## _copy_from_pe(&p[i], &p2[i]); return p; }\
      |                                                              ^~~~~~
/home/foo/bar/generated/flatbuffers_common_builder.h:360:1: note: in expansion of macro '__flatbuffers_define_fixed_array_primitives'
  360 | __ ## NS ## define_fixed_array_primitives(NS, N, T)\
      | ^~
/home/foo/bar/generated/flatbuffers_common_builder.h:668:1: note: in expansion of macro '__flatbuffers_build_scalar'
  668 | __flatbuffers_build_scalar(flatbuffers_, flatbuffers_char, char)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/foo/bar/generated/flatbuffers_common_builder.h: In function 'flatbuffers_char_array_copy_to_pe':
/home/foo/bar/generated/flatbuffers_common_builder.h:344:3: error: this 'for' clause does not guard... [-Werror=misleading-indentation]
  344 |   for (i = 0; i < n; ++i) N ## _copy_to_pe(&p[i], &p2[i]); return p; }
      |   ^~~
/home/foo/bar/generated/flatbuffers_common_builder.h:360:1: note: in expansion of macro '__flatbuffers_define_fixed_array_primitives'
  360 | __ ## NS ## define_fixed_array_primitives(NS, N, T)\
      | ^~
/home/foo/bar/generated/flatbuffers_common_builder.h:668:1: note: in expansion of macro '__flatbuffers_build_scalar'
  668 | __flatbuffers_build_scalar(flatbuffers_, flatbuffers_char, char)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/foo/bar/generated/flatbuffers_common_builder.h:344:60: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  344 |   for (i = 0; i < n; ++i) N ## _copy_to_pe(&p[i], &p2[i]); return p; }
      |                                                            ^~~~~~
/home/foo/bar/generated/flatbuffers_common_builder.h:360:1: note: in expansion of macro '__flatbuffers_define_fixed_array_primitives'
  360 | __ ## NS ## define_fixed_array_primitives(NS, N, T)\
      | ^~
/home/foo/bar/generated/flatbuffers_common_builder.h:668:1: note: in expansion of macro '__flatbuffers_build_scalar'
  668 | __flatbuffers_build_scalar(flatbuffers_, flatbuffers_char, char)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/foo/bar/generated/flatbuffers_common_builder.h:343:69: error: this 'else' clause does not guard... [-Werror=misleading-indentation]
  343 | { size_t i; if (NS ## is_native_pe()) memcpy(p, p2, n * sizeof(T)); else\
      |                                                                     ^~~~~
  344 |   for (i = 0; i < n; ++i) N ## _copy_to_pe(&p[i], &p2[i]); return p; }
      |                                                                      
/home/foo/bar/generated/flatbuffers_common_builder.h:360:1: note: in expansion of macro '__flatbuffers_define_fixed_array_primitives'
  360 | __ ## NS ## define_fixed_array_primitives(NS, N, T)\
      | ^~
/home/foo/bar/generated/flatbuffers_common_builder.h:668:1: note: in expansion of macro '__flatbuffers_build_scalar'
  668 | __flatbuffers_build_scalar(flatbuffers_, flatbuffers_char, char)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/foo/bar/generated/flatbuffers_common_builder.h:344:60: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
  344 |   for (i = 0; i < n; ++i) N ## _copy_to_pe(&p[i], &p2[i]); return p; }
      |                                                            ^~~~~~
/home/foo/bar/generated/flatbuffers_common_builder.h:360:1: note: in expansion of macro '__flatbuffers_define_fixed_array_primitives'
  360 | __ ## NS ## define_fixed_array_primitives(NS, N, T)\
      | ^~
/home/foo/bar/generated/flatbuffers_common_builder.h:668:1: note: in expansion of macro '__flatbuffers_build_scalar'
  668 | __flatbuffers_build_scalar(flatbuffers_, flatbuffers_char, char)

Remove a few GCC (tested on 13.2.0) warnings from code
@fedepell fedepell force-pushed the misleading-identation branch from 3c25745 to 005f54d Compare December 1, 2024 05:04
@fedepell fedepell changed the title Remove two misleading-indentation warnings Remove a few misleading-indentation warnings Dec 1, 2024
@fedepell
Copy link
Author

fedepell commented Dec 1, 2024

I've done one more commit fixing another two. I know there may be more but maybe if they are trivial to fix (like the 4 in this mr) it may be worth to clean up as we go by to be able to remove at some point the need to disable the warning?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant