[PATCH v2 4/4] vhost: Reformat vhost_{get, put}_user()

Gavin Shan posted 4 patches 1 year, 7 months ago
[PATCH v2 4/4] vhost: Reformat vhost_{get, put}_user()
Posted by Gavin Shan 1 year, 7 months ago
Reformat the macros to use tab as the terminator for each line so
that it looks clean.

No functional change intended.

Signed-off-by: Gavin Shan <gshan@redhat.com>
---
 drivers/vhost/vhost.c | 60 +++++++++++++++++++++----------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 4ddb9ec2fe46..c1ed5e750521 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1207,21 +1207,22 @@ static inline void __user *__vhost_get_user(struct vhost_virtqueue *vq,
 	return __vhost_get_user_slow(vq, addr, size, type);
 }
 
-#define vhost_put_user(vq, x, ptr)		\
-({ \
-	int ret; \
-	if (!vq->iotlb) { \
-		ret = __put_user(x, ptr); \
-	} else { \
-		__typeof__(ptr) to = \
+#define vhost_put_user(vq, x, ptr)					\
+({									\
+	int ret;							\
+	if (!vq->iotlb) {						\
+		ret = __put_user(x, ptr);				\
+	} else {							\
+		__typeof__(ptr) to =					\
 			(__typeof__(ptr)) __vhost_get_user(vq, ptr,	\
-					  sizeof(*ptr), VHOST_ADDR_USED); \
-		if (to != NULL) \
-			ret = __put_user(x, to); \
-		else \
-			ret = -EFAULT;	\
-	} \
-	ret; \
+						sizeof(*ptr),		\
+						VHOST_ADDR_USED);	\
+		if (to != NULL)						\
+			ret = __put_user(x, to);			\
+		else							\
+			ret = -EFAULT;					\
+	}								\
+	ret;								\
 })
 
 static inline int vhost_put_avail_event(struct vhost_virtqueue *vq)
@@ -1252,22 +1253,21 @@ static inline int vhost_put_used_idx(struct vhost_virtqueue *vq)
 			      &vq->used->idx);
 }
 
-#define vhost_get_user(vq, x, ptr, type)		\
-({ \
-	int ret; \
-	if (!vq->iotlb) { \
-		ret = __get_user(x, ptr); \
-	} else { \
-		__typeof__(ptr) from = \
-			(__typeof__(ptr)) __vhost_get_user(vq, ptr, \
-							   sizeof(*ptr), \
-							   type); \
-		if (from != NULL) \
-			ret = __get_user(x, from); \
-		else \
-			ret = -EFAULT; \
-	} \
-	ret; \
+#define vhost_get_user(vq, x, ptr, type)				\
+({									\
+	int ret;							\
+	if (!vq->iotlb) {						\
+		ret = __get_user(x, ptr);				\
+	} else {							\
+		__typeof__(ptr) from =					\
+			(__typeof__(ptr)) __vhost_get_user(vq, ptr,	\
+						sizeof(*ptr), type);	\
+		if (from != NULL)					\
+			ret = __get_user(x, from);			\
+		else							\
+			ret = -EFAULT;					\
+	}								\
+	ret;								\
 })
 
 #define vhost_get_avail(vq, x, ptr) \
-- 
2.44.0
Re: [PATCH v2 4/4] vhost: Reformat vhost_{get, put}_user()
Posted by Michael S. Tsirkin 1 year, 7 months ago
On Mon, Apr 29, 2024 at 08:14:00PM +1000, Gavin Shan wrote:
> Reformat the macros to use tab as the terminator for each line so
> that it looks clean.
> 
> No functional change intended.
> 
> Signed-off-by: Gavin Shan <gshan@redhat.com>

Just messes up history for no real gain.

> ---
>  drivers/vhost/vhost.c | 60 +++++++++++++++++++++----------------------
>  1 file changed, 30 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 4ddb9ec2fe46..c1ed5e750521 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -1207,21 +1207,22 @@ static inline void __user *__vhost_get_user(struct vhost_virtqueue *vq,
>  	return __vhost_get_user_slow(vq, addr, size, type);
>  }
>  
> -#define vhost_put_user(vq, x, ptr)		\
> -({ \
> -	int ret; \
> -	if (!vq->iotlb) { \
> -		ret = __put_user(x, ptr); \
> -	} else { \
> -		__typeof__(ptr) to = \
> +#define vhost_put_user(vq, x, ptr)					\
> +({									\
> +	int ret;							\
> +	if (!vq->iotlb) {						\
> +		ret = __put_user(x, ptr);				\
> +	} else {							\
> +		__typeof__(ptr) to =					\
>  			(__typeof__(ptr)) __vhost_get_user(vq, ptr,	\
> -					  sizeof(*ptr), VHOST_ADDR_USED); \
> -		if (to != NULL) \
> -			ret = __put_user(x, to); \
> -		else \
> -			ret = -EFAULT;	\
> -	} \
> -	ret; \
> +						sizeof(*ptr),		\
> +						VHOST_ADDR_USED);	\
> +		if (to != NULL)						\
> +			ret = __put_user(x, to);			\
> +		else							\
> +			ret = -EFAULT;					\
> +	}								\
> +	ret;								\
>  })
>  
>  static inline int vhost_put_avail_event(struct vhost_virtqueue *vq)
> @@ -1252,22 +1253,21 @@ static inline int vhost_put_used_idx(struct vhost_virtqueue *vq)
>  			      &vq->used->idx);
>  }
>  
> -#define vhost_get_user(vq, x, ptr, type)		\
> -({ \
> -	int ret; \
> -	if (!vq->iotlb) { \
> -		ret = __get_user(x, ptr); \
> -	} else { \
> -		__typeof__(ptr) from = \
> -			(__typeof__(ptr)) __vhost_get_user(vq, ptr, \
> -							   sizeof(*ptr), \
> -							   type); \
> -		if (from != NULL) \
> -			ret = __get_user(x, from); \
> -		else \
> -			ret = -EFAULT; \
> -	} \
> -	ret; \
> +#define vhost_get_user(vq, x, ptr, type)				\
> +({									\
> +	int ret;							\
> +	if (!vq->iotlb) {						\
> +		ret = __get_user(x, ptr);				\
> +	} else {							\
> +		__typeof__(ptr) from =					\
> +			(__typeof__(ptr)) __vhost_get_user(vq, ptr,	\
> +						sizeof(*ptr), type);	\
> +		if (from != NULL)					\
> +			ret = __get_user(x, from);			\
> +		else							\
> +			ret = -EFAULT;					\
> +	}								\
> +	ret;								\
>  })
>  
>  #define vhost_get_avail(vq, x, ptr) \
> -- 
> 2.44.0