Merge pull request !1285 from cheng_jinsong/newcodex
This commit is contained in:
openharmony_ci 2022-09-23 07:03:59 +00:00 committed by Gitee
commit 1fe58187be
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 15 additions and 17 deletions

View File

@ -261,16 +261,20 @@ void WatcherManagerKits::ParameterChangeListener::OnParameterChange(const std::s
} // namespace init_param
} // namespace OHOS
static int ParameterWatcherCheck(const char *keyPrefix)
{
std::string key(keyPrefix);
if (key.rfind("*") == key.length() - 1) {
return WatchParamCheck(key.substr(0, key.length() - 1).c_str());
} else {
return WatchParamCheck(keyPrefix);
}
}
int SystemWatchParameter(const char *keyPrefix, ParameterChangePtr callback, void *context)
{
WATCHER_CHECK(keyPrefix != nullptr, return PARAM_CODE_INVALID_PARAM, "Invalid prefix");
int ret = 0;
std::string key(keyPrefix);
if (key.rfind("*") == key.length() - 1) {
ret = WatchParamCheck(key.substr(0, key.length() - 1).c_str());
} else {
ret = WatchParamCheck(keyPrefix);
}
int ret = ParameterWatcherCheck(keyPrefix);
if (ret != 0) {
return ret;
}
@ -286,13 +290,7 @@ int SystemWatchParameter(const char *keyPrefix, ParameterChangePtr callback, voi
int RemoveParameterWatcher(const char *keyPrefix, ParameterChgPtr callback, void *context)
{
WATCHER_CHECK(keyPrefix != nullptr, return PARAM_CODE_INVALID_PARAM, "Invalid prefix");
int ret = 0;
std::string key(keyPrefix);
if (key.rfind("*") == key.length() - 1) {
ret = WatchParamCheck(key.substr(0, key.length() - 1).c_str());
} else {
ret = WatchParamCheck(keyPrefix);
}
int ret = ParameterWatcherCheck(keyPrefix);
if (ret != 0) {
return ret;
}

View File

@ -75,7 +75,7 @@ static void TestHashNodeFree(const HashNode *node)
static TestHashNode *TestCreateHashNode(const char *value)
{
TestHashNode *node = (TestHashNode *)malloc(sizeof(TestHashNode) + strlen(value) + 1);
TestHashNode *node = reinterpret_cast<TestHashNode *>(malloc(sizeof(TestHashNode) + strlen(value) + 1));
if (node == nullptr) {
return nullptr;
}

View File

@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef PARAM_TEST_STUB_
#define PARAM_TEST_STUB_
#ifndef PARAM_TEST_STUB
#define PARAM_TEST_STUB
#include <cstdio>
#include <cstdlib>
#include <cstring>