Skip to content

Fix strncpy truncation warning and cppcheck index-before-check error#3893

Open
BsAtHome wants to merge 1 commit intoLinuxCNC:masterfrom
BsAtHome:fix_strncpy-and-index-check
Open

Fix strncpy truncation warning and cppcheck index-before-check error#3893
BsAtHome wants to merge 1 commit intoLinuxCNC:masterfrom
BsAtHome:fix_strncpy-and-index-check

Conversation

@BsAtHome
Copy link
Copy Markdown
Contributor

Newer GCC starts to complain even more about inappropriate use of strncpy when it obviously truncates. In this case a simple char type is appropriate instead of copying a string in to a buffer of length 1 (Tcl_GetStringFromObj always returns a valid buffer).

The second fix is a cppcheck error noting that an array index was used before the index was checked (in one expression). The expression has been rewritten to perform the index test before the index.

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