From: Glenn Kasten Date: Mon, 30 Jan 2012 18:15:48 +0000 (-0800) Subject: Fix const sp<>& in parameter list and return value X-Git-Tag: android-x86-4.4-r1~1579^2~242^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=435dbe6c3ecd04bcb4bd80584064e287ebccd720;p=android-x86%2Fframeworks-av.git Fix const sp<>& in parameter list and return value EffectModule::addHandle and Client::heap() were declared incorrectly. As a parameter, an sp<> should be & for efficiency, and for input parameters it should also be const to protect the caller's value. But as a return value, an sp<> should have neither const or &. The "e" in "return e;" might be located on the stack, and if there is "&" then the caller would see the address of a variable which no longer exists. Also, an & would make it hard to do "return 0;". A "const" without & is meaningless in the return type. (In this particular case, the "e" is a member field, so it was safe.) Change-Id: I3df5f294214eb15a9d4d596c6d5ef29de97b5c27 --- diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 2d856ada40..518550c142 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -4065,7 +4065,7 @@ AudioFlinger::Client::~Client() mAudioFlinger->removeClient_l(mPid); } -const sp& AudioFlinger::Client::heap() const +sp AudioFlinger::Client::heap() const { return mMemoryDealer; } @@ -6179,7 +6179,7 @@ AudioFlinger::EffectModule::~EffectModule() } } -status_t AudioFlinger::EffectModule::addHandle(sp& handle) +status_t AudioFlinger::EffectModule::addHandle(const sp& handle) { status_t status; diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index 766ba44343..ece4ba2fdb 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -226,7 +226,7 @@ private: public: Client(const sp& audioFlinger, pid_t pid); virtual ~Client(); - const sp& heap() const; + sp heap() const; pid_t pid() const { return mPid; } sp audioFlinger() { return mAudioFlinger; } @@ -1107,7 +1107,7 @@ private: void setThread(const wp& thread) { mThread = thread; } wp& thread() { return mThread; } - status_t addHandle(sp& handle); + status_t addHandle(const sp& handle); void disconnect(const wp& handle, bool unpiniflast); size_t removeHandle (const wp& handle);