Merge pull request #507 from eeff/eeff/fix

fix: string equality comparison using strcmp
This commit is contained in:
fengzeroz
2022-05-25 10:52:53 +08:00
committed by GitHub
5 changed files with 29 additions and 32 deletions
+3 -4
View File
@@ -1894,8 +1894,7 @@ int neu_adapter_start(neu_adapter_t *adapter)
switch (adapter->state) {
case ADAPTER_STATE_IDLE:
case ADAPTER_STATE_INIT:
if (strncmp(adapter->plugin_info.module->module_name, "ekuiper",
strlen("ekuiper")) != 0) {
if (strcmp(adapter->plugin_info.module->module_name, "ekuiper") != 0) {
error = NEU_ERR_NODE_NOT_READY;
}
break;
@@ -2084,7 +2083,7 @@ void neu_adapter_add_sub_grp_config(neu_adapter_t * adapter,
neu_sub_grp_config_t *sgc =
(neu_sub_grp_config_t *) iterator_get(&iter);
if (sgc->node_id == node_id &&
strncmp(name, sgc->group_config_name, strlen(name)) == 0) {
strcmp(name, sgc->group_config_name) == 0) {
find = true;
break;
}
@@ -2114,7 +2113,7 @@ void neu_adapter_del_sub_grp_config(neu_adapter_t * adapter,
neu_sub_grp_config_t *sgc =
(neu_sub_grp_config_t *) iterator_get(&iter);
if (sgc->node_id == node_id &&
strncmp(name, sgc->group_config_name, strlen(name)) == 0) {
strcmp(name, sgc->group_config_name) == 0) {
iterator_erase(&adapter->sub_grp_configs, &iter);
break;
+22 -22
View File
@@ -28,27 +28,27 @@
#define NEU_SELF_NODE_NAME_UNKNOWN "unknown-adapter"
#define PLUGIN_CALL_CMD(plugin, type, req_buff, resp_struct, func) \
{ \
neu_request_t cmd = { 0 }; \
neu_response_t * result = NULL; \
neu_plugin_common_t *plugin_common = \
neu_plugin_to_plugin_common(plugin); \
cmd.req_type = (type); \
cmd.req_id = neu_plugin_get_event_id(plugin); \
cmd.buf = (void *) &(req_buff); \
cmd.buf_len = sizeof(req_buff); \
if (plugin_common->adapter_callbacks->command( \
plugin_common->adapter, &(cmd), &(result)) == 0) { \
assert((result)->buf_len == sizeof(resp_struct)); \
resp_struct *resp = NULL; \
resp = (resp_struct *) (result)->buf; \
{ func }; \
if (strncmp("intptr_t", #resp_struct, strlen("intptr_t")) != 0) { \
free(resp); \
} \
free(result); \
} \
#define PLUGIN_CALL_CMD(plugin, type, req_buff, resp_struct, func) \
{ \
neu_request_t cmd = { 0 }; \
neu_response_t * result = NULL; \
neu_plugin_common_t *plugin_common = \
neu_plugin_to_plugin_common(plugin); \
cmd.req_type = (type); \
cmd.req_id = neu_plugin_get_event_id(plugin); \
cmd.buf = (void *) &(req_buff); \
cmd.buf_len = sizeof(req_buff); \
if (plugin_common->adapter_callbacks->command( \
plugin_common->adapter, &(cmd), &(result)) == 0) { \
assert((result)->buf_len == sizeof(resp_struct)); \
resp_struct *resp = NULL; \
resp = (resp_struct *) (result)->buf; \
{ func }; \
if (strcmp("intptr_t", #resp_struct) != 0) { \
free(resp); \
} \
free(result); \
} \
}
#define PLUGIN_SEND_CMD(plugin, type, req_buff, event_id) \
@@ -490,7 +490,7 @@ neu_taggrp_config_t *neu_system_ref_group_config(neu_plugin_t *plugin,
{
neu_taggrp_config_t *config =
*(neu_taggrp_config_t **) iterator_get(&iter);
if (strncmp(neu_taggrp_cfg_get_name(config), name, strlen(name)) == 0) {
if (strcmp(neu_taggrp_cfg_get_name(config), name) == 0) {
find_config = config;
break;
}
+2 -3
View File
@@ -850,9 +850,8 @@ static void manager_loop(void *arg)
log_info("Reply pong to pipe: %d", msg_pipe);
nng_sendmsg(manager_bind->mng_sock, out_msg, 0);
}
if (0 ==
strncmp(DEFAULT_PERSIST_ADAPTER_NAME, buf_ptr,
msg_get_buf_len(pay_msg))) {
// buf_ptr contains NULL terminated adapter name
if (0 == strcmp(DEFAULT_PERSIST_ADAPTER_NAME, buf_ptr)) {
msg_size = msg_inplace_data_get_size(0);
rv = nng_msg_alloc(&out_msg, msg_size);
message_t *msg_ptr = (message_t *) nng_msg_body(out_msg);
+1 -1
View File
@@ -53,7 +53,7 @@ static inline bool ends_with(const char *str, const char *suffix)
{
size_t m = strlen(str);
size_t n = strlen(suffix);
return m >= n && !strncmp(str + m - n, suffix, n);
return m >= n && !strcmp(str + m - n, suffix);
}
typedef struct neu_persister {
+1 -2
View File
@@ -109,8 +109,7 @@ int neu_jwt_init(char *dir_path)
continue;
}
if (strncmp("neuron.key", (char *) ptr->d_name, strlen("neuron.key")) ==
0) {
if (strcmp("neuron.key", (char *) ptr->d_name) == 0) {
content = load_key(dir_path, (char *) ptr->d_name);
assert(content != NULL);