Merged
Conversation
The `k2v_add_config` macro previously used a GCC-specific braced-group
expression (`({ ... })`), which triggers `-Wpedantic` warnings and is not
ISO C compliant. This change replaces it with a standard C helper function
`k2v__append_and_free`, defined in `k2v.c`, and updates the macro to call
this function.
This eliminates all `-Wpedantic` warnings related to `k2v_add_config` while
preserving the original API and behavior. The helper function handles
string concatenation, memory allocation, and cleanup in a portable way.
Also fixes a linking issue by removing the incorrect `static` declaration
from the header and ensuring the function has external linkage.
The `k2v_open_file` function previously compared `ssize_t len` (from `read`) with `size_t strlen(ret)`, triggering a `-Wsign-compare` warning. More importantly, the check `if (len != strlen(ret))` was logically flawed: it would fire whenever the file contained embedded null bytes — which is expected behavior for `strlen`, but not necessarily an error for config files. Since the function already explicitly null-terminates the buffer with `ret[len] = '\0'`, the string is always properly terminated. The warning message about "\0 is not the end of file" was misleading and unnecessary. This change: - Removes the problematic comparison - Simplifies error handling - Reduces allocated buffer size from `bufsize + 2` to `bufsize + 1` - Adds missing check for `read()` failure The function now safely returns a null-terminated string without spurious warnings or undefined comparisons.
1a65761 to
1a0d312
Compare
The `errno_map` array in `ruri_resolve_seccomp_errno` previously stored errno values as `int`, causing a `-Wsign-conversion` warning when passed to `SCMP_ACT_ERRNO()`, which expects an unsigned value. Since all standard errno constants (e.g., EPERM, EACCES) are positive and libseccomp requires errno codes in the range [1, 4095], changing the field type to `unsigned int` is both safe and semantically correct. This eliminates the compiler warning without altering behavior.
- Replace non-standard escape sequence `\e` with `\033` for ISO C compliance - Change `int n` to `ssize_t n` when capturing return value of `read()` - Use `size_t` for loop index to match `strlen()` return type These changes eliminate -Wpedantic, -Wconversion, and -Wsign-compare warnings while improving robustness and portability.
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.
✅ Normal merge
✅ Rebase merge
❌ Squash merge