[webkit-dev] Reminder regarding formatting uint64_t

Simon Fraser simon.fraser at apple.com
Wed Feb 27 15:03:04 PST 2019


Or use LOG_WITH_STREAM() where I presume << pageID() << does the right thing.

We’d need some new RELEASE_LOG_ macros for that.

Simon

> On Feb 27, 2019, at 2:47 PM, Ryosuke Niwa <rniwa at webkit.org> wrote:
> 
> We should probably stop using these formatting strings in favor of makeString by making *LOG* functions to use makeString behind the scene.
> 
> See https://trac.webkit.org/changeset/242014 <https://trac.webkit.org/changeset/242014> for example.
> 
> - R. Niwa
> 
> On Wed, Feb 27, 2019 at 2:36 PM Michael Catanzaro <mcatanzaro at igalia.com <mailto:mcatanzaro at igalia.com>> wrote:
> Hi,
> 
> For the past several years, I've been regularly fixing -Wformat 
> warnings that look like this:
> 
> ../../Source/WebKit/WebProcess/WebPage/WebPage.cpp:3148:46: warning: 
> format ‘%llu’ expects argument of type ‘long long unsigned 
> int’, but argument 6 has type ‘uint64_t’ {aka ‘long unsigned 
> int’} [-Wformat=]
>          RELEASE_LOG_ERROR(ProcessSuspension, "%p - WebPage 
> (PageID=%llu) - LayerTreeFreezeReason::ProcessSuspended was set when 
> removing LayerTreeFreezeReason::PageTransition; current reasons are %d",
> 
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>              this, m_pageID, m_LayerTreeFreezeReasons.toRaw());
>                    ~~~~~~~~
> 
> Problem is that uint64_t is long long unsigned int on Mac, but only 
> long unsigned int on Linux. It can't be printed with %llu, so please 
> use PRIu64 instead. E.g.:
> 
> LOG("%llu", pageID); // wrong
> LOG("%" PRIu64, pageID); // correct
> 
> This is good to keep in mind for any sized integer types, but uint64_t 
> in particular since this is what causes problems for us in practice.
> 
> Thanks,
> 
> Michael
> 
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org <mailto:webkit-dev at lists.webkit.org>
> https://lists.webkit.org/mailman/listinfo/webkit-dev <https://lists.webkit.org/mailman/listinfo/webkit-dev>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20190227/9e60e54c/attachment.html>


More information about the webkit-dev mailing list