public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Alcock <nick.alcock@oracle.com>
To: binutils@sourceware.org
Subject: [PATCH 05/16] libctf: fix GNU style for do {} while
Date: Sat,  6 Mar 2021 00:40:12 +0000	[thread overview]
Message-ID: <20210306004023.164154-6-nick.alcock@oracle.com> (raw)
In-Reply-To: <20210306004023.164154-1-nick.alcock@oracle.com>

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-02  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/ctf-archive.c |  3 +-
 libctf/ctf-dedup.c   | 67 +++++++++++++++++++++++---------------------
 libctf/ctf-dump.c    |  3 +-
 libctf/ctf-lookup.c  |  3 +-
 libctf/swap.h        | 24 ++++++++--------
 5 files changed, 54 insertions(+), 46 deletions(-)

diff --git a/libctf/ctf-archive.c b/libctf/ctf-archive.c
index 8b8e170241f..e0ceb80fa11 100644
--- a/libctf/ctf-archive.c
+++ b/libctf/ctf-archive.c
@@ -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_;
diff --git a/libctf/ctf-dedup.c b/libctf/ctf-dedup.c
index ef8507a59f2..9f5ba903ec4 100644
--- a/libctf/ctf-dedup.c
+++ b/libctf/ctf-dedup.c
@@ -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))
     {
diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c
index 788355d9db1..409626a224b 100644
--- a/libctf/ctf-dump.c
+++ b/libctf/ctf-dump.c
@@ -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)
     {
diff --git a/libctf/ctf-lookup.c b/libctf/ctf-lookup.c
index 2e78cf49276..9d1e6d8a4a2 100644
--- a/libctf/ctf-lookup.c
+++ b/libctf/ctf-lookup.c
@@ -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
     {
diff --git a/libctf/swap.h b/libctf/swap.h
index d7cc9936cea..4d0b48c9e75 100644
--- a/libctf/swap.h
+++ b/libctf/swap.h
@@ -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) */
-- 
2.30.0.252.gc27e85e57d


  parent reply	other threads:[~2021-03-06  0:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-06  0:40 [PATCH 00/16] libctf: mostly cleanups and refactoring Nick Alcock
2021-03-06  0:40 ` [PATCH 01/16] libctf: fix some tabdamage and move some code around Nick Alcock
2021-03-06  0:40 ` [PATCH 02/16] libctf: split serialization and file writeout into its own file Nick Alcock
2021-03-06  0:40 ` [PATCH 03/16] libctf: fix comment above ctf_dict_t Nick Alcock
2021-03-06  0:40 ` [PATCH 04/16] libctf: split up ctf_serialize Nick Alcock
2021-03-06  0:40 ` Nick Alcock [this message]
2021-03-06  0:40 ` [PATCH 06/16] libctf: eliminate dtd_u, part 1: int/float/slice Nick Alcock
2021-03-06  0:40 ` [PATCH 07/16] libctf: eliminate dtd_u, part 2: arrays Nick Alcock
2021-03-06  0:40 ` [PATCH 08/16] libctf: eliminate dtd_u, part 3: functions Nick Alcock
2021-03-06  0:40 ` [PATCH 09/16] Add install dependencies for ld -> bfd and libctf -> bfd Nick Alcock
2021-03-15 13:11   ` [PING] " Nick Alcock
2021-03-17 14:23     ` Nick Alcock
2021-03-17 18:34       ` [PATCH v2 " Nick Alcock
2021-03-18  9:25         ` Alan Modra
2021-03-18 12:30           ` Nick Alcock
2021-03-19  1:24             ` Alan Modra
2021-03-06  0:40 ` [PATCH 10/16] libctf: don't lose track of all valid types upon serialization Nick Alcock
2021-03-06  0:40 ` [PATCH 11/16] libctf: do not corrupt strings across ctf_serialize Nick Alcock
2021-03-06  0:40 ` [PATCH 12/16] libctf: eliminate dtd_u, part 4: enums Nick Alcock
2021-03-06  0:40 ` [PATCH 13/16] libctf: eliminate dtd_u, part 5: structs / unions Nick Alcock
2021-03-06  0:40 ` [PATCH 14/16] libctf: types: unify code dealing with small-vs-large struct members Nick Alcock
2021-03-06  0:40 ` [PATCH 15/16] libctf: a couple of small error-handling fixes Nick Alcock
2021-03-06  0:40 ` [PATCH 16/16] libctf: support encodings for enums Nick Alcock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210306004023.164154-6-nick.alcock@oracle.com \
    --to=nick.alcock@oracle.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).