Skip to content

Commit

Permalink
ProcessThrottler.cpp: error: format specifies type 'unsigned int' but…
Browse files Browse the repository at this point in the history
… the argument has type 'ProcessAssertionType' [-Werror,-Wformat]

https://bugs.webkit.org/show_bug.cgi?id=259314
<rdar://111551983>

Reviewed by Chris Dumez.

* Source/WebKit/UIProcess/ProcessAssertion.h:
(WebKit::ProcessAssertionType): Make enum class use uint8_t.

* Source/WebKit/UIProcess/ProcessThrottler.cpp:
(WebKit::ProcessThrottler::setThrottleState):
- Use WTF::enumToUnderlyingType() to convert the enum value to its
  underlying type for logging to fix the compiler error.

Canonical link: https://commits.webkit.org/266142@main
  • Loading branch information
David Kilzer authored and ddkilzer committed Jul 18, 2023
1 parent bbe7d4f commit 190a527
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/ProcessAssertion.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ OBJC_CLASS WKRBSAssertionDelegate;

namespace WebKit {

enum class ProcessAssertionType {
enum class ProcessAssertionType : uint8_t {
NearSuspended,
Background,
UnboundedNetworking,
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit/UIProcess/ProcessThrottler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "ProcessThrottlerClient.h"
#include <optional>
#include <wtf/CompletionHandler.h>
#include <wtf/EnumTraits.h>
#include <wtf/text/TextStream.h>

#if PLATFORM(COCOA)
Expand Down Expand Up @@ -183,7 +184,7 @@ void ProcessThrottler::setThrottleState(ProcessThrottleState newState)
if (m_assertion && m_assertion->isValid() && m_assertion->type() == newType)
return;

PROCESSTHROTTLER_RELEASE_LOG("setThrottleState: Updating process assertion type to %u (foregroundActivities=%u, backgroundActivities=%u)", newType, m_foregroundActivities.size(), m_backgroundActivities.size());
PROCESSTHROTTLER_RELEASE_LOG("setThrottleState: Updating process assertion type to %u (foregroundActivities=%u, backgroundActivities=%u)", WTF::enumToUnderlyingType(newType), m_foregroundActivities.size(), m_backgroundActivities.size());

// Keep the previous assertion active until the new assertion is taken asynchronously.
auto previousAssertion = std::exchange(m_assertion, nullptr);
Expand Down

0 comments on commit 190a527

Please sign in to comment.