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

respecting nodiscard for fscanf #3214

Merged
merged 2 commits into from
Jul 9, 2019

Conversation

kunaltyagi
Copy link
Member

Skip early if return value of fscanf is 0 (or negative, though not possible)

This also prevents compiler warnings about discarding the return value of fscanf

@SergioRAgostinho
Copy link
Member

This was changed very recently in #3095. clang-tidy flagged them as dead stores. This means we need to manually flag them so that clang-tidy can ignore them safely. See
https://clang.llvm.org/extra/clang-tidy/#suppressing-undesired-diagnostics

@kunaltyagi
Copy link
Member Author

kunaltyagi commented Jul 9, 2019

I can't find the clang-tidy config. I assume that's out-of-repo and is set as reported in the commit. I'll take a look and report back

Update

$ clang-tidy -header-filter=.* -checks=-*,clang-analyzer-deadcode.DeadStores -p=build -clang-tidy-binary <path_to_binary_coz _not_in_my_path> ./ml/src/svm.cpp

Says dead-store for 5 fscanf, lines 3261, 3264,3267, 3270, 3273.

As per this FAQ, (void)res is a solution.

Added that to the next commit. Tested with the above command to get 0 warnings

@SergioRAgostinho SergioRAgostinho merged commit aeab202 into PointCloudLibrary:master Jul 9, 2019
@kunaltyagi kunaltyagi deleted the fscanf branch July 9, 2019 13:36
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.

3 participants