[SR-Dev] git:janakj/postgres: Fix problem in the previous commit: use ntohl() instead of ntohs() when

Jan Janak jan at iptel.org
Sun Feb 15 18:55:28 CET 2009


Module: sip-router
Branch: janakj/postgres
Commit: 6b51c9e6267c39b21b766081c2126c0402298c62
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6b51c9e6267c39b21b766081c2126c0402298c62

Author: Maxim Sobolev <sobomax at sippysoft.com>
Committer: Maxim Sobolev <sobomax at sippysoft.com>
Date:   Wed May 21 16:30:53 2008 +0000

Fix problem in the previous commit: use ntohl() instead of ntohs() when
converting int4 and cast result to int32_t not int16_t.

---

 modules/db_postgres/pg_fld.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/db_postgres/pg_fld.c b/modules/db_postgres/pg_fld.c
index 4bac561..fce1bf6 100644
--- a/modules/db_postgres/pg_fld.c
+++ b/modules/db_postgres/pg_fld.c
@@ -627,7 +627,7 @@ static inline int pg_int4_2_db_cstr(db_fld_t* fld, char* val, int len)
 	struct pg_fld* pfld = DB_GET_PAYLOAD(fld);
 	int size, v;
 
-	v = (int16_t)ntohs(*((int32_t*)val));
+	v = (int32_t)ntohl(*((int32_t*)val));
 
     size = snprintf(pfld->buf, INT2STR_MAX_LEN, "%-d", v);
     if (len < 0 || size >= INT2STR_MAX_LEN) {
@@ -664,7 +664,7 @@ static inline int pg_int4_2_db_str(db_fld_t* fld, char* val, int len)
 	struct pg_fld* pfld = DB_GET_PAYLOAD(fld);
 	int size, v;
 
-	v = (int16_t)ntohs(*((int32_t*)val));
+	v = (int32_t)ntohl(*((int32_t*)val));
 
     size = snprintf(pfld->buf, INT2STR_MAX_LEN, "%-d", v);
     if (size < 0 || size >= INT2STR_MAX_LEN) {




More information about the sr-dev mailing list