-
Notifications
You must be signed in to change notification settings - Fork 393
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 some compiler warnings for unused local variables #728
Conversation
Thanks. It all looks fine to me, but github security has a warning, and I don't know how much credibility should be given to that. |
Also, using (void)fscanf() gives CMake ubuntu build warnings, such as
|
So my pull request does not work for Ubuntu. It took me some time to find the reason. On macOS the problem does not exist. On Debian and Ubuntu functions like Leptonica builds use recent versions of gcc or clang with optimization. On Debian, So what can we do?
I think I'll try a patch for the last alternative. |
That seems like the most elegant approach. leptonica_system() or lept_system() (I prefer shorter) could go in utils1.c, which is the same file where lept_stderr() is defined. |
I now updated the pull request with We still need similar wrappers |
Sorry -- this got buried in my 'stack'. Do we still have this critical issue? And why has it only surfaced when the sprintf() is passed to system() within this new function? We got away with it before. |
I think that we always had this "issue", So we can either ignore the warning or fix it by checking whether the printer argument is syntactically a valid printer name. |
Dan, you'll see that "critical error" and some more here (only visible for project members). |
Good to see that this is not a real problem! I just remembered that we already have a wrapper for system(), |
Also, I have 3 programs that do this 'critical' thing that are NOT caught by the compiler. |
And the plot gets thicker. I call |
Could the reason |
Commit 0d44776 adds the callSystemDebug() wrapper to all calls to system(). |
Signed-off-by: Stefan Weil <[email protected]>
Instead of assigning the return value to an otherwise unused variable (which also raises a compiler warning), use a cast to void to explicitly indicate that the return value is intentionally ignored. Signed-off-by: Stefan Weil <[email protected]>
That does not fix the "critical" code scanning alerts ("Uncontrolled data used in OS command"). |
I close this pull request because my suggested changes don't fix the compiler warnings for calls of functions with |
Instead of assigning the return value to an otherwise unused variable (which also raises a compiler warning), use a cast to void to explicitly indicate that the return value is intentionally ignored.
Calling system() without checking the return value does not raise a compiler warning, so don't add the cast for those calls.