]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libctf: fix GNU style for do {} while
authorNick Alcock <nick.alcock@oracle.com>
Thu, 18 Mar 2021 12:37:52 +0000 (12:37 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 18 Mar 2021 12:37:55 +0000 (12:37 +0000)
It's formatted like this:

do
  {
    ...
  }
while (...);

Not like this:

do
 {
    ...
  } while (...);

or this:

do {
  ...
} while (...);

We used both in various places in libctf.  Fixing it necessitated some
light reindentation.

libctf/ChangeLog
2021-03-18  Nick Alcock  <nick.alcock@oracle.com>

* ctf-archive.c (ctf_archive_next): GNU style fix for do {} while.
* ctf-dedup.c (ctf_dedup_rhash_type): Likewise.
(ctf_dedup_rwalk_one_output_mapping): Likewise.
* ctf-dump.c (ctf_dump_format_type): Likewise.
* ctf-lookup.c (ctf_symbol_next): Likewise.
* swap.h (swap_thing): Likewise.

libctf/ChangeLog
libctf/ctf-archive.c
libctf/ctf-dedup.c
libctf/ctf-dump.c
libctf/ctf-lookup.c
libctf/swap.h

index 4e4e9af0686dbd95684dc946fa641dea9cf56508..f64493f5012fba39db7929be8cc563f5a4aa8a5d 100644 (file)
@@ -1,3 +1,12 @@
+2021-03-18  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-archive.c (ctf_archive_next): GNU style fix for do {} while.
+       * ctf-dedup.c (ctf_dedup_rhash_type): Likewise.
+       (ctf_dedup_rwalk_one_output_mapping): Likewise.
+       * ctf-dump.c (ctf_dump_format_type): Likewise.
+       * ctf-lookup.c (ctf_symbol_next): Likewise.
+       * swap.h (swap_thing): Likewise.
+
 2021-03-18  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-serialize.c: General reshuffling, and...
index 8b8e170241f59c4d87a1a7acd8703ab60ac5b72e..e0ceb80fa11fa1899c5c3e091192e3cf8f114a30 100644 (file)
@@ -1156,7 +1156,8 @@ ctf_archive_next (const ctf_archive_t *wrapper, ctf_next_t **it, const char **na
 
       name_ = &nametbl[le64toh (modent[i->ctn_n].name_offset)];
       i->ctn_n++;
-    } while (skip_parent && strcmp (name_, _CTF_SECTION) == 0);
+    }
+  while (skip_parent && strcmp (name_, _CTF_SECTION) == 0);
 
   if (name)
     *name = name_;
index ef8507a59f288bcf35ac889e33c0d1b411f8dca1..9f5ba903ec486d3cf47fa57c192ef252362b263d 100644 (file)
@@ -589,7 +589,8 @@ ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs,
          goto oom;                                                     \
       if (ctf_dynset_cinsert (citers, hval) < 0)                       \
        goto oom;                                                       \
-    } while (0)
+    }                                                                  \
+  while (0)
 
   /* If this is a named struct or union or a forward to one, and this is a child
      traversal, treat this type as if it were a forward -- do not recurse to
@@ -2029,42 +2030,44 @@ ctf_dedup_rwalk_one_output_mapping (ctf_dict_t *output,
      times, which is worse.  */
 
 #define CTF_TYPE_WALK(type, errlabel, errmsg)                          \
-  do {                                                                 \
-    void *type_id;                                                     \
-    const char *hashval;                                               \
-    int cited_type_input_num = input_num;                              \
+  do                                                                   \
+    {                                                                  \
+      void *type_id;                                                   \
+      const char *hashval;                                             \
+      int cited_type_input_num = input_num;                            \
                                                                        \
-    if ((fp->ctf_flags & LCTF_CHILD) && (LCTF_TYPE_ISPARENT (fp, type))) \
-      cited_type_input_num = parents[input_num];                       \
+      if ((fp->ctf_flags & LCTF_CHILD) && (LCTF_TYPE_ISPARENT (fp, type))) \
+       cited_type_input_num = parents[input_num];                      \
                                                                        \
-    type_id = CTF_DEDUP_GID (output, cited_type_input_num, type);      \
+      type_id = CTF_DEDUP_GID (output, cited_type_input_num, type);    \
                                                                        \
-    if (type == 0)                                                     \
-      {                                                                        \
-       ctf_dprintf ("Walking: unimplemented type\n");                  \
-       break;                                                          \
-      }                                                                        \
+      if (type == 0)                                                   \
+       {                                                               \
+         ctf_dprintf ("Walking: unimplemented type\n");                \
+         break;                                                        \
+       }                                                               \
                                                                        \
-    ctf_dprintf ("Looking up ID %i/%lx in type hashes\n",              \
-                cited_type_input_num, type);                           \
-    hashval = ctf_dynhash_lookup (d->cd_type_hashes, type_id);         \
-    if (!ctf_assert (output, hashval))                                 \
-      {                                                                        \
-       whaterr = N_("error looking up ID in type hashes");             \
-       goto errlabel;                                                  \
-      }                                                                        \
-    ctf_dprintf ("ID %i/%lx has hash %s\n", cited_type_input_num, type,        \
-                hashval);                                              \
+      ctf_dprintf ("Looking up ID %i/%lx in type hashes\n",            \
+                  cited_type_input_num, type);                         \
+      hashval = ctf_dynhash_lookup (d->cd_type_hashes, type_id);       \
+      if (!ctf_assert (output, hashval))                               \
+       {                                                               \
+         whaterr = N_("error looking up ID in type hashes");           \
+         goto errlabel;                                                \
+       }                                                               \
+      ctf_dprintf ("ID %i/%lx has hash %s\n", cited_type_input_num, type, \
+                  hashval);                                            \
                                                                        \
-    ret = ctf_dedup_rwalk_output_mapping (output, inputs, ninputs, parents, \
-                                         already_visited, hashval,     \
-                                         visit_fun, arg, depth);       \
-    if (ret < 0)                                                       \
-      {                                                                        \
-       whaterr = errmsg;                                               \
-       goto errlabel;                                                  \
-      }                                                                        \
-  } while (0)
+      ret = ctf_dedup_rwalk_output_mapping (output, inputs, ninputs, parents, \
+                                           already_visited, hashval,   \
+                                           visit_fun, arg, depth);     \
+      if (ret < 0)                                                     \
+       {                                                               \
+         whaterr = errmsg;                                             \
+         goto errlabel;                                                \
+       }                                                               \
+    }                                                                  \
+  while (0)
 
   switch (ctf_type_kind_unsliced (fp, type))
     {
index 788355d9db145f52decbb37d978672aacd38a0d7..409626a224b64974b69989959c6450ec744260fa 100644 (file)
@@ -220,7 +220,8 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
        new_id = ctf_type_reference (fp, id);
       if (new_id != CTF_ERR)
        str = str_append (str, " -> ");
-    } while (new_id != CTF_ERR);
+    }
+  while (new_id != CTF_ERR);
 
   if (ctf_errno (fp) != ECTF_NOTREF)
     {
index 2e78cf492763af348d8a48d59e9353086aaaf10a..9d1e6d8a4a2b23c9d0ad7eade665123f1e7a0f7f 100644 (file)
@@ -723,7 +723,8 @@ ctf_symbol_next (ctf_dict_t *fp, ctf_next_t **it, const char **name,
 
          *name = ctf_strptr (fp, idx[i->ctn_n]);
          sym = tab[i->ctn_n++];
-       } while (sym == -1u || sym == 0);
+       }
+      while (sym == -1u || sym == 0);
     }
   else
     {
index d7cc9936cea37ca7388aae8d3f7638a0982fde4d..4d0b48c9e759e9c002a3b5b70a16ccb4519365d0 100644 (file)
@@ -73,18 +73,20 @@ bswap_64 (uint64_t v)
 /* Swap the endianness of something.  */
 
 #define swap_thing(x)                                                  \
-  do {                                                                 \
-    _Static_assert (sizeof (x) == 1 || (sizeof (x) % 2 == 0            \
-                                       && sizeof (x) <= 8),            \
-                   "Invalid size, update endianness code");            \
-    switch (sizeof (x)) {                                              \
-    case 2: x = bswap_16 (x); break;                                   \
-    case 4: x = bswap_32 (x); break;                                   \
-    case 8: x = bswap_64 (x); break;                                   \
-    case 1: /* Nothing needs doing */                                  \
-      break;                                                           \
+  do                                                                   \
+    {                                                                  \
+      _Static_assert (sizeof (x) == 1 || (sizeof (x) % 2 == 0          \
+                                         && sizeof (x) <= 8),          \
+                     "Invalid size, update endianness code");          \
+      switch (sizeof (x)) {                                            \
+      case 2: x = bswap_16 (x); break;                                 \
+      case 4: x = bswap_32 (x); break;                                 \
+      case 8: x = bswap_64 (x); break;                                 \
+      case 1: /* Nothing needs doing */                                        \
+       break;                                                          \
+      }                                                                        \
     }                                                                  \
-  while (0);
+  while (0);
 
 
 #endif /* !defined(_CTF_SWAP_H) */