[libvirt] [PATCH 09/17] use errno, not socket_errno()

Jim Meyering jim at meyering.net
Tue Oct 28 12:29:54 UTC 2008


"Daniel P. Berrange" <berrange at redhat.com> wrote:

> On Tue, Oct 28, 2008 at 12:21:26PM +0100, Jim Meyering wrote:
>> From: Jim Meyering <meyering at redhat.com>
>>
>> * remote_internal.c: s/socket_errno()/errno/, now that gnulib's
>> socket module ensures errno is useful in those cases.
>> @@ -4627,7 +4627,7 @@ really_write_buf (virConnectPtr conn, struct private_data *priv,
>>          do {
>>              err = send (priv->sock, p, len, 0);
>>              if (err == -1) {
>> -                int errno_ = socket_errno ();
>> +                int errno_ = errno;
>>                  if (errno_ == EINTR || errno_ == EAGAIN)
>>                      continue;
>>                  error (in_open ? NULL : conn,
>> @@ -4710,7 +4710,7 @@ really_read_buf (virConnectPtr conn, struct private_data *priv,
>>      reread:
>>          err = recv (priv->sock, bytes, len, 0);
>>          if (err == -1) {
>> -            int errno_ = socket_errno ();
>> +            int errno_ = errno;
>>              if (errno_ == EINTR)
>>                  goto reread;
>>              error (in_open ? NULL : conn,
>
> Do we need to keep this intermediate variable around ? I think we can
> just of 'if (errno == EINTR)' directly ?
>
> ACK anyway

Here's the incremental I'm folding in:

diff --git a/src/remote_internal.c b/src/remote_internal.c
index 5f528a8..7dcaf89 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -4627,11 +4627,10 @@ really_write_buf (virConnectPtr conn, struct private_data *priv,
         do {
             err = send (priv->sock, p, len, 0);
             if (err == -1) {
-                int errno_ = errno;
-                if (errno_ == EINTR || errno_ == EAGAIN)
+                if (errno == EINTR || errno == EAGAIN)
                     continue;
                 error (in_open ? NULL : conn,
-                       VIR_ERR_SYSTEM_ERROR, strerror (errno_));
+                       VIR_ERR_SYSTEM_ERROR, strerror (errno));
                 return -1;
             }
             len -= err;
@@ -4710,11 +4709,10 @@ really_read_buf (virConnectPtr conn, struct private_data *priv,
     reread:
         err = recv (priv->sock, bytes, len, 0);
         if (err == -1) {
-            int errno_ = errno;
-            if (errno_ == EINTR)
+            if (errno == EINTR)
                 goto reread;
             error (in_open ? NULL : conn,
-                   VIR_ERR_SYSTEM_ERROR, strerror (errno_));
+                   VIR_ERR_SYSTEM_ERROR, strerror (errno));
             return -1;
         }
         if (err == 0) {




More information about the libvir-list mailing list