Raise the warning level to -Wall -Wextra and resolve the warnings#609
Open
matejk wants to merge 3 commits into
Open
Raise the warning level to -Wall -Wextra and resolve the warnings#609matejk wants to merge 3 commits into
matejk wants to merge 3 commits into
Conversation
- Check or deliberately consume warn_unused_result returns: asprintf results are verified instead of testing the (undefined-on-failure) output pointer; the lost-and-found path no longer leaks or reuses the old path on reallocation; the trace dump consumes write results while staying best-effort; /proc reads fall back to a placeholder and leave room for the terminator and arch suffix. - Replace strncpy on fixed-width SCSI and MAM fields with memcpy or the new bounded ltfs_string_copy (tape_ops.h), which always terminates; the device-list and serial-number copies were not guaranteed to be terminated before. The device-provided serial length is clamped to the field. - The MAM coherency signature copies its terminator explicitly; the reader checks all five bytes. - Initialize values read on early-exit paths (u_get_truncate_size). - Use size_t for the name-length arithmetic in fs_dentry_lookup; the unsigned conversion also surfaced and fixed a reversed loop bound in the cleanup path. - Spell the fall-through comment so the compiler recognizes it; format the XML timestamp with a real snprintf instead of the size-discarding arch_sprintf. Addresses the -Wstringop-truncation reports of LinearTapeFileSystem#280.
unused-parameter and missing-field-initializers stay disabled: callback signatures must keep parameters they do not use, and the operation/option tables intentionally rely on zero-initialized remaining members. The tree builds without compiler warnings on Linux (gcc 15, -O0 and -O2) and macOS (clang) apart from macOS SDK deprecation notices. The CMake build carries the same flags.
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.
The build used the default warning level, which hides real defects. This PR adds
-Wall -WextratoAM_CFLAGSand resolves every warning the tree then produces — string truncation in MAM attribute handling, sign and width mismatches, unused parameters and variables, missing field initializers — without behavior changes. Genuine bugs discovered by the higher warning level are filed in the separate bugfix PRs rather than here, so this PR stays mechanical and reviewable.Verified warning-clean at
-Wall -Wextra -O2with gcc on Ubuntu and clang on macOS (arm64);make checkstays green.Fixes #280.