Bug 193441 - [JSC] printf-type mishap
Summary: [JSC] printf-type mishap
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Claudio Saavedra
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-01-15 03:32 PST by Claudio Saavedra
Modified: 2019-01-16 00:08 PST (History)
6 users (show)

See Also:


Attachments
Patch (1.36 KB, patch)
2019-01-15 03:38 PST, Claudio Saavedra
saam: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Claudio Saavedra 2019-01-15 03:32:45 PST
[2/1678] Building CXX object Source/JavaScriptCore/shell/CMakeFiles/jsc.dir/__/jsc.cpp.o
../../Source/JavaScriptCore/jsc.cpp: In function ‘int jscmain(int, char**)’:
../../Source/JavaScriptCore/jsc.cpp:2941:16: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
         printf("Memory Footprint:\n    Current Footprint: %llu\n    Peak Footprint: %llu\n", footprint.current, footprint.peak);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~
../../Source/JavaScriptCore/jsc.cpp:2941:16: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
Comment 1 Claudio Saavedra 2019-01-15 03:38:48 PST
Created attachment 359151 [details]
Patch
Comment 2 Saam Barati 2019-01-15 14:46:19 PST
Comment on attachment 359151 [details]
Patch

This doesn't seem to build. Isn't there something for size_t?
Comment 3 Mark Lam 2019-01-15 17:22:06 PST
Comment on attachment 359151 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=359151&action=review

> Source/JavaScriptCore/jsc.cpp:2941
> -        printf("Memory Footprint:\n    Current Footprint: %llu\n    Peak Footprint: %llu\n", footprint.current, footprint.peak);
> +        printf("Memory Footprint:\n    Current Footprint: %lu\n    Peak Footprint: %lu\n", footprint.current, footprint.peak);

Saam is correct.  You made this work for 32-bit builds but broke 64-bit builds.  Instead, you should use size_t like so:

    printf("Memory Footprint:\n Current Footprint: %zu\n Peak Footprint: %zu\n", static_cast<size_t>(footprint.current), static_cast<size_t>(footprint.peak));
Comment 4 Claudio Saavedra 2019-01-16 00:07:27 PST
Tomas Popela already pushed a fix in https://trac.webkit.org/changeset/239981/webkit.
Comment 5 Radar WebKit Bug Importer 2019-01-16 00:08:31 PST
<rdar://problem/47309674>