diff --git a/core/include/dap_common.h b/core/include/dap_common.h index dff8c06c7d855d0d89e101bf092743f05f2eecb1..399c76fe0541aa3ffc828c1d3f8d68b93a44f49c 100755 --- a/core/include/dap_common.h +++ b/core/include/dap_common.h @@ -116,6 +116,22 @@ #define UNUSED_ARG __attribute__((__unused__)) +#ifndef likely +# if (defined(__GNUC__) || __has_builtin(__builtin_expect)) && !defined(__COVERITY__) +# define likely(cond) __builtin_expect(!!(cond), 1) +# else +# define likely(x) (!!(x)) +# endif +#endif /* likely */ + +#ifndef unlikely +# if (defined(__GNUC__) || __has_builtin(__builtin_expect)) && !defined(__COVERITY__) +# define unlikely(cond) __builtin_expect(!!(cond), 0) +# else +# define unlikely(x) (!!(x)) +# endif +#endif /* unlikely */ + #ifndef ROUNDUP #define ROUNDUP(n,width) (((n) + (width) - 1) & ~(unsigned)((width) - 1)) #endif @@ -932,4 +948,4 @@ DAP_STATIC_INLINE int dap_stream_node_addr_from_str(dap_stream_node_addr_t *a_ad DAP_STATIC_INLINE bool dap_stream_node_addr_is_blank(dap_stream_node_addr_t *a_addr) { return !a_addr->uint64; } -const char *dap_stream_node_addr_to_str_static(dap_stream_node_addr_t a_address); \ No newline at end of file +const char *dap_stream_node_addr_to_str_static(dap_stream_node_addr_t a_address); diff --git a/crypto/src/dap_cert.c b/crypto/src/dap_cert.c index 99bd8f1a43e4a46a658fc02681a934f9858d67be..b16588a2590bdc686a20cc558f2d3fbbcab4aab6 100755 --- a/crypto/src/dap_cert.c +++ b/crypto/src/dap_cert.c @@ -390,7 +390,7 @@ int dap_cert_add(dap_cert_t *a_cert) { if (!a_cert) return -2; - dap_cert_item_t *l_cert_item; + dap_cert_item_t *l_cert_item = NULL; HASH_FIND_STR(s_certs, a_cert->name, l_cert_item); if (l_cert_item) { log_it(L_WARNING, "Certificate with name %s already present in memory", a_cert->name); diff --git a/global-db/dap_global_db_driver_mdbx.c b/global-db/dap_global_db_driver_mdbx.c index 27e8ddbd9412f58a36a23475074119b0ddfbb980..ce97afc29b90bc1235c9df06fd451412f0a7ffbc 100644 --- a/global-db/dap_global_db_driver_mdbx.c +++ b/global-db/dap_global_db_driver_mdbx.c @@ -213,7 +213,7 @@ char l_buf[1024] = {0}; static dap_db_ctx_t *s_cre_db_ctx_for_group(const char *a_group, int a_flags, MDBX_txn *a_txn) { int rc; -dap_db_ctx_t *l_db_ctx; +dap_db_ctx_t *l_db_ctx = NULL; size_t l_name_len; MDBX_val l_key_iov, l_data_iov; diff --git a/io/dap_events_socket.c b/io/dap_events_socket.c index e66c5e3fb5a215cdacf7b3bf06ae69d81317b021..68de372275f0b6c85d36b8f7ce5dbcb42120fbf7 100644 --- a/io/dap_events_socket.c +++ b/io/dap_events_socket.c @@ -263,7 +263,7 @@ static inline void s_dap_evsock_free(dap_events_socket_t *a_es) { #ifdef DAP_SYS_DEBUG pthread_rwlock_wrlock(&s_evsocks_lock); - dap_events_socket_t *l_es; + dap_events_socket_t *l_es = NULL; HASH_FIND(hh2, s_esockets, &a_es->uuid, sizeof(l_es->uuid), l_es); if (l_es) HASH_DELETE(hh2, s_esockets, l_es); /* Remove record from the table */ diff --git a/net/server/http_server/http_client/dap_http_client.c b/net/server/http_server/http_client/dap_http_client.c index 0b9df07c97468cf0d2a26605913d4a69b381aec7..0d0c89bdbb7b7ff9046002d84e6c65cb76716794 100644 --- a/net/server/http_server/http_client/dap_http_client.c +++ b/net/server/http_server/http_client/dap_http_client.c @@ -317,7 +317,7 @@ void dap_http_client_read( dap_events_socket_t *a_esocket, void *a_arg ) size_t read_bytes = 0; dap_http_client_t *l_http_client = DAP_HTTP_CLIENT( a_esocket ); - dap_http_url_proc_t *url_proc; + dap_http_url_proc_t *url_proc = NULL; dap_http_cache_t * l_http_cache; /* diff --git a/net/server/json_rpc/rpc_core/src/dap_json_rpc_notification.c b/net/server/json_rpc/rpc_core/src/dap_json_rpc_notification.c index 33ce7326535b3cc073354269e2c666372590cb81..8b3cfc925143ead7c61b166ca21c4af5128f27b0 100644 --- a/net/server/json_rpc/rpc_core/src/dap_json_rpc_notification.c +++ b/net/server/json_rpc/rpc_core/src/dap_json_rpc_notification.c @@ -7,7 +7,7 @@ static dap_json_rpc_notification_handler_t *s_handler_notifications = NULL; int dap_json_rpc_notification_registration(const char *a_method, notification_handler_func_t *a_notification_func) { - dap_json_rpc_notification_handler_t *l_handler; + dap_json_rpc_notification_handler_t *l_handler = NULL; HASH_FIND_STR(s_handler_notifications, a_method, l_handler); if (l_handler == 0){ l_handler = DAP_NEW(dap_json_rpc_notification_handler_t); @@ -25,7 +25,7 @@ int dap_json_rpc_notification_registration(const char *a_method, notification_ha } void dap_json_rpc_notification_unregistration(const char *a_method) { - dap_json_rpc_notification_handler_t *l_handler; + dap_json_rpc_notification_handler_t *l_handler = NULL; HASH_FIND_STR(s_handler_notifications, a_method, l_handler); if (l_handler != NULL){ HASH_DEL(s_handler_notifications, l_handler); diff --git a/net/server/json_rpc/rpc_core/src/dap_json_rpc_request_handler.c b/net/server/json_rpc/rpc_core/src/dap_json_rpc_request_handler.c index 0a4b2c89f3129ca8460dbf7f2f8c256e00445679..6bedaea61826a8c872f1286768cef861ace531e0 100644 --- a/net/server/json_rpc/rpc_core/src/dap_json_rpc_request_handler.c +++ b/net/server/json_rpc/rpc_core/src/dap_json_rpc_request_handler.c @@ -6,7 +6,7 @@ static dap_json_rpc_request_handler_t *s_handler_hash_table = NULL; int dap_json_rpc_registration_request_handler(const char *a_name, handler_func_t *a_func) { - dap_json_rpc_request_handler_t *l_handler; + dap_json_rpc_request_handler_t *l_handler = NULL; HASH_FIND_STR(s_handler_hash_table, a_name, l_handler); if (l_handler == NULL){ l_handler = DAP_NEW(dap_json_rpc_request_handler_t); @@ -24,7 +24,7 @@ int dap_json_rpc_registration_request_handler(const char *a_name, handler_func_t } int dap_json_rpc_unregistration_request_handler(const char *a_name) { - dap_json_rpc_request_handler_t *l_handler; + dap_json_rpc_request_handler_t *l_handler = NULL; HASH_FIND_STR(s_handler_hash_table, a_name, l_handler); if (l_handler == NULL){ return 1; diff --git a/net/server/notify_server/src/dap_notify_srv.c b/net/server/notify_server/src/dap_notify_srv.c index 24db569582216487d536ce1ee35f9aa876e00dbe..6f305a9ae671d9579e0fa750d5c36ee05410a45b 100644 --- a/net/server/notify_server/src/dap_notify_srv.c +++ b/net/server/notify_server/src/dap_notify_srv.c @@ -221,7 +221,7 @@ static void s_notify_server_callback_queue(dap_events_socket_t * a_es, void * a_ */ static void s_notify_server_callback_new(dap_events_socket_t * a_es, UNUSED_ARG void *a_arg) { - dap_events_socket_handler_hh_t * l_hh_new; + dap_events_socket_handler_hh_t *l_hh_new = NULL; pthread_rwlock_wrlock(&s_notify_server_clients_mutex); HASH_FIND(hh,s_notify_server_clients, &a_es->uuid, sizeof (a_es->uuid), l_hh_new); if (l_hh_new){ diff --git a/net/stream/session/dap_stream_session.c b/net/stream/session/dap_stream_session.c index 7a7aadda875a10d235baa46be095ebc706161bea..42b187d8cacee7007f9c8853fee387d4e485bb1c 100644 --- a/net/stream/session/dap_stream_session.c +++ b/net/stream/session/dap_stream_session.c @@ -97,7 +97,7 @@ void dap_stream_session_get_list_sessions_unlock(void) dap_stream_session_t * dap_stream_session_pure_new() { -dap_stream_session_t *l_stm_sess, *l_stm_tmp; +dap_stream_session_t *l_stm_sess, *l_stm_tmp = NULL; uint32_t session_id = 0; if ( !(l_stm_sess = DAP_NEW_Z(dap_stream_session_t)) ) /* Preallocate new session context */ @@ -159,7 +159,7 @@ dap_stream_session_t *dap_stream_session_id_mt(uint32_t a_id) */ dap_stream_session_t *dap_stream_session_id_unsafe(uint32_t id ) { - dap_stream_session_t *ret; + dap_stream_session_t *ret = NULL; HASH_FIND(hh, s_sessions, &id, sizeof(uint32_t), ret); return ret; } diff --git a/net/stream/stream/dap_stream.c b/net/stream/stream/dap_stream.c index d0231d84332e6e70fc5f21260145e75adb9c6f99..72d03b551c73b2f17b1f262bb4916518aab4e1fc 100644 --- a/net/stream/stream/dap_stream.c +++ b/net/stream/stream/dap_stream.c @@ -1177,7 +1177,7 @@ dap_stream_info_t *dap_stream_get_links_info(dap_cluster_t *a_cluster, size_t *a log_it(L_CRITICAL, "! Attempt to aquire streams lock recursively !"); return NULL; } - dap_stream_t *it; + dap_stream_t *it = NULL; size_t l_streams_count = 0, i = 0; if (a_cluster) { pthread_rwlock_rdlock(&a_cluster->members_lock); diff --git a/plugin/src/dap_plugin_manifest.c b/plugin/src/dap_plugin_manifest.c index dc30027449ba1aecab371a1dd987662e7b43de01..6625a17eb2b9bf47b4a6e32e1da573397c758cad 100644 --- a/plugin/src/dap_plugin_manifest.c +++ b/plugin/src/dap_plugin_manifest.c @@ -268,7 +268,7 @@ dap_plugin_manifest_t* dap_plugin_manifest_all() */ dap_plugin_manifest_t *dap_plugin_manifest_find(const char *a_name) { - dap_plugin_manifest_t *l_ret; + dap_plugin_manifest_t *l_ret = NULL; HASH_FIND_STR(s_manifests,a_name,l_ret); return l_ret; } @@ -327,7 +327,7 @@ static void s_manifest_delete(dap_plugin_manifest_t *a_manifest) */ bool dap_plugins_manifest_remove(const char *a_name) { - dap_plugin_manifest_t *l_manifest; + dap_plugin_manifest_t *l_manifest = NULL; HASH_FIND_STR(s_manifests, a_name,l_manifest); if(l_manifest) HASH_DEL(s_manifests, l_manifest);