From 3d184d708cdbf864eb96c15e1a0f08b57c118009 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 16 Dec 2014 09:54:58 +0100 Subject: [PATCH] proto: Renamed sdb_proto_get_int to sdb_proto_unmarshal_int. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … to be consistent with the other functions. --- src/client/sock.c | 4 ++-- src/frontend/query.c | 6 +++--- src/include/utils/proto.h | 6 +++++- src/tools/sysdb/command.c | 2 +- src/utils/proto.c | 8 ++++---- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/client/sock.c b/src/client/sock.c index d4596cd..a99abf1 100644 --- a/src/client/sock.c +++ b/src/client/sock.c @@ -304,8 +304,8 @@ sdb_client_recv(sdb_client_t *client, if (rstatus == UINT32_MAX) { /* retrieve status and data len */ - rstatus = sdb_proto_get_int(buf, data_offset); - rlen = sdb_proto_get_int(buf, data_offset + sizeof(rstatus)); + rstatus = sdb_proto_unmarshal_int(buf, data_offset); + rlen = sdb_proto_unmarshal_int(buf, data_offset + sizeof(rstatus)); if (! rlen) break; diff --git a/src/frontend/query.c b/src/frontend/query.c index 35ff102..4580e57 100644 --- a/src/frontend/query.c +++ b/src/frontend/query.c @@ -132,7 +132,7 @@ sdb_fe_fetch(sdb_conn_t *conn) return -1; } - type = sdb_proto_get_int(conn->buf, 0); + type = sdb_proto_unmarshal_int(conn->buf, 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)) - type = sdb_proto_get_int(conn->buf, 0); + type = sdb_proto_unmarshal_int(conn->buf, 0); 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; } - type = sdb_proto_get_int(conn->buf, 0); + type = sdb_proto_unmarshal_int(conn->buf, 0); matcher = sdb_strbuf_string(conn->buf) + sizeof(uint32_t); matcher_len = conn->cmd_len - sizeof(uint32_t); diff --git a/src/include/utils/proto.h b/src/include/utils/proto.h index 6f0907f..311162b 100644 --- a/src/include/utils/proto.h +++ b/src/include/utils/proto.h @@ -64,8 +64,12 @@ int sdb_proto_unmarshal_header(sdb_strbuf_t *buf, uint32_t *code, uint32_t *msg_len); +/* + * sdb_proto_unmarshal_int: + * Read and decode an integer from the specified string buffer. + */ uint32_t -sdb_proto_get_int(sdb_strbuf_t *buf, size_t offset); +sdb_proto_unmarshal_int(sdb_strbuf_t *buf, size_t offset); #ifdef __cplusplus } /* extern "C" */ diff --git a/src/tools/sysdb/command.c b/src/tools/sysdb/command.c index 9589875..e859bc7 100644 --- a/src/tools/sysdb/command.c +++ b/src/tools/sysdb/command.c @@ -49,7 +49,7 @@ static void log_printer(sdb_strbuf_t *buf) { - uint32_t prio = sdb_proto_get_int(buf, 0); + uint32_t prio = sdb_proto_unmarshal_int(buf, 0); if (prio == UINT32_MAX) { sdb_log(SDB_LOG_WARNING, "Received a LOG message with invalid " diff --git a/src/utils/proto.c b/src/utils/proto.c index 35b1986..dc6ee71 100644 --- a/src/utils/proto.c +++ b/src/utils/proto.c @@ -73,17 +73,17 @@ sdb_proto_unmarshal_header(sdb_strbuf_t *buf, if (sdb_strbuf_len(buf) < 2 * sizeof(uint32_t)) return -1; - tmp = sdb_proto_get_int(buf, 0); + tmp = sdb_proto_unmarshal_int(buf, 0); if (code) *code = tmp; - tmp = sdb_proto_get_int(buf, sizeof(uint32_t)); + tmp = sdb_proto_unmarshal_int(buf, sizeof(uint32_t)); if (msg_len) *msg_len = tmp; return 0; } /* sdb_proto_unmarshal_header */ uint32_t -sdb_proto_get_int(sdb_strbuf_t *buf, size_t offset) +sdb_proto_unmarshal_int(sdb_strbuf_t *buf, size_t offset) { const char *data; uint32_t n; @@ -99,7 +99,7 @@ sdb_proto_get_int(sdb_strbuf_t *buf, size_t offset) data += offset; memcpy(&n, data, sizeof(n)); return ntohl(n); -} /* sdb_proto_get_int */ +} /* sdb_proto_unmarshal_int */ /* vim: set tw=78 sw=4 ts=4 noexpandtab : */ -- 2.30.2