From 5f9da2a651cbbbdf8c61b56158f376fbe3368654 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Tue, 22 Jul 2014 15:21:22 +0200 Subject: [PATCH] Fix format string problems in error(3) calls. --- libc/stdlib/heap.cpp | 4 ++-- utils/chvideomode.cpp | 4 ++-- utils/find.cpp | 2 +- utils/kill.cpp | 11 ++++++----- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libc/stdlib/heap.cpp b/libc/stdlib/heap.cpp index 3a27f4ac..36097a78 100644 --- a/libc/stdlib/heap.cpp +++ b/libc/stdlib/heap.cpp @@ -674,13 +674,13 @@ extern "C" void free(void* addr) if ( !IsGoodHeapPointer(addr, 1) || !IsGoodHeapPointer(chunk, sizeof(*chunk)) ) { - error(0, 0, "attempted to free(3) non-heap pointer: 0x%zx", addr); + error(0, 0, "attempted to free(3) non-heap pointer: %p", addr); abort(); } if ( !chunk->IsUsed() ) { error(0, 0, "attempted to free(3) area that doesn't appear to be " - "allocated: 0x%zx + 0x%zx", addr); + "allocated: %p + 0x%zx", chunk, chunk->size); abort(); } #endif diff --git a/utils/chvideomode.cpp b/utils/chvideomode.cpp index 46d77805..3ecaf42d 100644 --- a/utils/chvideomode.cpp +++ b/utils/chvideomode.cpp @@ -467,7 +467,7 @@ Try make sure the desired driver is loaded and is configured correctly.\n"); struct dispmsg_crtc_mode mode = modes[selection]; if ( !SetCurrentMode(mode) ) { - error(1, errno, "Unable to set video mode: %s", mode); + error(1, errno, "Unable to set video mode: %s", StringOfCrtcMode(mode)); } #endif if ( 1 < argc ) @@ -480,7 +480,7 @@ Try make sure the desired driver is loaded and is configured correctly.\n"); waitpid(childpid, &status, 0); if ( !SetCurrentMode(prevmode) ) { - error(1, errno, "Unable to restore video mode: %s", prevmode); + error(1, errno, "Unable to restore video mode: %s", StringOfCrtcMode(prevmode)); } exit(WEXITSTATUS(status)); } diff --git a/utils/find.cpp b/utils/find.cpp index a8d6c02f..58792184 100644 --- a/utils/find.cpp +++ b/utils/find.cpp @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) if ( arg[0] != '-' ) { if ( found_options ) - error(1, 0, "path `%s' must come before options"); + error(1, 0, "path `%s' must come before options", arg); if ( path ) error(1, 0, "multiple paths are not supported"); path = arg; diff --git a/utils/kill.cpp b/utils/kill.cpp index a1ba1753..524e5e99 100644 --- a/utils/kill.cpp +++ b/utils/kill.cpp @@ -20,12 +20,13 @@ *******************************************************************************/ -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include int usage() { @@ -52,7 +53,7 @@ int main(int argc, char* argv[]) pid_t pid = atoi(argv[i]); if ( kill(pid, signum) ) { - error(0, errno, "(%u)", pid); + error(0, errno, "(%ji)", (intmax_t) pid); result |= 1; } }