Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: format specifies type 'ssize_t' (aka 'long') but the argument has type 'off_t' (aka 'long long') #200

Closed
cmoad opened this issue Apr 9, 2018 · 3 comments

Comments

@cmoad
Copy link
Contributor

cmoad commented Apr 9, 2018

I am getting the following errors in master. Changing the formatters to %ll fixes the problem. Any ideas why I am seeing this? OS 10.13.4

☁  hyperkit [master] make -j4
cc src/lib/firmware/bootrom.c
src/lib/firmware/bootrom.c:95:49: error: format specifies type 'ssize_t' (aka 'long') but the argument has type 'off_t' (aka 'long long')
      [-Werror,-Wformat]
                fprintf(stderr, "Invalid bootrom size %zd\n", sbuf.st_size);
                                                      ~~~     ^~~~~~~~~~~~
                                                      %lld
src/lib/firmware/bootrom.c:101:22: error: format specifies type 'ssize_t' (aka 'long') but the argument has type 'off_t' (aka 'long long')
      [-Werror,-Wformat]
                    "page size\n", sbuf.st_size);
                                   ^~~~~~~~~~~~
src/lib/firmware/bootrom.c:112:4: error: format specifies type 'ssize_t' (aka 'long') but the argument has type 'off_t' (aka 'long long')
      [-Werror,-Wformat]
                        sbuf.st_size);
                        ^~~~~~~~~~~~
3 errors generated.
make: *** [build/lib/firmware/bootrom.o] Error 1
diff --git a/src/lib/firmware/bootrom.c b/src/lib/firmware/bootrom.c
index 02cdecd..3ae2b6a 100644
--- a/src/lib/firmware/bootrom.c
+++ b/src/lib/firmware/bootrom.c
@@ -92,12 +92,12 @@ uint64_t bootrom_load(void)
         * MMIO space (e.g. APIC, HPET, MSI).
         */
        if (sbuf.st_size > MAX_BOOTROM_SIZE || sbuf.st_size < XHYVE_PAGE_SIZE) {
-               fprintf(stderr, "Invalid bootrom size %zd\n", sbuf.st_size);
+               fprintf(stderr, "Invalid bootrom size %lld\n", sbuf.st_size);
                goto done;
        }

        if (sbuf.st_size & XHYVE_PAGE_MASK) {
-               fprintf(stderr, "Bootrom size %zd is not a multiple of the "
+               fprintf(stderr, "Bootrom size %lld is not a multiple of the "
                    "page size\n", sbuf.st_size);
                goto done;
        }
@@ -108,7 +108,7 @@ uint64_t bootrom_load(void)
        ptr = vmm_mem_alloc(gpa, (size_t)sbuf.st_size);
        if (!ptr) {
                fprintf(stderr,
-                       "Failed to allocate %zd bytes of memory for bootrom\n",
+                       "Failed to allocate %lld bytes of memory for bootrom\n",
                        sbuf.st_size);
                rv = -1;
                goto done;
@ijc
Copy link
Collaborator

ijc commented Apr 9, 2018

Please do raise a PR.

Using %lld is probably the least bad option but please also cast the variables with (long long) to eliminate any possible mismatch.

Unclear why you are the only one seeing this so far, might be a more (or less) up to date clang in your toolchain or some CFLAG thing turning on long offsets. Seems a bit odd for ssize_t and off_t to have such different underlying type magnitudes, but oh well.

@akimd
Copy link
Contributor

akimd commented Apr 10, 2018

The diagnostic is new in clang 6.

@jshaw86
Copy link

jshaw86 commented Jul 6, 2018

I'm still getting this issue on OSX 10.13.5 and

cc --version
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

installing latest hyperkit

rn added a commit to rn/hyperkit that referenced this issue Dec 5, 2020
macOS Big Sur seems to have introduced their own version of
these functions. Use an _ to pick up our version of these
functions.

This is based on b7e589f91e68 ("Support Big Sur (moby#200)")
from https://github.com/machyve/xhyve

Signed-off-by: Rolf Neugebauer <[email protected]>
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

No branches or pull requests

4 participants