Code

Add a suffix to integer marshal/unmarshal functions specifying the int size.
authorSebastian Harl <sh@tokkee.org>
Wed, 24 Dec 2014 11:58:02 +0000 (12:58 +0100)
committerSebastian Harl <sh@tokkee.org>
Wed, 24 Dec 2014 11:58:02 +0000 (12:58 +0100)
src/client/sock.c
src/frontend/query.c
src/include/utils/proto.h
src/tools/sysdb/command.c
src/utils/proto.c

index 6f231bd96a3e6823a405a7468a3cce6901465af4..bed6fc0ff0b6d20aff605f4f0a1c4b466435b3e8 100644 (file)
@@ -309,8 +309,8 @@ sdb_client_recv(sdb_client_t *client,
 
                        /* retrieve status and data len */
                        assert(len >= 2 * sizeof(uint32_t));
 
                        /* retrieve status and data len */
                        assert(len >= 2 * sizeof(uint32_t));
-                       rstatus = sdb_proto_unmarshal_int(str, len);
-                       rlen = sdb_proto_unmarshal_int(str + sizeof(rstatus),
+                       rstatus = sdb_proto_unmarshal_int32(str, len);
+                       rlen = sdb_proto_unmarshal_int32(str + sizeof(rstatus),
                                        len - sizeof(rstatus));
 
                        if (! rlen)
                                        len - sizeof(rstatus));
 
                        if (! rlen)
index 1c5b1f293b76b83bff5f39dfde1b5baf0edcb5bd..933ca04cae5a887156400b27fb78c086d0fc6c33 100644 (file)
@@ -132,7 +132,7 @@ sdb_fe_fetch(sdb_conn_t *conn)
                return -1;
        }
 
                return -1;
        }
 
-       type = sdb_proto_unmarshal_int(SDB_STRBUF_STR(conn->buf));
+       type = sdb_proto_unmarshal_int32(SDB_STRBUF_STR(conn->buf));
        strncpy(name, sdb_strbuf_string(conn->buf) + sizeof(uint32_t),
                        conn->cmd_len - sizeof(uint32_t));
        name[sizeof(name) - 1] = '\0';
        strncpy(name, sdb_strbuf_string(conn->buf) + sizeof(uint32_t),
                        conn->cmd_len - sizeof(uint32_t));
        name[sizeof(name) - 1] = '\0';
@@ -149,7 +149,7 @@ sdb_fe_list(sdb_conn_t *conn)
                return -1;
 
        if (conn->cmd_len == sizeof(uint32_t))
                return -1;
 
        if (conn->cmd_len == sizeof(uint32_t))
-               type = sdb_proto_unmarshal_int(SDB_STRBUF_STR(conn->buf));
+               type = sdb_proto_unmarshal_int32(SDB_STRBUF_STR(conn->buf));
        else if (conn->cmd_len) {
                sdb_log(SDB_LOG_ERR, "frontend: Invalid command length %d for "
                                "LIST command", conn->cmd_len);
        else if (conn->cmd_len) {
                sdb_log(SDB_LOG_ERR, "frontend: Invalid command length %d for "
                                "LIST command", conn->cmd_len);
@@ -188,7 +188,7 @@ sdb_fe_lookup(sdb_conn_t *conn)
                                conn->cmd_len);
                return -1;
        }
                                conn->cmd_len);
                return -1;
        }
-       type = sdb_proto_unmarshal_int(SDB_STRBUF_STR(conn->buf));
+       type = sdb_proto_unmarshal_int32(SDB_STRBUF_STR(conn->buf));
 
        matcher = sdb_strbuf_string(conn->buf) + sizeof(uint32_t);
        matcher_len = conn->cmd_len - sizeof(uint32_t);
 
        matcher = sdb_strbuf_string(conn->buf) + sizeof(uint32_t);
        matcher_len = conn->cmd_len - sizeof(uint32_t);
index 4968977d7de4f9ecac7fbf5090fc46e46aa42984..ab01cf5d1ed9cf53bf66fbbe8c29bf8003921631 100644 (file)
@@ -81,11 +81,11 @@ sdb_proto_unmarshal_header(const char *buf, size_t buf_len,
                uint32_t *code, uint32_t *msg_len);
 
 /*
                uint32_t *code, uint32_t *msg_len);
 
 /*
- * sdb_proto_unmarshal_int:
- * Read and decode an integer from the specified string.
+ * sdb_proto_unmarshal_int32:
+ * Read and decode a 32-bit integer from the specified string.
  */
 uint32_t
  */
 uint32_t
-sdb_proto_unmarshal_int(const char *buf, size_t buf_len);
+sdb_proto_unmarshal_int32(const char *buf, size_t buf_len);
 
 #ifdef __cplusplus
 } /* extern "C" */
 
 #ifdef __cplusplus
 } /* extern "C" */
index 78deb717520be48a95d37808b8b3830e32ec73db..2706dd220e12fbe8e5bacb0af539b313d08a8a8a 100644 (file)
@@ -49,7 +49,7 @@
 static void
 log_printer(sdb_strbuf_t *buf)
 {
 static void
 log_printer(sdb_strbuf_t *buf)
 {
-       uint32_t prio = sdb_proto_unmarshal_int(SDB_STRBUF_STR(buf));
+       uint32_t prio = sdb_proto_unmarshal_int32(SDB_STRBUF_STR(buf));
 
        if (prio == UINT32_MAX) {
                sdb_log(SDB_LOG_WARNING, "Received a LOG message with invalid "
 
        if (prio == UINT32_MAX) {
                sdb_log(SDB_LOG_WARNING, "Received a LOG message with invalid "
index 51c2ed8c45361f4625c4e7dc6d956594d7a96a7e..beaa07e98397f18876f27952ab38ed83ff673638 100644 (file)
@@ -54,7 +54,7 @@
  * been available. */
 
 static ssize_t
  * been available. */
 
 static ssize_t
-marshal_int(char *buf, size_t buf_len, int64_t v)
+marshal_int64(char *buf, size_t buf_len, int64_t v)
 {
        if (buf_len >= sizeof(v)) {
 #if __BYTE_ORDER != __BIG_ENDIAN
 {
        if (buf_len >= sizeof(v)) {
 #if __BYTE_ORDER != __BIG_ENDIAN
@@ -64,7 +64,7 @@ marshal_int(char *buf, size_t buf_len, int64_t v)
                memcpy(buf, &v, sizeof(v));
        }
        return sizeof(v);
                memcpy(buf, &v, sizeof(v));
        }
        return sizeof(v);
-} /* marshal_int */
+} /* marshal_int64 */
 
 static ssize_t
 marshal_double(char *buf, size_t buf_len, double v)
 
 static ssize_t
 marshal_double(char *buf, size_t buf_len, double v)
@@ -84,7 +84,7 @@ marshal_double(char *buf, size_t buf_len, double v)
 static ssize_t
 marshal_datetime(char *buf, size_t buf_len, sdb_time_t v)
 {
 static ssize_t
 marshal_datetime(char *buf, size_t buf_len, sdb_time_t v)
 {
-       return marshal_int(buf, buf_len, (int64_t)v);
+       return marshal_int64(buf, buf_len, (int64_t)v);
 } /* marshal_datetime */
 
 static ssize_t
 } /* marshal_datetime */
 
 static ssize_t
@@ -154,7 +154,7 @@ sdb_proto_marshal_data(char *buf, size_t buf_len, sdb_data_t *datum)
                return len;
 
        if (datum->type == SDB_TYPE_INTEGER)
                return len;
 
        if (datum->type == SDB_TYPE_INTEGER)
-               n = marshal_int(buf, buf_len, datum->data.integer);
+               n = marshal_int64(buf, buf_len, datum->data.integer);
        else if (datum->type == SDB_TYPE_DECIMAL)
                n = marshal_double(buf, buf_len, datum->data.decimal);
        else if (datum->type == SDB_TYPE_STRING)
        else if (datum->type == SDB_TYPE_DECIMAL)
                n = marshal_double(buf, buf_len, datum->data.decimal);
        else if (datum->type == SDB_TYPE_STRING)
@@ -192,7 +192,7 @@ sdb_proto_marshal_data(char *buf, size_t buf_len, sdb_data_t *datum)
        for (i = 0; i < datum->data.array.length; ++i) {
                if (type == SDB_TYPE_INTEGER) {
                        int64_t *v = datum->data.array.values;
        for (i = 0; i < datum->data.array.length; ++i) {
                if (type == SDB_TYPE_INTEGER) {
                        int64_t *v = datum->data.array.values;
-                       n = marshal_int(buf, buf_len, v[i]);
+                       n = marshal_int64(buf, buf_len, v[i]);
                }
                else if (type == SDB_TYPE_DECIMAL) {
                        double *v = datum->data.array.values;
                }
                else if (type == SDB_TYPE_DECIMAL) {
                        double *v = datum->data.array.values;
@@ -247,10 +247,10 @@ sdb_proto_unmarshal_header(const char *buf, size_t buf_len,
        if (buf_len < 2 * sizeof(uint32_t))
                return -1;
 
        if (buf_len < 2 * sizeof(uint32_t))
                return -1;
 
-       tmp = sdb_proto_unmarshal_int(buf, buf_len);
+       tmp = sdb_proto_unmarshal_int32(buf, buf_len);
        if (code)
                *code = tmp;
        if (code)
                *code = tmp;
-       tmp = sdb_proto_unmarshal_int(buf + sizeof(uint32_t),
+       tmp = sdb_proto_unmarshal_int32(buf + sizeof(uint32_t),
                        buf_len - sizeof(uint32_t));
        if (msg_len)
                *msg_len = tmp;
                        buf_len - sizeof(uint32_t));
        if (msg_len)
                *msg_len = tmp;
@@ -258,7 +258,7 @@ sdb_proto_unmarshal_header(const char *buf, size_t buf_len,
 } /* sdb_proto_unmarshal_header */
 
 uint32_t
 } /* sdb_proto_unmarshal_header */
 
 uint32_t
-sdb_proto_unmarshal_int(const char *buf, size_t buf_len)
+sdb_proto_unmarshal_int32(const char *buf, size_t buf_len)
 {
        uint32_t n;
 
 {
        uint32_t n;
 
@@ -268,7 +268,7 @@ sdb_proto_unmarshal_int(const char *buf, size_t buf_len)
 
        memcpy(&n, buf, sizeof(n));
        return ntohl(n);
 
        memcpy(&n, buf, sizeof(n));
        return ntohl(n);
-} /* sdb_proto_unmarshal_int */
+} /* sdb_proto_unmarshal_int32 */
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
 
 
 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */