Patchwork [1/1] Fold send_all() wrapper unix_write() into one function

login
register
mail settings
Submitter Jes Sorensen
Date Nov. 1, 2010, 7:02 p.m.
Message ID <1288638143-15227-1-git-send-email-Jes.Sorensen@redhat.com>
Download mbox | patch
Permalink /patch/69828/
State New
Headers show

Comments

Jes Sorensen - Nov. 1, 2010, 7:02 p.m.
From: Jes Sorensen <Jes.Sorensen@redhat.com>

The current send_all() wrapper for POSIX calls does nothing but call
unix_write(). Merge them to simplify the code.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 qemu-char.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
Anthony Liguori - Nov. 3, 2010, 6:27 p.m.
On 11/01/2010 02:02 PM, Jes.Sorensen@redhat.com wrote:
> From: Jes Sorensen<Jes.Sorensen@redhat.com>
>
> The current send_all() wrapper for POSIX calls does nothing but call
> unix_write(). Merge them to simplify the code.
>
> Signed-off-by: Jes Sorensen<Jes.Sorensen@redhat.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   qemu-char.c |    8 ++------
>   1 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/qemu-char.c b/qemu-char.c
> index 6d2dce7..88997f9 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -508,9 +508,10 @@ int send_all(int fd, const void *buf, int len1)
>
>   #else
>
> -static int unix_write(int fd, const uint8_t *buf, int len1)
> +int send_all(int fd, const void *_buf, int len1)
>   {
>       int ret, len;
> +    const uint8_t *buf = _buf;
>
>       len = len1;
>       while (len>  0) {
> @@ -527,11 +528,6 @@ static int unix_write(int fd, const uint8_t *buf, int len1)
>       }
>       return len1 - len;
>   }
> -
> -int send_all(int fd, const void *buf, int len1)
> -{
> -    return unix_write(fd, buf, len1);
> -}
>   #endif /* !_WIN32 */
>
>   #ifndef _WIN32
>

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 6d2dce7..88997f9 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -508,9 +508,10 @@  int send_all(int fd, const void *buf, int len1)
 
 #else
 
-static int unix_write(int fd, const uint8_t *buf, int len1)
+int send_all(int fd, const void *_buf, int len1)
 {
     int ret, len;
+    const uint8_t *buf = _buf;
 
     len = len1;
     while (len > 0) {
@@ -527,11 +528,6 @@  static int unix_write(int fd, const uint8_t *buf, int len1)
     }
     return len1 - len;
 }
-
-int send_all(int fd, const void *buf, int len1)
-{
-    return unix_write(fd, buf, len1);
-}
 #endif /* !_WIN32 */
 
 #ifndef _WIN32