mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1766377 - Fix some sign-compare warnings by using ProcessId more consistently. r=nika,necko-reviewers,kershaw
dom/media/ipc/RDDProcessManager.cpp(320,21): error: comparison of integers of different signs: 'base::ProcessId' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] gpuProcessPid != -1 ? gpuProcessPid : base::GetCurrentProcId(); ~~~~~~~~~~~~~ ^ ~~ dom/media/ipc/RDDProcessManager.cpp(332,21): error: comparison of integers of different signs: 'base::ProcessId' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] if (gpuProcessPid != -1) { ~~~~~~~~~~~~~ ^ ~~ gfx/layers/ipc/SharedSurfacesParent.cpp(360,38): error: comparison of integers of different signs: 'base::ProcessId' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare] if (!gpm || gpm->GPUProcessPid() != -1) { ~~~~~~~~~~~~~~~~~~~~ ^ ~~ ipc/glue/MessageChannel.cpp(2145,13): error: comparison of integers of different signs: 'int32_t' (aka 'int') and 'const base::ProcessId' (aka 'const unsigned long') [-Werror,-Wsign-compare] if (pid != base::kInvalidProcessId && ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~ Differential Revision: https://phabricator.services.mozilla.com/D144688
This commit is contained in:
parent
490d5e355e
commit
af7d5859d7
@ -278,7 +278,7 @@ typename Transaction<Context>::IndexSet Transaction<Context>::Validate(
|
||||
// from this transaction, so we log the failed values we're going to revert.
|
||||
MOZ_LOG(Context::GetSyncLog(), LogLevel::Debug,
|
||||
("Transaction::PartialRevert(#%" PRIx64 ", pid %d): %s",
|
||||
aOwner->Id(), aSource ? aSource->OtherPid() : -1,
|
||||
aOwner->Id(), aSource ? aSource->OtherPid() : base::kInvalidProcessId,
|
||||
FormatTransaction<Context>(revertTxn.mModified, mValues,
|
||||
revertTxn.mValues)
|
||||
.get()));
|
||||
|
@ -127,7 +127,7 @@ RefPtr<GenericNonExclusivePromise> RDDProcessHost::LaunchPromise() {
|
||||
return mLaunchPromise;
|
||||
}
|
||||
|
||||
void RDDProcessHost::OnChannelConnected(int32_t peer_pid) {
|
||||
void RDDProcessHost::OnChannelConnected(base::ProcessId peer_pid) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
GeckoChildProcessHost::OnChannelConnected(peer_pid);
|
||||
|
@ -88,7 +88,7 @@ class RDDProcessHost final : public mozilla::ipc::GeckoChildProcessHost {
|
||||
TimeStamp GetLaunchTime() const { return mLaunchTime; }
|
||||
|
||||
// Called on the IO thread.
|
||||
void OnChannelConnected(int32_t peer_pid) override;
|
||||
void OnChannelConnected(base::ProcessId peer_pid) override;
|
||||
void OnChannelError() override;
|
||||
|
||||
void SetListener(Listener* aListener);
|
||||
|
@ -306,7 +306,8 @@ bool RDDProcessManager::CreateVideoBridge() {
|
||||
ipc::Endpoint<PVideoBridgeChild> childPipe;
|
||||
|
||||
GPUProcessManager* gpuManager = GPUProcessManager::Get();
|
||||
base::ProcessId gpuProcessPid = gpuManager ? gpuManager->GPUProcessPid() : -1;
|
||||
base::ProcessId gpuProcessPid =
|
||||
gpuManager ? gpuManager->GPUProcessPid() : base::kInvalidProcessId;
|
||||
|
||||
// Build content device data first; this ensure that the GPU process is fully
|
||||
// ready.
|
||||
@ -316,8 +317,9 @@ bool RDDProcessManager::CreateVideoBridge() {
|
||||
// The child end is the producer of video frames; the parent end is the
|
||||
// consumer.
|
||||
base::ProcessId childPid = RDDProcessPid();
|
||||
base::ProcessId parentPid =
|
||||
gpuProcessPid != -1 ? gpuProcessPid : base::GetCurrentProcId();
|
||||
base::ProcessId parentPid = gpuProcessPid != base::kInvalidProcessId
|
||||
? gpuProcessPid
|
||||
: base::GetCurrentProcId();
|
||||
|
||||
nsresult rv = PVideoBridge::CreateEndpoints(parentPid, childPid, &parentPipe,
|
||||
&childPipe);
|
||||
@ -329,7 +331,7 @@ bool RDDProcessManager::CreateVideoBridge() {
|
||||
|
||||
mRDDChild->SendInitVideoBridge(std::move(childPipe),
|
||||
mNumUnexpectedCrashes == 0, contentDeviceData);
|
||||
if (gpuProcessPid != -1) {
|
||||
if (gpuProcessPid != base::kInvalidProcessId) {
|
||||
gpuManager->InitVideoBridge(std::move(parentPipe));
|
||||
} else {
|
||||
VideoBridgeParent::Open(std::move(parentPipe),
|
||||
@ -341,7 +343,8 @@ bool RDDProcessManager::CreateVideoBridge() {
|
||||
|
||||
base::ProcessId RDDProcessManager::RDDProcessPid() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
base::ProcessId rddPid = mRDDChild ? mRDDChild->OtherPid() : -1;
|
||||
base::ProcessId rddPid =
|
||||
mRDDChild ? mRDDChild->OtherPid() : base::kInvalidProcessId;
|
||||
return rddPid;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ bool GPUProcessHost::WaitForLaunch() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void GPUProcessHost::OnChannelConnected(int32_t peer_pid) {
|
||||
void GPUProcessHost::OnChannelConnected(base::ProcessId peer_pid) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
GeckoChildProcessHost::OnChannelConnected(peer_pid);
|
||||
|
@ -100,7 +100,7 @@ class GPUProcessHost final : public mozilla::ipc::GeckoChildProcessHost {
|
||||
TimeStamp GetLaunchTime() const { return mLaunchTime; }
|
||||
|
||||
// Called on the IO thread.
|
||||
void OnChannelConnected(int32_t peer_pid) override;
|
||||
void OnChannelConnected(base::ProcessId peer_pid) override;
|
||||
void OnChannelError() override;
|
||||
|
||||
void SetListener(Listener* aListener);
|
||||
|
@ -1098,7 +1098,8 @@ bool GPUProcessManager::CreateContentImageBridge(
|
||||
}
|
||||
|
||||
base::ProcessId GPUProcessManager::GPUProcessPid() {
|
||||
base::ProcessId gpuPid = mGPUChild ? mGPUChild->OtherPid() : -1;
|
||||
base::ProcessId gpuPid =
|
||||
mGPUChild ? mGPUChild->OtherPid() : base::kInvalidProcessId;
|
||||
return gpuPid;
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ bool SharedSurfacesParent::AccumulateMemoryReport(
|
||||
SharedSurfacesMemoryReport& aReport) {
|
||||
if (XRE_IsParentProcess()) {
|
||||
GPUProcessManager* gpm = GPUProcessManager::Get();
|
||||
if (!gpm || gpm->GPUProcessPid() != -1) {
|
||||
if (!gpm || gpm->GPUProcessPid() != base::kInvalidProcessId) {
|
||||
return false;
|
||||
}
|
||||
} else if (!XRE_IsGPUProcess()) {
|
||||
|
@ -198,7 +198,7 @@ void VRProcessParent::OnChannelError() {
|
||||
MOZ_ASSERT(false, "VR process channel error.");
|
||||
}
|
||||
|
||||
void VRProcessParent::OnChannelConnected(int32_t peer_pid) {
|
||||
void VRProcessParent::OnChannelConnected(base::ProcessId peer_pid) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
GeckoChildProcessHost::OnChannelConnected(peer_pid);
|
||||
|
@ -49,7 +49,7 @@ class VRProcessParent final : public mozilla::ipc::GeckoChildProcessHost {
|
||||
bool CanShutdown() override { return true; }
|
||||
|
||||
void OnChannelError() override;
|
||||
void OnChannelConnected(int32_t peer_pid) override;
|
||||
void OnChannelConnected(base::ProcessId peer_pid) override;
|
||||
void OnChannelConnectedTask();
|
||||
void OnChannelErrorTask();
|
||||
void OnChannelClosed();
|
||||
|
@ -47,7 +47,8 @@ void ChildProcessHost::ListenerHook::OnMessageReceived(IPC::Message&& msg) {
|
||||
host_->OnMessageReceived(std::move(msg));
|
||||
}
|
||||
|
||||
void ChildProcessHost::ListenerHook::OnChannelConnected(int32_t peer_pid) {
|
||||
void ChildProcessHost::ListenerHook::OnChannelConnected(
|
||||
base::ProcessId peer_pid) {
|
||||
host_->opening_channel_ = false;
|
||||
host_->OnChannelConnected(peer_pid);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class ChildProcessHost : public IPC::Channel::Listener {
|
||||
|
||||
// IPC::Channel::Listener implementation:
|
||||
virtual void OnMessageReceived(IPC::Message&& msg) override {}
|
||||
virtual void OnChannelConnected(int32_t peer_pid) override {}
|
||||
virtual void OnChannelConnected(base::ProcessId peer_pid) override {}
|
||||
virtual void OnChannelError() override {}
|
||||
|
||||
bool opening_channel() { return opening_channel_; }
|
||||
@ -57,7 +57,7 @@ class ChildProcessHost : public IPC::Channel::Listener {
|
||||
public:
|
||||
explicit ListenerHook(ChildProcessHost* host);
|
||||
virtual void OnMessageReceived(IPC::Message&& msg) override;
|
||||
virtual void OnChannelConnected(int32_t peer_pid) override;
|
||||
virtual void OnChannelConnected(base::ProcessId peer_pid) override;
|
||||
virtual void OnChannelError() override;
|
||||
virtual void GetQueuedMessages(std::queue<IPC::Message>& queue) override;
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <cstdint>
|
||||
#include <queue>
|
||||
#include "base/basictypes.h"
|
||||
#include "base/process.h"
|
||||
#include "build/build_config.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
@ -60,7 +61,7 @@ class Channel {
|
||||
|
||||
// Called when the channel is connected and we have received the internal
|
||||
// Hello message from the peer.
|
||||
virtual void OnChannelConnected(int32_t peer_pid) {}
|
||||
virtual void OnChannelConnected(base::ProcessId peer_pid) {}
|
||||
|
||||
// Called when an error is detected that causes the channel to close.
|
||||
// This method is not called when a channel is closed normally.
|
||||
|
@ -16,7 +16,7 @@ void AddIPCProfilerMarker(const Message& aMessage, int32_t aOtherPid,
|
||||
mozilla::ipc::MessagePhase aPhase) {
|
||||
if (aMessage.routing_id() != MSG_ROUTING_NONE &&
|
||||
profiler_feature_active(ProfilerFeature::IPCMessages)) {
|
||||
if (aOtherPid == -1) {
|
||||
if (aOtherPid == base::kInvalidProcessId) {
|
||||
DLOG(WARNING) << "Unable to record IPC profile marker, other PID not set";
|
||||
return;
|
||||
}
|
||||
|
@ -1575,7 +1575,7 @@ bool GeckoChildProcessHost::OpenPrivilegedHandle(base::ProcessId aPid) {
|
||||
return base::OpenPrivilegedProcessHandle(aPid, &mChildProcessHandle);
|
||||
}
|
||||
|
||||
void GeckoChildProcessHost::OnChannelConnected(int32_t peer_pid) {
|
||||
void GeckoChildProcessHost::OnChannelConnected(base::ProcessId peer_pid) {
|
||||
if (!OpenPrivilegedHandle(peer_pid)) {
|
||||
MOZ_CRASH("can't open handle to child process");
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class GeckoChildProcessHost : public ChildProcessHost,
|
||||
bool SyncLaunch(StringVector aExtraOpts = StringVector(),
|
||||
int32_t timeoutMs = 0);
|
||||
|
||||
virtual void OnChannelConnected(int32_t peer_pid) override;
|
||||
virtual void OnChannelConnected(base::ProcessId peer_pid) override;
|
||||
virtual void OnMessageReceived(IPC::Message&& aMsg) override;
|
||||
virtual void OnChannelError() override;
|
||||
virtual void GetQueuedMessages(std::queue<IPC::Message>& queue) override;
|
||||
|
@ -2137,7 +2137,7 @@ void MessageChannel::AddProfilerMarker(const IPC::Message& aMessage,
|
||||
mMonitor->AssertCurrentThreadOwns();
|
||||
|
||||
if (profiler_feature_active(ProfilerFeature::IPCMessages)) {
|
||||
int32_t pid = mListener->OtherPidMaybeInvalid();
|
||||
base::ProcessId pid = mListener->OtherPidMaybeInvalid();
|
||||
// Only record markers for IPCs with a valid pid.
|
||||
// And if one of the profiler mutexes is locked on this thread, don't record
|
||||
// markers, because we don't want to expose profiler IPCs due to the
|
||||
|
@ -37,7 +37,7 @@ namespace mozilla::ipc {
|
||||
|
||||
NodeChannel::NodeChannel(const NodeName& aName,
|
||||
UniquePtr<IPC::Channel> aChannel, Listener* aListener,
|
||||
int32_t aPid)
|
||||
base::ProcessId aPid)
|
||||
: mListener(aListener),
|
||||
mName(aName),
|
||||
mOtherPid(aPid),
|
||||
@ -97,8 +97,8 @@ void NodeChannel::Start(bool aCallConnect) {
|
||||
}
|
||||
} else {
|
||||
// Check if our channel has already been connected, and knows the other PID.
|
||||
int32_t otherPid = mChannel->OtherPid();
|
||||
if (otherPid != -1) {
|
||||
base::ProcessId otherPid = mChannel->OtherPid();
|
||||
if (otherPid != base::kInvalidProcessId) {
|
||||
SetOtherPid(otherPid);
|
||||
}
|
||||
|
||||
@ -121,11 +121,11 @@ void NodeChannel::Close() {
|
||||
mClosed = true;
|
||||
}
|
||||
|
||||
void NodeChannel::SetOtherPid(int32_t aNewPid) {
|
||||
void NodeChannel::SetOtherPid(base::ProcessId aNewPid) {
|
||||
AssertIOThread();
|
||||
MOZ_ASSERT(aNewPid != -1);
|
||||
MOZ_ASSERT(aNewPid != base::kInvalidProcessId);
|
||||
|
||||
int32_t previousPid = -1;
|
||||
base::ProcessId previousPid = base::kInvalidProcessId;
|
||||
if (!mOtherPid.compare_exchange_strong(previousPid, aNewPid)) {
|
||||
// The PID was already set before this call, double-check that it's correct.
|
||||
MOZ_RELEASE_ASSERT(previousPid == aNewPid,
|
||||
@ -282,7 +282,7 @@ void NodeChannel::OnMessageReceived(IPC::Message&& aMessage) {
|
||||
OnChannelError();
|
||||
}
|
||||
|
||||
void NodeChannel::OnChannelConnected(int32_t aPeerPid) {
|
||||
void NodeChannel::OnChannelConnected(base::ProcessId aPeerPid) {
|
||||
AssertIOThread();
|
||||
|
||||
SetOtherPid(aPeerPid);
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "mojo/core/ports/node.h"
|
||||
#include "mojo/core/ports/node_delegate.h"
|
||||
#include "base/process.h"
|
||||
#include "chrome/common/ipc_message.h"
|
||||
#include "chrome/common/ipc_channel.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
@ -37,8 +38,8 @@ class NodeChannel final : public IPC::Channel::Listener {
|
||||
NodeName mName;
|
||||
IPC::Channel::ChannelHandle mHandle;
|
||||
IPC::Channel::Mode mMode;
|
||||
int32_t mMyPid = -1;
|
||||
int32_t mOtherPid = -1;
|
||||
base::ProcessId mMyPid = base::kInvalidProcessId;
|
||||
base::ProcessId mOtherPid = base::kInvalidProcessId;
|
||||
};
|
||||
|
||||
class Listener {
|
||||
@ -62,7 +63,7 @@ class NodeChannel final : public IPC::Channel::Listener {
|
||||
};
|
||||
|
||||
NodeChannel(const NodeName& aName, UniquePtr<IPC::Channel> aChannel,
|
||||
Listener* aListener, int32_t aPid = -1);
|
||||
Listener* aListener, base::ProcessId aPid = base::kInvalidProcessId);
|
||||
|
||||
// Send the given message over this peer channel link. May be called from any
|
||||
// thread.
|
||||
@ -82,7 +83,7 @@ class NodeChannel final : public IPC::Channel::Listener {
|
||||
void AcceptInvite(const NodeName& aRealName, const PortName& aInitialPort);
|
||||
|
||||
// The PID of the remote process, once known. May be called from any thread.
|
||||
int32_t OtherPid() const { return mOtherPid; }
|
||||
base::ProcessId OtherPid() const { return mOtherPid; }
|
||||
|
||||
// Start communicating with the remote process using this NodeChannel. MUST BE
|
||||
// CALLED FROM THE IO THREAD.
|
||||
@ -109,14 +110,14 @@ class NodeChannel final : public IPC::Channel::Listener {
|
||||
void FinalDestroy();
|
||||
|
||||
// Update the known PID for the remote process. IO THREAD ONLY
|
||||
void SetOtherPid(int32_t aNewPid);
|
||||
void SetOtherPid(base::ProcessId aNewPid);
|
||||
|
||||
void SendMessage(UniquePtr<IPC::Message> aMessage);
|
||||
void DoSendMessage(UniquePtr<IPC::Message> aMessage);
|
||||
|
||||
// IPC::Channel::Listener implementation
|
||||
void OnMessageReceived(IPC::Message&& aMessage) override;
|
||||
void OnChannelConnected(int32_t aPeerPid) override;
|
||||
void OnChannelConnected(base::ProcessId aPeerPid) override;
|
||||
void OnChannelError() override;
|
||||
|
||||
// NOTE: This strong reference will create a reference cycle between the
|
||||
@ -133,7 +134,7 @@ class NodeChannel final : public IPC::Channel::Listener {
|
||||
// NOTE: This won't change once the connection has been established, but may
|
||||
// be `-1` until then. This will only be written to on the IO thread, but may
|
||||
// be read from other threads.
|
||||
std::atomic<int32_t> mOtherPid;
|
||||
std::atomic<base::ProcessId> mOtherPid;
|
||||
|
||||
// WARNING: This must only be accessed on the IO thread.
|
||||
mozilla::UniquePtr<IPC::Channel> mChannel;
|
||||
|
@ -283,7 +283,7 @@ void NodeController::DropPeer(NodeName aNodeName) {
|
||||
|
||||
NODECONTROLLER_LOG(LogLevel::Info, "Dropping Peer %s (pid: %d)",
|
||||
ToString(aNodeName).c_str(),
|
||||
channel ? channel->OtherPid() : -1);
|
||||
channel ? channel->OtherPid() : base::kInvalidProcessId);
|
||||
|
||||
if (channel) {
|
||||
channel->Close();
|
||||
@ -670,7 +670,7 @@ void NodeController::OnRequestIntroduction(const NodeName& aFromNode,
|
||||
// an invalid introduction to content to clean up any pending outbound
|
||||
// messages.
|
||||
NodeChannel::Introduction intro{aName, nullptr, IPC::Channel::MODE_SERVER,
|
||||
peerA->OtherPid(), -1};
|
||||
peerA->OtherPid(), base::kInvalidProcessId};
|
||||
peerA->Introduce(std::move(intro));
|
||||
return;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ RefPtr<GenericNonExclusivePromise> UtilityProcessHost::LaunchPromise() {
|
||||
return mLaunchPromise;
|
||||
}
|
||||
|
||||
void UtilityProcessHost::OnChannelConnected(int32_t peer_pid) {
|
||||
void UtilityProcessHost::OnChannelConnected(base::ProcessId peer_pid) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
GeckoChildProcessHost::OnChannelConnected(peer_pid);
|
||||
|
@ -83,7 +83,7 @@ class UtilityProcessHost final : public mozilla::ipc::GeckoChildProcessHost {
|
||||
}
|
||||
|
||||
// Called on the IO thread.
|
||||
void OnChannelConnected(int32_t peer_pid) override;
|
||||
void OnChannelConnected(base::ProcessId peer_pid) override;
|
||||
void OnChannelError() override;
|
||||
|
||||
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
|
||||
|
@ -96,7 +96,7 @@ static void HandleErrorAfterDestroy(
|
||||
}));
|
||||
}
|
||||
|
||||
void SocketProcessHost::OnChannelConnected(int32_t peer_pid) {
|
||||
void SocketProcessHost::OnChannelConnected(base::ProcessId peer_pid) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
GeckoChildProcessHost::OnChannelConnected(peer_pid);
|
||||
|
@ -74,7 +74,7 @@ class SocketProcessHost final : public mozilla::ipc::GeckoChildProcessHost {
|
||||
}
|
||||
|
||||
// Called on the IO thread.
|
||||
void OnChannelConnected(int32_t peer_pid) override;
|
||||
void OnChannelConnected(base::ProcessId peer_pid) override;
|
||||
void OnChannelError() override;
|
||||
|
||||
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
|
||||
|
Loading…
Reference in New Issue
Block a user