[PATCH 1/2] Cleanup xrow.h

Vladimir Davydov vdavydov.dev at gmail.com
Tue Feb 6 15:02:15 MSK 2018


No functional changes, just a trivial cleanup:

 - Move all C functions inside extern "C" section.
 - Rename xrow_decode_join to xrow_decode_join_xc.
 - Make XXX_xc wrappers around XXX functions.
---
 src/box/box.cc |  2 +-
 src/box/xrow.h | 70 ++++++++++++++++++++++++++++++++++------------------------
 2 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/src/box/box.cc b/src/box/box.cc
index c33243a8..7cd0e279 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -1214,7 +1214,7 @@ box_process_join(struct ev_io *io, struct xrow_header *header)
 
 	/* Decode JOIN request */
 	struct tt_uuid instance_uuid = uuid_nil;
-	xrow_decode_join(header, &instance_uuid);
+	xrow_decode_join_xc(header, &instance_uuid);
 
 	/* Check that bootstrap has been finished */
 	if (!is_box_configured)
diff --git a/src/box/xrow.h b/src/box/xrow.h
index e7faa4da..859bd1d2 100644
--- a/src/box/xrow.h
+++ b/src/box/xrow.h
@@ -41,6 +41,8 @@
 extern "C" {
 #endif
 
+struct vclock;
+
 enum {
 	XROW_HEADER_IOVMAX = 1,
 	XROW_BODY_IOVMAX = 2,
@@ -220,7 +222,6 @@ xrow_encode_auth(struct xrow_header *row, const char *salt, size_t salt_len,
 		 const char *login, size_t login_len, const char *password,
 		 size_t password_len);
 
-struct vclock;
 /**
  * Encode SUBSCRIBE command.
  * @param[out] Row.
@@ -264,6 +265,20 @@ int
 xrow_encode_join(struct xrow_header *row, const struct tt_uuid *instance_uuid);
 
 /**
+ * Decode JOIN command.
+ * @param row Row to decode.
+ * @param[out] instance_uuid.
+ *
+ * @retval  0 Success.
+ * @retval -1 Memory or format error.
+ */
+static inline int
+xrow_decode_join(struct xrow_header *row, struct tt_uuid *instance_uuid)
+{
+	return xrow_decode_subscribe(row, NULL, instance_uuid, NULL, NULL);
+}
+
+/**
  * Encode end of stream command (a response to JOIN command).
  * @param row[out] Row to encode into.
  * @param vclock.
@@ -275,6 +290,20 @@ int
 xrow_encode_vclock(struct xrow_header *row, const struct vclock *vclock);
 
 /**
+ * Decode end of stream command (a response to JOIN command).
+ * @param row Row to decode.
+ * @param[out] vclock.
+ *
+ * @retval  0 Success.
+ * @retval -1 Memory or format error.
+ */
+static inline int
+xrow_decode_vclock(struct xrow_header *row, struct vclock *vclock)
+{
+	return xrow_decode_subscribe(row, NULL, NULL, vclock, NULL);
+}
+
+/**
  * Encode a heartbeat message.
  * @param row[out] Row to encode into.
  * @param replica_id Instance id.
@@ -319,7 +348,7 @@ void
 iproto_reply_select(struct obuf *buf, struct obuf_svp *svp, uint64_t sync,
 		    uint32_t schema_version, uint32_t count);
 
-/*
+/**
  * Encode iproto header with IPROTO_OK response code.
  * @param out Encode to.
  * @param sync Request sync.
@@ -425,9 +454,7 @@ xrow_decode_error(struct xrow_header *row);
 #if defined(__cplusplus)
 } /* extern "C" */
 
-/**
- * @copydoc xrow_header_decode()
- */
+/** @copydoc xrow_header_decode. */
 static inline void
 xrow_header_decode_xc(struct xrow_header *header, const char **pos,
 		      const char *end)
@@ -454,6 +481,7 @@ xrow_decode_error_xc(struct xrow_header *row)
 	diag_raise();
 }
 
+/** @copydoc xrow_decode_dml. */
 static inline void
 xrow_decode_dml_xc(struct xrow_header *row, struct request *request,
 		   uint64_t key_map)
@@ -462,6 +490,7 @@ xrow_decode_dml_xc(struct xrow_header *row, struct request *request,
 		diag_raise();
 }
 
+/** @copydoc xrow_encode_dml. */
 static inline int
 xrow_encode_dml_xc(const struct request *request, struct iovec *iov)
 {
@@ -533,15 +562,12 @@ xrow_encode_join_xc(struct xrow_header *row,
 		diag_raise();
 }
 
-/**
- * \brief Decode JOIN command
- * \param row
- * \param[out] instance_uuid
-*/
+/** @copydoc xrow_decode_join. */
 static inline void
-xrow_decode_join(struct xrow_header *row, struct tt_uuid *instance_uuid)
+xrow_decode_join_xc(struct xrow_header *row, struct tt_uuid *instance_uuid)
 {
-	xrow_decode_subscribe_xc(row, NULL, instance_uuid, NULL, NULL);
+	if (xrow_decode_join(row, instance_uuid) != 0)
+		diag_raise();
 }
 
 /** @copydoc xrow_encode_vclock. */
@@ -552,26 +578,12 @@ xrow_encode_vclock_xc(struct xrow_header *row, const struct vclock *vclock)
 		diag_raise();
 }
 
-/**
- * \brief Decode end of stream command (a response to JOIN command)
- * \param row
- * \param[out] vclock
-*/
-static inline int
-xrow_decode_vclock(struct xrow_header *row, struct vclock *vclock)
-{
-	return xrow_decode_subscribe(row, NULL, NULL, vclock, NULL);
-}
-
-/**
- * \brief Decode end of stream command (a response to JOIN command)
- * \param row
- * \param[out] vclock
-*/
+/** @copydoc xrow_decode_vclock. */
 static inline void
 xrow_decode_vclock_xc(struct xrow_header *row, struct vclock *vclock)
 {
-	xrow_decode_subscribe_xc(row, NULL, NULL, vclock, NULL);
+	if (xrow_decode_vclock(row, vclock) != 0)
+		diag_raise();
 }
 
 /** @copydoc iproto_reply_ok. */
-- 
2.11.0




More information about the Tarantool-patches mailing list