Fix various warnings on MacOS / Unix systems#22
Open
reinauer wants to merge 8 commits intosimh:masterfrom
Open
Fix various warnings on MacOS / Unix systems#22reinauer wants to merge 8 commits intosimh:masterfrom
reinauer wants to merge 8 commits intosimh:masterfrom
Conversation
reinauer
commented
Oct 17, 2025
- Fix "assignment as a condition" warnings
- Switch function declarations from K&R to ANSI C
- Fix warnings for unused function parameters
- Remove unused variables
- Type and format fixes
- config11: Use fgets instead of gets
- hpconvert: Use mkstemp() instead of tmpnam()
- ods2: Use proper braces in direct.c
A lot of code assigns variables within an if condition, like: if (ppos = strrchr (oname, '.')) strcpy (ppos, ".new"); This results in warnings with modern compilers: warning: using the result of an assignment as a condition without parentheses [-Wparentheses] Fix the code by properly adding parenthesis around these assignments.
From the gets() man page: The gets() function cannot be used securely. Because of its lack of bounds checking, and the inability for the calling program to reliably determine the length of the next incoming line, the use of this function enables malicious users to arbitrarily change a running program's functionality through a buffer overflow attack. It is strongly suggested that the fgets() function be used in all cases.
From the tmpnam() man page: The tmpnam() and tempnam() functions are susceptible to a race condition occurring between the selection of the file name and the creation of the file, which allows malicious users to potentially overwrite arbitrary files in the system, depending on the level of privilege of the running program.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.