Repository navigation
treewide: fix 64-bit printk format mismatches and an LTO strcpy link failure - #127
Merged
Merged
Conversation
Values of typedef types (int64_t, size_t) and pointer-sized constants do not have a stable underlying type across compilers, so the same %lld, %llu and %zd call sites fail -Wformat on some hosts and pass on others. Pass each argument at the type its specifier reads: cast int64_t values printed with %llu to unsigned long long, print size_t with %zu, and give PROCESS_USER_STACK_TOP an ULL suffix so /proc/<pid>/stat keeps printing it with %llu. The rendered text is unchanged. Signed-off-by: FengHeting <2609948707@qq.com>
GCC can expand strcat() into a strcpy() call during LTO after the definition was already pruned, leaving an undefined reference to strcpy at link time. Mark the definition as used so it survives to the final link. Signed-off-by: FengHeting <2609948707@qq.com>
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.
Summary
Two build fixes for compiler-dependent behavior.
64-bit printk format specifiers
int64_t,size_tand pointer-sized constants do not have a stableunderlying type across toolchains, so the same
%lld/%llu/%zdcallsites trip
-Wformaton some hosts while building cleanly on others, whichmakes the failure move between machines.
Pass every argument at the type its specifier reads:
kernel/arch/cpu/smp.c: print thesize_tCPU count with%zuinsteadof
%zd.fs/ntfs/ntfs_runlist.c: cast theint64_tbyte offset and cluster countto
unsigned long longwhere the format uses%llu.fs/proc/procfs.c: castpid_tfields tounsigned long longfor%llu, use%lluforresident_pages, and use%llufor the user stacktop instead of
%lu.include/process/process.h: givePROCESS_USER_STACK_TOPanULLsuffix so its type matches the
%lluin procfs.Rendered output is unchanged for the value ranges these fields can take.
LTO strcpy link failure
GCC can expand
strcat()into astrcpy()call during LTO after thestrcpy()definition has been pruned as unused, leaving anundefined reference to 'strcpy'at link time. Mark the definition__attribute__((used))so it survives to the final link.Testing
make -j$(nproc)(GCC): clean build, no warnings.make <file>.tidy) clean on all touched C files.