[04/13] constify maint.c

Message ID 1406055319-26380-5-git-send-email-tromey@redhat.com
State Committed
Headers

Commit Message

Tom Tromey July 22, 2014, 6:55 p.m. UTC
  This does a bit of constification in maint.c, making
print_bfd_section_info a bit cleaner in the process.

2014-07-22  Tom Tromey  <tromey@redhat.com>

	* maint.c (match_bfd_flags): Make "string" const.
	(print_bfd_section_info): Remove casts.
	(print_objfile_section_info): Make "string" const.
---
 gdb/ChangeLog |  6 ++++++
 gdb/maint.c   | 13 +++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)
  

Comments

Pedro Alves July 24, 2014, 1:47 a.m. UTC | #1
On 07/22/2014 07:55 PM, Tom Tromey wrote:

>  {
>    flagword flags = bfd_get_section_flags (abfd, asect);
>    const char *name = bfd_section_name (abfd, asect);
> +  const char *arg = datum;
>  
> -  if (arg == NULL || *((char *) arg) == '\0'
> -      || match_substring ((char *) arg, name)
> -      || match_bfd_flags ((char *) arg, flags))
> +  if (arg == NULL || *(arg) == '\0'

I wouldn't mind removing the unnecessary parens
in '*(arg)' while we're touching this.

But, looks good.

Thanks,
Pedro Alves
  
Tom Tromey July 24, 2014, 3:17 p.m. UTC | #2
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> I wouldn't mind removing the unnecessary parens
Pedro> in '*(arg)' while we're touching this.

I agree.  I'm making this change.

Tom
  

Patch

diff --git a/gdb/maint.c b/gdb/maint.c
index c7a937c..336856c 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -236,7 +236,7 @@  match_substring (const char *string, const char *substr)
 }
 
 static int 
-match_bfd_flags (char *string, flagword flags)
+match_bfd_flags (const char *string, flagword flags)
 {
   if (flags & SEC_ALLOC)
     if (match_substring (string, "ALLOC"))
@@ -324,14 +324,15 @@  maint_print_section_info (const char *name, flagword flags,
 static void
 print_bfd_section_info (bfd *abfd, 
 			asection *asect, 
-			void *arg)
+			void *datum)
 {
   flagword flags = bfd_get_section_flags (abfd, asect);
   const char *name = bfd_section_name (abfd, asect);
+  const char *arg = datum;
 
-  if (arg == NULL || *((char *) arg) == '\0'
-      || match_substring ((char *) arg, name)
-      || match_bfd_flags ((char *) arg, flags))
+  if (arg == NULL || *(arg) == '\0'
+      || match_substring (arg, name)
+      || match_bfd_flags (arg, flags))
     {
       struct gdbarch *gdbarch = gdbarch_from_bfd (abfd);
       int addr_size = gdbarch_addr_bit (gdbarch) / 8;
@@ -348,7 +349,7 @@  print_bfd_section_info (bfd *abfd,
 static void
 print_objfile_section_info (bfd *abfd, 
 			    struct obj_section *asect, 
-			    char *string)
+			    const char *string)
 {
   flagword flags = bfd_get_section_flags (abfd, asect->the_bfd_section);
   const char *name = bfd_section_name (abfd, asect->the_bfd_section);