Skip to content

Raise the warning level to -Wall -Wextra and resolve the warnings#609

Open
matejk wants to merge 3 commits into
LinearTapeFileSystem:mainfrom
matejk:cleanup/warnings
Open

Raise the warning level to -Wall -Wextra and resolve the warnings#609
matejk wants to merge 3 commits into
LinearTapeFileSystem:mainfrom
matejk:cleanup/warnings

Conversation

@matejk

@matejk matejk commented Jun 12, 2026

Copy link
Copy Markdown

The build used the default warning level, which hides real defects. This PR adds -Wall -Wextra to AM_CFLAGS and 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 -O2 with gcc on Ubuntu and clang on macOS (arm64); make check stays green.

Fixes #280.

matejk added 3 commits June 12, 2026 11:09
- 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.
@vandelvan vandelvan requested review from XV02, madjesc and vandelvan June 12, 2026 20:54
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.

Linux compilation warnings(4)

1 participant