[v4,20/35] libctf: eschew C99 for loop initial declarations

Message ID 20190924135131.441906-21-nick.alcock@oracle.com
State New
Headers show
Series
  • CTF linking support
Related show

Commit Message

Nick Alcock Sept. 24, 2019, 1:51 p.m.
We shouldn't use these, since binutils doesn't require a C99-capable
compiler yet.

New in v3.

libctf/
	* ctf-open.c (flip_lbls): Eschew for-loop initial declarations.
        (flip_objts): Likewise.
        (flip_vars): Likewise.
        (flip_types): Likewise.
---
 libctf/ctf-open.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

-- 
2.23.0.239.g28aa4420fd

Patch

diff --git a/libctf/ctf-open.c b/libctf/ctf-open.c
index 7f9504c68ce..25f0e9e8ad1 100644
--- a/libctf/ctf-open.c
+++ b/libctf/ctf-open.c
@@ -986,8 +986,9 @@  static void
 flip_lbls (void *start, size_t len)
 {
   ctf_lblent_t *lbl = start;
+  ssize_t i;
 
-  for (ssize_t i = len / sizeof (struct ctf_lblent); i > 0; lbl++, i--)
+  for (i = len / sizeof (struct ctf_lblent); i > 0; lbl++, i--)
     {
       swap_thing (lbl->ctl_label);
       swap_thing (lbl->ctl_type);
@@ -1003,8 +1004,9 @@  static void
 flip_objts (void *start, size_t len)
 {
   uint32_t *obj = start;
+  ssize_t i;
 
-  for (ssize_t i = len / sizeof (uint32_t); i > 0; obj++, i--)
+  for (i = len / sizeof (uint32_t); i > 0; obj++, i--)
       swap_thing (*obj);
 }
 
@@ -1014,8 +1016,9 @@  static void
 flip_vars (void *start, size_t len)
 {
   ctf_varent_t *var = start;
+  ssize_t i;
 
-  for (ssize_t i = len / sizeof (struct ctf_varent); i > 0; var++, i--)
+  for (i = len / sizeof (struct ctf_varent); i > 0; var++, i--)
     {
       swap_thing (var->ctv_name);
       swap_thing (var->ctv_type);
@@ -1080,8 +1083,9 @@  flip_types (void *start, size_t len)
 	    /* This type has a bunch of uint32_ts.  */
 
 	    uint32_t *item = (uint32_t *) t;
+	    ssize_t i;
 
-	    for (ssize_t i = vlen; i > 0; item++, i--)
+	    for (i = vlen; i > 0; item++, i--)
 	      swap_thing (*item);
 	    break;
 	  }
@@ -1125,7 +1129,8 @@  flip_types (void *start, size_t len)
 	    if (_libctf_unlikely_ (size >= CTF_LSTRUCT_THRESH))
 	      {
 		ctf_lmember_t *lm = (ctf_lmember_t *) t;
-		for (ssize_t i = vlen; i > 0; i--, lm++)
+		ssize_t i;
+		for (i = vlen; i > 0; i--, lm++)
 		  {
 		    swap_thing (lm->ctlm_name);
 		    swap_thing (lm->ctlm_offsethi);
@@ -1136,7 +1141,8 @@  flip_types (void *start, size_t len)
 	    else
 	      {
 		ctf_member_t *m = (ctf_member_t *) t;
-		for (ssize_t i = vlen; i > 0; i--, m++)
+		ssize_t i;
+		for (i = vlen; i > 0; i--, m++)
 		  {
 		    swap_thing (m->ctm_name);
 		    swap_thing (m->ctm_offset);
@@ -1151,8 +1157,9 @@  flip_types (void *start, size_t len)
 	    /* This has an array of ctf_enum_t.  */
 
 	    ctf_enum_t *item = (ctf_enum_t *) t;
+	    ssize_t i;
 
-	    for (ssize_t i = vlen; i > 0; item++, i--)
+	    for (i = vlen; i > 0; item++, i--)
 	      {
 		swap_thing (item->cte_name);
 		swap_thing (item->cte_value);