[glib/main-c89: 2/5] gsocket.c: Declare variables at the top-of-block




commit 08413a37c4f6e2db5746968eafeb865d7a1c6cdf
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Mar 31 16:53:23 2021 +0800

    gsocket.c: Declare variables at the top-of-block
    
    This will allow the code to build on C89 compilers, since they do not
    allow declaring a variable within a for loop initializer.

 gio/gsocket.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gio/gsocket.c b/gio/gsocket.c
index d5603c538..5ffe87aa0 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -4795,7 +4795,9 @@ g_socket_send_message (GSocket                *socket,
 
   if (num_vectors != -1)
     {
-      for (gint i = 0; i < num_vectors; i++)
+      gint i;
+
+      for (i = 0; i < num_vectors; i++)
         {
           /* No wrap-around for vectors_size */
           if (vectors_size > vectors_size + vectors[i].size)
@@ -4811,7 +4813,9 @@ g_socket_send_message (GSocket                *socket,
     }
   else
     {
-      for (gsize i = 0; vectors[i].buffer != NULL; i++)
+      gsize i;
+
+      for (i = 0; vectors[i].buffer != NULL; i++)
         {
           /* No wrap-around for vectors_size */
           if (vectors_size > vectors_size + vectors[i].size)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]