[sr-dev] git:master:b9b177cc: db_redis: var initialization and safety check to avoid compiler warnings

Daniel-Constantin Mierla miconda at gmail.com
Thu Apr 23 10:22:14 CEST 2020


Module: kamailio
Branch: master
Commit: b9b177ccffd58b11cf460764514486d29637dd55
URL: https://github.com/kamailio/kamailio/commit/b9b177ccffd58b11cf460764514486d29637dd55

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-04-23T09:57:05+02:00

db_redis: var initialization and safety check to avoid compiler warnings

---

Modified: src/modules/db_redis/redis_table.c

---

Diff:  https://github.com/kamailio/kamailio/commit/b9b177ccffd58b11cf460764514486d29637dd55.diff
Patch: https://github.com/kamailio/kamailio/commit/b9b177ccffd58b11cf460764514486d29637dd55.patch

---

diff --git a/src/modules/db_redis/redis_table.c b/src/modules/db_redis/redis_table.c
index 4bed4e1c6d..a35e7dc786 100644
--- a/src/modules/db_redis/redis_table.c
+++ b/src/modules/db_redis/redis_table.c
@@ -491,7 +491,7 @@ int db_redis_parse_keys(km_redis_con_t *con) {
     char *start;
     char *end;
 
-    str table_name;
+    str table_name = str_init("");
     str type_name;
     str column_name;
     str version_code;
@@ -550,7 +550,8 @@ int db_redis_parse_keys(km_redis_con_t *con) {
 
                 table_entry = str_hash_get(&con->tables, table_name.s, table_name.len);
                 if (!table_entry) {
-                    LM_ERR("No table schema found for table '%.*s', fix config by adding one to the 'schema' mod-param!\n",
+                    LM_ERR("No table schema found for table '%.*s', fix config"
+                    		" by adding one to the 'schema' mod-param!\n",
                             table_name.len, table_name.s);
                     goto err;
                 }
@@ -558,6 +559,10 @@ int db_redis_parse_keys(km_redis_con_t *con) {
                 table->version_code = version_code;
                 break;
             case DBREDIS_KEYS_TYPE_ST:
+            	if(!table) {
+            		LM_ERR("invalid definition, table not set\n");
+            		goto err;
+				}
                 while(p != end && *p != ':')
                     ++p;
                 if (p == end) {
@@ -631,8 +636,6 @@ int db_redis_parse_keys(km_redis_con_t *con) {
             case DBREDIS_KEYS_END_ST:
                 LM_DBG("done parsing keys definition\n");
                 return 0;
-
-
         }
     } while (p != end);
 




More information about the sr-dev mailing list