public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: binutils@sourceware.org
Subject: [PATCH 5/5] bfd: Rename Chunk and S3Forced
Date: Fri, 17 Feb 2017 00:24:00 -0000	[thread overview]
Message-ID: <1487290680-24260-6-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1487290680-24260-1-git-send-email-palves@redhat.com>

The direct references in objcopy kind of look like a hack to me, so
I'm calling these symbols internal too.  Certainly they aren't named
and documented as a public BFD symbol today anyway.

So ... give these bfd-internal symbols with external linkage a _bfd_
prefix to avoid collisions in the global symbol namespace.

While at it, give them names that more closely match the corresponding
option name that toggles them.

Also while at it, fix a few related comment typos.

gdb/ChangeLog:
2017-02-16  Pedro Alves  <palves@redhat.com>

	* srec.c (Chunk): Rename to ...
	(_bfd_srec_len): ... this.
	(S3Forced): Rename to ...
	(_bfd_srec_forceS3): ... this.
	* objcopy.c: Adjust all references.
---
 bfd/srec.c         | 22 +++++++++++-----------
 binutils/objcopy.c | 12 ++++++------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/bfd/srec.c b/bfd/srec.c
index 5ebab79..6d9b9a4 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -129,12 +129,12 @@ static const char digs[] = "0123456789ABCDEF";
 /* The number of data bytes we actually fit onto a line on output.
    This variable can be modified by objcopy's --srec-len parameter.
    For a 0x75 byte record you should set --srec-len=0x70.  */
-unsigned int Chunk = DEFAULT_CHUNK;
+unsigned int _bfd_srec_len = DEFAULT_CHUNK;
 
 /* The type of srec output (free or forced to S3).
    This variable can be modified by objcopy's --srec-forceS3
    parameter.  */
-bfd_boolean S3Forced = FALSE;
+bfd_boolean _bfd_srec_forceS3 = FALSE;
 
 /* When writing an S-record file, the S-records can not be output as
    they are seen.  This structure is used to hold them in memory.  */
@@ -904,9 +904,9 @@ srec_set_section_contents (bfd *abfd,
 	return FALSE;
       memcpy ((void *) data, location, (size_t) bytes_to_do);
 
-      /* Ff S3Forced is TRUE then always select S3 records,
-	 regardless of the siez of the addresses.  */
-      if (S3Forced)
+      /* If _bfd_srec_forceS3 is TRUE then always select S3 records,
+	 regardless of the size of the addresses.  */
+      if (_bfd_srec_forceS3)
 	tdata->type = 3;
       else if ((section->lma + (offset + bytes_to_do) / opb - 1) <= 0xffff)
 	;  /* The default, S1, is OK.  */
@@ -1040,18 +1040,18 @@ srec_write_section (bfd *abfd,
      have three, and S3 (tdata->type == 3) records have four.
      The total length can't exceed 255, and a zero data length will
      spin for a long time.  */
-  if (Chunk == 0)
-    Chunk = 1;
-  else if (Chunk > MAXCHUNK - tdata->type - 2)
-    Chunk = MAXCHUNK - tdata->type - 2;
+  if (_bfd_srec_len == 0)
+    _bfd_srec_len = 1;
+  else if (_bfd_srec_len > MAXCHUNK - tdata->type - 2)
+    _bfd_srec_len = MAXCHUNK - tdata->type - 2;
 
   while (octets_written < list->size)
     {
       bfd_vma address;
       unsigned int octets_this_chunk = list->size - octets_written;
 
-      if (octets_this_chunk > Chunk)
-	octets_this_chunk = Chunk;
+      if (octets_this_chunk > _bfd_srec_len)
+	octets_this_chunk = _bfd_srec_len;
 
       address = list->where + octets_written / bfd_octets_per_byte (abfd);
 
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 2636ab4..9291b3a 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -491,14 +491,14 @@ extern char *program_name;
    -1 means if we should use argv[0] to decide.  */
 extern int is_strip;
 
-/* The maximum length of an S record.  This variable is declared in srec.c
+/* The maximum length of an S record.  This variable is defined in srec.c
    and can be modified by the --srec-len parameter.  */
-extern unsigned int Chunk;
+extern unsigned int _bfd_srec_len;
 
 /* Restrict the generation of Srecords to type S3 only.
-   This variable is declare in bfd/srec.c and can be toggled
+   This variable is defined in bfd/srec.c and can be toggled
    on by the --srec-forceS3 command line switch.  */
-extern bfd_boolean S3Forced;
+extern bfd_boolean _bfd_srec_forceS3;
 
 /* Forward declarations.  */
 static void setup_section (bfd *, asection *, void *);
@@ -4509,11 +4509,11 @@ copy_main (int argc, char *argv[])
 	  break;
 
 	case OPTION_SREC_LEN:
-	  Chunk = parse_vma (optarg, "--srec-len");
+	  _bfd_srec_len = parse_vma (optarg, "--srec-len");
 	  break;
 
 	case OPTION_SREC_FORCES3:
-	  S3Forced = TRUE;
+	  _bfd_srec_forceS3 = TRUE;
 	  break;
 
 	case OPTION_STRIP_SYMBOLS:
-- 
2.5.5

  parent reply	other threads:[~2017-02-17  0:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17  0:18 [PATCH 0/5] Rename a few internal symbols to avoid collisions Pedro Alves
2017-02-17  0:18 ` [PATCH 2/5] bfd: Rename real_{ftell, fseek, fopen} Pedro Alves
2017-02-17  0:18 ` [PATCH 1/5] bfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128 Pedro Alves
2017-02-17  0:18 ` [PATCH 3/5] bfd: Rename warn_deprecated Pedro Alves
2017-02-17  0:24 ` Pedro Alves [this message]
2017-02-17  0:24 ` [PATCH 4/5] bfd: Rename bsd_write_armap and coff_write_armap Pedro Alves
2017-02-17  1:06 ` [PATCH 0/5] Rename a few internal symbols to avoid collisions Alan Modra
2017-02-17  2:16   ` Pedro Alves
2017-02-17  2:30     ` Pedro Alves
2017-02-17  2:53       ` Alan Modra

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=1487290680-24260-6-git-send-email-palves@redhat.com \
    --to=palves@redhat.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).