未验证 提交 1fe58187 编写于 作者: O openharmony_ci 提交者: Gitee

!1285 newcodex

Merge pull request !1285 from cheng_jinsong/newcodex
......@@ -261,16 +261,20 @@ void WatcherManagerKits::ParameterChangeListener::OnParameterChange(const std::s
} // namespace init_param
} // namespace OHOS
int SystemWatchParameter(const char *keyPrefix, ParameterChangePtr callback, void *context)
static int ParameterWatcherCheck(const char *keyPrefix)
{
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());
return WatchParamCheck(key.substr(0, key.length() - 1).c_str());
} else {
ret = WatchParamCheck(keyPrefix);
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 = 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;
}
......
......@@ -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;
}
......
......@@ -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>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册