This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[libvtv] Fix formatting errors


While looking at libvtv for the Solaris port, I noticed all sorts of GNU
Coding Standard violations:

* ChangeLog entries attributed to the committer instead of the author
  and with misformatted PR references, entries only giving a vague
  rational instead of what changed

* overlong lines

* tons of whitespace errors (though I may be wrong in some cases: C++
  code might have other rules)

* code formatting that seems to have been done to be visually pleasing,
  completely different from what Emacs does

* commented code fragments (#if 0 equivalent)

* configure.tgt target list in no recognizable order

* the Cygwin/MingW port is done in the worst possible way: tons of
  target-specific ifdefs instead of feature-specific conditionals or an
  interface that can wrap both Cygwin and Linux variants of the code

The following patch (as yet not even compiled) fixes some of the most
glaring errors.  The Solaris port will fix a few of the latter ones.

Do you think this is the right direction or did I get something wrong?

Thanks.
        Rainer


2015-08-26  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	Fix formatting errors.

# HG changeset patch
# Parent 6459822b8e6fa7647ad0d12ffb6f3da7bd0c5db2
Fix formatting errors

diff --git a/libvtv/ChangeLog b/libvtv/ChangeLog
--- a/libvtv/ChangeLog
+++ b/libvtv/ChangeLog
@@ -1,6 +1,6 @@
-2015-08-01  Caroline Tice  <cmtice@google.com>
+2015-08-01  Eric Gallager  <egall@gwmail.gwu.edu>
 
-	PR 66521
+	PR bootstrap/66521
 	* Makefile.am:  Update to match latest tree.
 	* Makefile.in: Regenerate.
 	* testsuite/lib/libvtv: Brought up to date.
@@ -24,15 +24,13 @@ 2015-02-09  Thomas Schwinge  <thomas@cod
 	* configure: Likewise.
 	* testsuite/Makefile.in: Likewise.
 
-2015-01-29  Caroline Tice  <cmtice@google.com>
+2015-01-29  Patrick Wollgast  <patrick.wollgast@rub.de>
 
-	Committing VTV Cywin/Ming patch for Patrick Wollgast
 	* libvtv/Makefile.in : Regenerate.
 	* libvtv/configure : Regenerate.
 
-2015-01-28  Caroline Tice  <cmtice@google.com>
+2015-01-28  Patrick Wollgast  <patrick.wollgast@rub.de>
 
-	Committing VTV Cywin/Ming patch for Patrick Wollgast
 	* libvtv/Makefile.am : Add libvtv.la to toolexeclib_LTLIBRARIES, if
 	VTV_CYGMIN is set. Define libvtv_la_LIBADD, libvtv_la_LDFLAGS,
 	libvtv_stubs_la_LDFLAGS and libvtv_stubs_la_SOURCES if VTV_CYGMIN is
diff --git a/libvtv/vtv_fail.cc b/libvtv/vtv_fail.cc
--- a/libvtv/vtv_fail.cc
+++ b/libvtv/vtv_fail.cc
@@ -38,9 +38,7 @@
    desired.  This may be the case if the programmer has to deal wtih
    unverified third party software, for example.  __vtv_really_fail is
    available for the programmer to call from his version of
-   __vtv_verify_fail, if he decides the failure is real.
-
-*/
+   __vtv_verify_fail, if he decides the failure is real.  */
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -80,8 +78,8 @@ const unsigned long SET_HANDLE_HANDLE_BI
 
 /* Instantiate the template classes (in vtv_set.h) for our particular
    hash table needs.  */
-typedef void * vtv_set_handle;
-typedef vtv_set_handle * vtv_set_handle_handle; 
+typedef void *vtv_set_handle;
+typedef vtv_set_handle *vtv_set_handle_handle; 
 
 static int vtv_failures_log_fd = -1;
 
@@ -121,17 +119,16 @@ log_error_message (const char *log_msg, 
    variable.  */
 
 static inline bool
-is_set_handle_handle (void * ptr)
+is_set_handle_handle (void *ptr)
 {
-  return ((unsigned long) ptr & SET_HANDLE_HANDLE_BIT)
-                                                      == SET_HANDLE_HANDLE_BIT;
+  return ((unsigned long) ptr & SET_HANDLE_HANDLE_BIT) == SET_HANDLE_HANDLE_BIT;
 }
 
 /* Returns the actual pointer value of a vtable map variable, PTR (see
    comments for is_set_handle_handle for more details).  */
 
 static inline vtv_set_handle * 
-ptr_from_set_handle_handle (void * ptr)
+ptr_from_set_handle_handle (void *ptr)
 {
   return (vtv_set_handle *) ((unsigned long) ptr & ~SET_HANDLE_HANDLE_BIT);
 }
@@ -141,7 +138,7 @@ ptr_from_set_handle_handle (void * ptr)
    variable.  */
 
 static inline vtv_set_handle_handle
-set_handle_handle (vtv_set_handle * ptr)
+set_handle_handle (vtv_set_handle *ptr)
 {
   return (vtv_set_handle_handle) ((unsigned long) ptr | SET_HANDLE_HANDLE_BIT);
 }
@@ -151,7 +148,7 @@ set_handle_handle (vtv_set_handle * ptr)
    file, then calls __vtv_verify_fail.  SET_HANDLE_PTR is the pointer
    to the set of valid vtable pointers, VTBL_PTR is the pointer that
    was not found in the set, and DEBUG_MSG is the message to be
-   written to the log file before failing. n */
+   written to the log file before failing.  */
 
 void
 __vtv_verify_fail_debug (void **set_handle_ptr, const void *vtbl_ptr, 
@@ -197,9 +194,9 @@ vtv_fail (const char *msg, void **data_s
                  "*** Unable to verify vtable pointer (%p) in set (%p) *** \n";
 
   snprintf (buffer, sizeof (buffer), format_str, vtbl_ptr,
-            is_set_handle_handle(*data_set_ptr) ?
-              ptr_from_set_handle_handle (*data_set_ptr) :
-	      *data_set_ptr);
+            is_set_handle_handle(*data_set_ptr)
+	    ? ptr_from_set_handle_handle (*data_set_ptr)
+	    : *data_set_ptr);
   buf_len = strlen (buffer);
   /*  Send this to to stderr.  */
   write (2, buffer, buf_len);
@@ -221,9 +218,9 @@ void
   char log_msg[256];
   snprintf (log_msg, sizeof (log_msg), "Looking for vtable %p in set %p.\n",
             vtbl_ptr,
-            is_set_handle_handle (*data_set_ptr) ?
-              ptr_from_set_handle_handle (*data_set_ptr) :
-              *data_set_ptr);
+            is_set_handle_handle (*data_set_ptr)
+	    ? ptr_from_set_handle_handle (*data_set_ptr)
+	    : *data_set_ptr);
   log_error_message (log_msg, false);
 
   const char *format_str =
diff --git a/libvtv/vtv_fail.h b/libvtv/vtv_fail.h
--- a/libvtv/vtv_fail.h
+++ b/libvtv/vtv_fail.h
@@ -28,7 +28,7 @@
   abort.  It is here for programmers to call, presumably from
   __vtv_verify_fail, if they choose to overwrite the standard
   __vtv_verify_fail with one of their own.  Programmers should NOT
-  attempt to rewrite __vtv_really_fail. */
+  attempt to rewrite __vtv_really_fail.  */
 
 extern void
 __vtv_really_fail (const char *fail_msg)
diff --git a/libvtv/vtv_malloc.cc b/libvtv/vtv_malloc.cc
--- a/libvtv/vtv_malloc.cc
+++ b/libvtv/vtv_malloc.cc
@@ -58,7 +58,7 @@ unsigned int long long mprotect_cycles =
 
 /* Put the following variables in our ".vtable_map_vars" section so
    that they are protected.  They are explicitly unprotected and
-   protected again by calls to __vtv_unprotect and __vtv_protect */
+   protected again by calls to __vtv_unprotect and __vtv_protect.  */
 
 static struct obstack vtv_obstack VTV_PROTECTED_VAR;
 static void *current_chunk VTV_PROTECTED_VAR = 0;
@@ -84,7 +84,7 @@ int
 __vtv_count_mmapped_pages (void)
 {
   int count = 0;
-  struct _obstack_chunk * ci = (struct _obstack_chunk *) current_chunk;
+  struct _obstack_chunk *ci = (struct _obstack_chunk *) current_chunk;
   while (ci)
     {
       count++;
@@ -115,7 +115,6 @@ change_protections_on_data_chunks (int p
       unsigned long long start, end;
       int result;
 
-
       /* As long as the next 'chunk' is adjacent to the current one,
          keep going down the list.  */
       do
@@ -179,7 +178,7 @@ obstack_chunk_alloc (size_t size)
 
 #if defined (__CYGWIN__) || defined (__MINGW32__)
   if ((allocated = VirtualAlloc(NULL, size,  MEM_RESERVE|MEM_COMMIT,
-                         PAGE_READWRITE)) == 0)
+				PAGE_READWRITE)) == 0)
 #else
   if ((allocated = mmap (NULL, size, PROT_READ | PROT_WRITE,
                          MAP_PRIVATE | MAP_ANONYMOUS,  -1, 0)) == 0)
@@ -196,8 +195,8 @@ obstack_chunk_alloc (size_t size)
 static void
 obstack_chunk_free (size_t)
 {
-  /* Do nothing. For our purposes there should be very little
-     de-allocation. */
+  /* Do nothing.  For our purposes there should be very little
+     de-allocation.  */
 }
 
 /* This function sets up and initializes the obstack pieces for our
@@ -221,7 +220,7 @@ void
   obstack_alignment_mask (&vtv_obstack) = sizeof (long) - 1;
   /* We guarantee that the obstack alloc failed handler will never be
      called because in case the allocation of the chunk fails, it will
-     never return */
+     never return.  */
   obstack_alloc_failed_handler = NULL;
 
   obstack_init (&vtv_obstack);
@@ -229,7 +228,7 @@ void
 }
 
 /* This is our external interface for the memory allocation.  SIZE is
-   the requested number of bytes to be allocated/  */
+   the requested number of bytes to be allocated.  */
 
 void *
 __vtv_malloc (size_t size)
@@ -254,7 +253,7 @@ void
 __vtv_malloc_stats (void)
 {
   int count = 0;
-  struct _obstack_chunk * ci = (struct _obstack_chunk *) current_chunk;
+  struct _obstack_chunk *ci = (struct _obstack_chunk *) current_chunk;
   while (ci)
     {
       count++;
@@ -280,7 +279,7 @@ void
     return;
 
   int count = 0;
-  struct _obstack_chunk * ci = (struct _obstack_chunk *) current_chunk;
+  struct _obstack_chunk *ci = (struct _obstack_chunk *) current_chunk;
   while (ci)
     {
       count++;
diff --git a/libvtv/vtv_malloc.h b/libvtv/vtv_malloc.h
--- a/libvtv/vtv_malloc.h
+++ b/libvtv/vtv_malloc.h
@@ -87,7 +87,7 @@ extern unsigned long long regpair_cycles
 
 extern void __vtv_malloc_init (void);
 extern void *__vtv_malloc (size_t size) __attribute__ ((malloc));
-extern void __vtv_free (void * ptr);
+extern void __vtv_free (void *ptr);
 extern void __vtv_malloc_protect (void);
 extern void __vtv_malloc_unprotect (void);
 extern void __vtv_malloc_stats (void);
diff --git a/libvtv/vtv_rts.cc b/libvtv/vtv_rts.cc
--- a/libvtv/vtv_rts.cc
+++ b/libvtv/vtv_rts.cc
@@ -34,56 +34,56 @@
    the valid set, execution is allowed to continue; otherwise the
    program is halted.
 
-  There are several pieces needed in order to make this work: 1. For
-  every virtual class in the program (i.e. a class that contains
-  virtual methods), we need to build the set of all possible valid
-  vtables that an object of that class could point to.  This includes
-  vtables for any class(es) that inherit from the class under
-  consideration.  2. For every such data set we build up, we need a
-  way to find and reference the data set.  This is complicated by the
-  fact that the real vtable addresses are not known until runtime,
-  when the program is loaded into memory, but we need to reference the
-  sets at compile time when we are inserting verification calls into
-  the program.  3.  We need to find every virtual call in the program,
-  and insert the verification call (with the appropriate arguments)
-  before the virtual call.  4. We need some runtime library pieces:
-  the code to build up the data sets at runtime; the code to actually
-  perform the verification using the data sets; and some code to set
-  protections on the data sets, so they themselves do not become
-  hacker targets.
+   There are several pieces needed in order to make this work: 1. For
+   every virtual class in the program (i.e. a class that contains
+   virtual methods), we need to build the set of all possible valid
+   vtables that an object of that class could point to.  This includes
+   vtables for any class(es) that inherit from the class under
+   consideration.  2. For every such data set we build up, we need a
+   way to find and reference the data set.  This is complicated by the
+   fact that the real vtable addresses are not known until runtime,
+   when the program is loaded into memory, but we need to reference the
+   sets at compile time when we are inserting verification calls into
+   the program.  3.  We need to find every virtual call in the program,
+   and insert the verification call (with the appropriate arguments)
+   before the virtual call.  4. We need some runtime library pieces:
+   the code to build up the data sets at runtime; the code to actually
+   perform the verification using the data sets; and some code to set
+   protections on the data sets, so they themselves do not become
+   hacker targets.
 
-  To find and reference the set of valid vtable pointers for any given
-  virtual class, we create a special global varible for each virtual
-  class.  We refer to this as the "vtable map variable" for that
-  class.  The vtable map variable has the type "void *", and is
-  initialized by the compiler to NULL.  At runtime when the set of
-  valid vtable pointers for a virtual class, e.g. class Foo, is built,
-  the vtable map variable for class Foo is made to point to the set.
-  During compile time, when the compiler is inserting verification
-  calls into the program, it passes the vtable map variable for the
-  appropriate class to the verification call, so that at runtime the
-  verification call can find the appropriate data set.
+   To find and reference the set of valid vtable pointers for any given
+   virtual class, we create a special global varible for each virtual
+   class.  We refer to this as the "vtable map variable" for that
+   class.  The vtable map variable has the type "void *", and is
+   initialized by the compiler to NULL.  At runtime when the set of
+   valid vtable pointers for a virtual class, e.g. class Foo, is built,
+   the vtable map variable for class Foo is made to point to the set.
+   During compile time, when the compiler is inserting verification
+   calls into the program, it passes the vtable map variable for the
+   appropriate class to the verification call, so that at runtime the
+   verification call can find the appropriate data set.
 
-  The actual set of valid vtable pointers for a polymorphic class,
-  e.g. class Foo, cannot be built until runtime, when the vtables get
-  loaded into memory and their addresses are known.  But the knowledge
-  about which vtables belong in which class' hierarchy is only known
-  at compile time.  Therefore at compile time we collect class
-  hierarchy and vtable information about every virtual class, and we
-  generate calls to build up the data sets at runtime.  To build the
-  data sets, we call one of the functions we add to the runtime
-  library, __VLTRegisterPair.  __VLTRegisterPair takes two arguments,
-  a vtable map variable and the address of a vtable.  If the vtable
-  map variable is currently NULL, it creates a new data set (hash
-  table), makes the vtable map variable point to the new data set, and
-  inserts the vtable address into the data set.  If the vtable map
-  variable is not NULL, it just inserts the vtable address into the
-  data set.  In order to make sure that our data sets are built before
-  any verification calls happen, we create a special constructor
-  initialization function for each compilation unit, give it a very
-  high initialization priority, and insert all of our calls to
-  __VLTRegisterPair into our special constructor initialization
-  function.  */
+   The actual set of valid vtable pointers for a polymorphic class,
+   e.g. class Foo, cannot be built until runtime, when the vtables get
+   loaded into memory and their addresses are known.  But the knowledge
+   about which vtables belong in which class' hierarchy is only known
+   at compile time.  Therefore at compile time we collect class
+   hierarchy and vtable information about every virtual class, and we
+   generate calls to build up the data sets at runtime.  To build the
+   data sets, we call one of the functions we add to the runtime
+   library, __VLTRegisterPair.  __VLTRegisterPair takes two arguments,
+   a vtable map variable and the address of a vtable.  If the vtable
+   map variable is currently NULL, it creates a new data set (hash
+   table), makes the vtable map variable point to the new data set, and
+   inserts the vtable address into the data set.  If the vtable map
+   variable is not NULL, it just inserts the vtable address into the
+   data set.  In order to make sure that our data sets are built before
+   any verification calls happen, we create a special constructor
+   initialization function for each compilation unit, give it a very
+   high initialization priority, and insert all of our calls to
+   __VLTRegisterPair into our special constructor initialization
+   function.  */
 
 /* This file contains the main externally visible runtime library
    functions for vtable verification: __VLTChangePermission,
@@ -137,7 +137,7 @@
 #include <fcntl.h>
 #include <limits.h>
 
-/* For gthreads suppport */
+/* For gthreads suppport.  */
 #include <bits/c++config.h>
 #include <ext/concurrence.h>
 
@@ -176,7 +176,7 @@ extern "C" {
 #endif
 
 /* The following variables are used only for debugging and performance
-   tuning purposes. Therefore they do not need to be "protected".
+   tuning purposes.  Therefore they do not need to be "protected".
    They cannot be used to attack the vtable verification system and if
    they become corrupted it will not affect the correctness or
    security of any of the rest of the vtable verification feature.  */
@@ -192,12 +192,12 @@ unsigned long long verify_vtable_cycles 
    the routines below are called before any runtime initialization for
    statics in this file will be done. For example, dont try to
    initialize any of these statics with a runtime call (for ex:
-   sysconf). The initialization will happen after calls to the routines
-   to protect/unprotec the vtabla_map variables */
+   sysconf).  The initialization will happen after calls to the routines
+   to protect/unprotect the vtable_map variables.  */
 
 /* No need to mark the following variables with VTV_PROTECTED_VAR.
    These are either const or are only used for debugging/tracing.
-   debugging/tracing will not be ON on production environments */
+   debugging/tracing will not be ON on production environments.  */
 
 static const bool debug_hash = HASHTABLE_STATS;
 
@@ -237,13 +237,13 @@ static __gthread_mutex_t change_permissi
 static inline unsigned long long
 get_cycle_count (void)
 {
-  return rdtsc();
+  return rdtsc ();
 }
 
 static inline void
 accumulate_cycle_count (unsigned long long *sum, unsigned long long start)
 {
-  unsigned long long end = rdtsc();
+  unsigned long long end = rdtsc ();
   *sum = *sum + (end - start);
 }
 
@@ -319,8 +319,8 @@ struct vptr_set_alloc
    hash table needs.  */
 typedef insert_only_hash_sets<int_vptr, vptr_hash, vptr_set_alloc> vtv_sets;
 typedef vtv_sets::insert_only_hash_set vtv_set;
-typedef vtv_set * vtv_set_handle;
-typedef vtv_set_handle * vtv_set_handle_handle; 
+typedef vtv_set *vtv_set_handle;
+typedef vtv_set_handle *vtv_set_handle_handle; 
 
 /* Records for caching the section header information that we have
    read out of the file(s) on disk (in dl_iterate_phdr_callback), to
@@ -478,7 +478,7 @@ read_section_offset_and_length (char *na
 
           PIMAGE_SECTION_HEADER sect_hdr = 
             (PIMAGE_SECTION_HEADER)((char *)&pNtHeaders->OptionalHeader
-                                       + pFileHeader->SizeOfOptionalHeader);
+				    + pFileHeader->SizeOfOptionalHeader);
 
           /* Loop through all the section headers, looking for one whose
              name is ".vtable_map_vars".  */
@@ -491,13 +491,11 @@ read_section_offset_and_length (char *na
                  table. */
               if (sect_hdr[i].Name[0] == '/')
                 {
-                  if (atoi((const char*)sect_hdr[i].Name+1) == 0)
-                    {
-                      continue;
-                    }
+                  if (atoi((const char*) sect_hdr[i].Name + 1) == 0)
+		    continue;
 
                   off_t name_offset = PointerToStringTable
-                                       + atoi((const char*)sect_hdr[i].Name+1);
+		    + atoi((const char*)sect_hdr[i].Name + 1);
 
                   size_t bytes_read = ReadFromOffset (fd, &header_name, 64,
                                                       name_offset);
@@ -505,21 +503,19 @@ read_section_offset_and_length (char *na
                   VTV_ASSERT (bytes_read > 0);
                 }
               else
-                {
-                  memcpy (&header_name, sect_hdr[i].Name,
-                          sizeof (sect_hdr[i].Name));
-                }
+		memcpy (&header_name, sect_hdr[i].Name,
+			sizeof (sect_hdr[i].Name));
 
               if (memcmp (header_name, sect_name, name_len) == 0)
                 {
                   /* We found the section; get its load offset and
                      size.  */
                   *sect_offset = sect_hdr[i].VirtualAddress;
-      if (sect_hdr[i].Misc.VirtualSize % VTV_PAGE_SIZE != 0)
-        *sect_len = sect_hdr[i].Misc.VirtualSize + VTV_PAGE_SIZE
-                     - (sect_hdr[i].Misc.VirtualSize % VTV_PAGE_SIZE);
-      else
-        *sect_len = sect_hdr[i].Misc.VirtualSize;
+		  if (sect_hdr[i].Misc.VirtualSize % VTV_PAGE_SIZE != 0)
+		    *sect_len = sect_hdr[i].Misc.VirtualSize + VTV_PAGE_SIZE
+		      - (sect_hdr[i].Misc.VirtualSize % VTV_PAGE_SIZE);
+		  else
+		    *sect_len = sect_hdr[i].Misc.VirtualSize;
                   found = true;
                 }
             }
@@ -623,7 +619,7 @@ read_section_offset_and_length (struct d
           ElfW (Half) strtab_idx = ehdr_info->e_shstrndx;
           ElfW (Shdr) shstrtab;
           off_t shstrtab_offset = ehdr_info->e_shoff +
-                                         (ehdr_info->e_shentsize * strtab_idx);
+	    (ehdr_info->e_shentsize * strtab_idx);
           size_t bytes_read = ReadFromOffset (fd, &shstrtab, sizeof (shstrtab),
                                               shstrtab_offset);
           VTV_ASSERT (bytes_read == sizeof (shstrtab));
@@ -678,7 +674,7 @@ read_section_offset_and_length (struct d
       /* Calculate the page location in memory, making sure the
          address is page-aligned.  */
       ElfW (Addr) start_addr = (const ElfW (Addr)) info->dlpi_addr
-                                                                 + *sect_offset;
+	+ *sect_offset;
       *sect_offset = start_addr & ~(VTV_PAGE_SIZE - 1);
       *sect_len = *sect_len - 1;
 
@@ -703,9 +699,9 @@ read_section_offset_and_length (struct d
 
 #if defined (__CYGWIN__) || defined (__MINGW32__)
 /* This function is used to iterate over all loaded modules and searches
-   for a section called ".vtable_map_vars". The only interaction with 
+   for a section called ".vtable_map_vars".  The only interaction with 
    the binary file on disk of the module is to read section names in the
-   COFF string table. If the module contains a ".vtable_map_vars" section,
+   COFF string table.  If the module contains a ".vtable_map_vars" section,
    read section offset and size from the section header of the loaded module.
    Call 'mprotect' on those pages, setting the protection either to
    read-only or read-write, depending on what's in data.
@@ -715,7 +711,7 @@ read_section_offset_and_length (struct d
 static int
 iterate_modules (void *data)
 {
-  int * mprotect_flags = (int *) data;
+  int *mprotect_flags = (int *) data;
   off_t map_sect_offset = 0;
   WORD map_sect_len = 0;
   char buffer[1024];
@@ -737,7 +733,7 @@ iterate_modules (void *data)
           char szModName[MAX_PATH];
 
           if (GetModuleFileNameExA (hProcess, hMods[i], szModName,
-                        sizeof (szModName)))
+				    sizeof (szModName)))
             {
               map_sect_offset = 0;
               map_sect_len = 0;
@@ -832,7 +828,7 @@ iterate_modules (void *data)
 static int
 dl_iterate_phdr_callback (struct dl_phdr_info *info, size_t, void *data)
 {
-  int * mprotect_flags = (int *) data;
+  int *mprotect_flags = (int *) data;
   off_t map_sect_offset = 0;
   ElfW (Word) map_sect_len = 0;
   char buffer[1024];
@@ -846,8 +842,7 @@ dl_iterate_phdr_callback (struct dl_phdr
   if (strcmp (info->dlpi_name, "linux-vdso.so.1") == 0)
     return 0;
 
-  if (strlen (info->dlpi_name) == 0
-      && info->dlpi_addr != 0)
+  if (strlen (info->dlpi_name) == 0 && info->dlpi_addr != 0)
     return 0;
 
   /* Get the name of the main executable.  This may or may not include
@@ -946,7 +941,7 @@ dl_iterate_phdr_callback (struct dl_phdr
 static void
 change_protections_on_phdr_cache (int protection_flag)
 {
-  char * low_address = (char *) &(vtv_sect_info_cache);
+  char *low_address = (char *) &(vtv_sect_info_cache);
   size_t cache_size = MAX_ENTRIES * sizeof (struct sect_hdr_data);
 
   low_address = (char *) ((uintptr_t) low_address & ~(VTV_PAGE_SIZE - 1));
@@ -956,8 +951,8 @@ change_protections_on_phdr_cache (int pr
 }
 
 /* Unprotect all the vtable map vars and other side data that is used
-   to keep the core hash_map data. All of these data have been put
-   into relro sections */
+   to keep the core hash_map data.  All of these data have been put
+   into relro sections.  */
 
 static void
 vtv_unprotect_vtable_vars (void)
@@ -974,8 +969,8 @@ vtv_unprotect_vtable_vars (void)
 }
 
 /* Protect all the vtable map vars and other side data that is used
-   to keep the core hash_map data. All of these data have been put
-   into relro sections */
+   to keep the core hash_map data.  All of these data have been put
+   into relro sections.  */
 
 static void
 vtv_protect_vtable_vars (void)
@@ -1034,11 +1029,11 @@ static void
 log_set_stats (void)
 {
 #if HASHTABLE_STATS
-      if (set_log_fd == -1)
-	set_log_fd = __vtv_open_log ("vtv_set_stats.log");
+  if (set_log_fd == -1)
+    set_log_fd = __vtv_open_log ("vtv_set_stats.log");
 
-      __vtv_add_to_log (set_log_fd, "---\n%s\n",
-			insert_only_hash_tables_stats().c_str());
+  __vtv_add_to_log (set_log_fd, "---\n%s\n",
+		    insert_only_hash_tables_stats().c_str());
 #endif
 }
 
@@ -1047,7 +1042,7 @@ log_set_stats (void)
    contain our vtable map variables).  PERM indicates whether to make
    the permissions read-only or read-write.  */
 
-extern "C" /* This is only being applied to __VLTChangePermission*/
+extern "C" /* This is only being applied to __VLTChangePermission.  */
 void
 __VLTChangePermission (int perm)
 {
@@ -1071,11 +1066,11 @@ void
   /* Ordering of these unprotect/protect calls is very important.
      You first need to unprotect all the map vars and side
      structures before you do anything with the core data
-     structures (hash_maps) */
+     structures (hash_maps).  */
 
   if (perm == __VLTP_READ_WRITE)
     {
-      /* TODO: Need to revisit this code for dlopen. It most probably
+      /* TODO: Need to revisit this code for dlopen.  It most probably
          is not unlocking the protected vtable vars after for load
          module that is not the first load module.  */
       __gthread_mutex_lock (&change_permissions_lock);
@@ -1132,7 +1127,7 @@ typedef insert_only_hash_map <vtv_set_ha
                               insert_only_hash_map_allocator > s2s;
 typedef const s2s::key_type  vtv_symbol_key;
 
-static s2s * vtv_symbol_unification_map VTV_PROTECTED_VAR = NULL;
+static s2s *vtv_symbol_unification_map VTV_PROTECTED_VAR = NULL;
 
 const unsigned long SET_HANDLE_HANDLE_BIT = 0x2;
 
@@ -1145,17 +1140,16 @@ const unsigned long SET_HANDLE_HANDLE_BI
    variable.  */
 
 static inline bool
-is_set_handle_handle (void * ptr)
+is_set_handle_handle (void *ptr)
 {
-  return ((uintptr_t) ptr & SET_HANDLE_HANDLE_BIT)
-                                                      == SET_HANDLE_HANDLE_BIT;
+  return ((uintptr_t) ptr & SET_HANDLE_HANDLE_BIT) == SET_HANDLE_HANDLE_BIT;
 }
 
 /* Returns the actual pointer value of a vtable map variable, PTR (see
    comments for is_set_handle_handle for more details).  */
 
 static inline vtv_set_handle * 
-ptr_from_set_handle_handle (void * ptr)
+ptr_from_set_handle_handle (void *ptr)
 {
   return (vtv_set_handle *) ((uintptr_t) ptr & ~SET_HANDLE_HANDLE_BIT);
 }
@@ -1165,7 +1159,7 @@ ptr_from_set_handle_handle (void * ptr)
    variable.  */
 
 static inline vtv_set_handle_handle
-set_handle_handle (vtv_set_handle * ptr)
+set_handle_handle (vtv_set_handle *ptr)
 {
   return (vtv_set_handle_handle) ((uintptr_t) ptr | SET_HANDLE_HANDLE_BIT);
 }
@@ -1235,7 +1229,7 @@ register_pair_common (void **set_handle_
    using a map from set name to pointer to set handle. Since there
    will be multiple copies of the pointer to the set handle (one per
    compilation unit that uses it), it makes sure to initialize all the
-   pointers to the set handle so that the set handle is unique. To
+   pointers to the set handle so that the set handle is unique.  To
    make this a little more efficient and avoid a level of indirection
    in some cases, the first pointer to handle for a particular handle
    becomes the handle itself and the other pointers will point to the
@@ -1264,7 +1258,7 @@ init_set_symbol_debug (void **set_handle
   vtv_symbol_key *symbol_key_ptr = (vtv_symbol_key *) set_symbol_key;
 
   const s2s::value_type * map_value_ptr =
-                              vtv_symbol_unification_map->get (symbol_key_ptr);
+    vtv_symbol_unification_map->get (symbol_key_ptr);
   char buffer[200];
   if (map_value_ptr == NULL)
     {
@@ -1313,7 +1307,7 @@ init_set_symbol_debug (void **set_handle
         vtv_sets::resize (size_hint, *map_value_ptr);
       else
         {
-          /* The one level handle to the set already exists. So, we
+          /* The one level handle to the set already exists.  So, we
              are adding one level of indirection here and we will
              store a pointer to the one level handle here.  */
 
@@ -1323,13 +1317,13 @@ init_set_symbol_debug (void **set_handle
           VTV_DEBUG_ASSERT(*handle_handle_ptr != NULL);
 
           /* The handle can itself be NULL if the set has only
-             been initiazlied with size hint == 1. */
+             been initiazlied with size hint == 1.  */
           vtv_sets::resize (size_hint, *map_value_ptr);
         }
     }
   else
     {
-      /* We will create a new set. So, in this case handle_ptr is the
+      /* We will create a new set.  So, in this case handle_ptr is the
          one level pointer to the set handle.  Create copy of map name
          in case the memory where this comes from gets unmapped by
          dlclose.  */
@@ -1344,7 +1338,7 @@ init_set_symbol_debug (void **set_handle
                                                      &value_ptr);
       *value_ptr = handle_ptr;
 
-      /*  TODO: We should verify the return value. */
+      /*  TODO: We should verify the return value.  */
       vtv_sets::create (size_hint, handle_ptr);
       VTV_DEBUG_ASSERT (size_hint <= 1 || *handle_ptr != NULL);
     }
@@ -1364,12 +1358,12 @@ init_set_symbol_debug (void **set_handle
 }
 
 
-/* This routine initializes a set handle to a vtable set. It makes
+/* This routine initializes a set handle to a vtable set.  It makes
    sure that there is only one set handle for a particular set by
-   using a map from set name to pointer to set handle. Since there
+   using a map from set name to pointer to set handle.  Since there
    will be multiple copies of the pointer to the set handle (one per
    compilation unit that uses it), it makes sure to initialize all the
-   pointers to the set handle so that the set handle is unique. To
+   pointers to the set handle so that the set handle is unique.  To
    make this a little more efficient and avoid a level of indirection
    in some cases, the first pointer to handle for a particular handle
    becomes the handle itself and the other pointers will point to the
@@ -1416,8 +1410,8 @@ void
   VTV_DEBUG_ASSERT(set_handle_ptr != NULL);
   init_set_symbol_debug (set_handle_ptr, set_symbol_key, size_hint);
 
-  register_pair_common (set_handle_ptr, vtable_ptr, set_symbol_name, vtable_name,
-                        true);
+  register_pair_common (set_handle_ptr, vtable_ptr, set_symbol_name,
+			vtable_name, true);
 
   accumulate_cycle_count (&regpair_cycles, start);
 }
@@ -1479,12 +1473,12 @@ const void *
   return vtable_ptr;
 }
 
-/* This routine initializes a set handle to a vtable set. It makes
+/* This routine initializes a set handle to a vtable set.  It makes
    sure that there is only one set handle for a particular set by
    using a map from set name to pointer to set handle. Since there
    will be multiple copies of the pointer to the set handle (one per
    compilation unit that uses it), it makes sure to initialize all the
-   pointers to the set handle so that the set handle is unique. To
+   pointers to the set handle so that the set handle is unique.  To
    make this a little more efficient and avoid a level of indirection
    in some cases, the first pointer to handle for a particular handle
    becomes the handle itself and the other pointers will point to the
@@ -1492,7 +1486,7 @@ const void *
    variable, SET_SYMBOL_KEY is the hash table key (containing the name
    of the map variable and the hash value) and SIZE_HINT is a guess
    for the best initial size for the set of vtable pointers that
-   SET_HANDLE_POINTER will point to.*/
+   SET_HANDLE_POINTER will point to.  */
 
 static inline void
 init_set_symbol (void **set_handle_ptr, const void *set_symbol_key,
@@ -1515,7 +1509,7 @@ init_set_symbol (void **set_handle_ptr, 
 
   vtv_symbol_key *symbol_key_ptr = (vtv_symbol_key *) set_symbol_key;
   const s2s::value_type *map_value_ptr =
-                              vtv_symbol_unification_map->get (symbol_key_ptr);
+    vtv_symbol_unification_map->get (symbol_key_ptr);
 
   if (map_value_ptr != NULL)
     {
@@ -1523,7 +1517,7 @@ init_set_symbol (void **set_handle_ptr, 
         vtv_sets::resize (size_hint, *map_value_ptr);
       else
         {
-          /* The one level handle to the set already exists. So, we
+          /* The one level handle to the set already exists.  So, we
              are adding one level of indirection here and we will
              store a pointer to the one level pointer here.  */
           vtv_set_handle_handle *handle_handle_ptr =
@@ -1554,12 +1548,12 @@ init_set_symbol (void **set_handle_ptr, 
     }
 }
 
-/* This routine initializes a set handle to a vtable set. It makes
+/* This routine initializes a set handle to a vtable set.  It makes
    sure that there is only one set handle for a particular set by
-   using a map from set name to pointer to set handle. Since there
+   using a map from set name to pointer to set handle.  Since there
    will be multiple copies of the pointer to the set handle (one per
    compilation unit that uses it), it makes sure to initialize all the
-   pointers to the set handle so that the set handle is unique. To
+   pointers to the set handle so that the set handle is unique.  To
    make this a little more efficient and avoid a level of indirection
    in some cases, the first pointer to handle for a particular handle
    becomes the handle itself and the other pointers will point to the
@@ -1567,8 +1561,7 @@ init_set_symbol (void **set_handle_ptr, 
    variable, SET_SYMBOL_KEY is the hash table key (containing the name
    of the map variable and the hash value) and SIZE_HINT is a guess
    for the best initial size for the set of vtable pointers that
-   SET_HANDLE_POINTER will point to.*/
-
+   SET_HANDLE_POINTER will point to.  */
 
 void
 __VLTRegisterSet (void **set_handle_ptr, const void *set_symbol_key,
@@ -1613,7 +1606,7 @@ void
    important for it to be as efficient as possible.  */
 
 const void *
-__VLTVerifyVtablePointer (void ** set_handle_ptr, const void * vtable_ptr)
+__VLTVerifyVtablePointer (void **set_handle_ptr, const void *vtable_ptr)
 {
   unsigned long long start = get_cycle_count ();
   int_vptr vtbl_ptr = (int_vptr) vtable_ptr;
@@ -1664,7 +1657,7 @@ dl_iterate_phdr_count_pages (struct dl_p
     return 0;
 
   read_section_offset_and_length (info, map_sect_name, *mprotect_flags,
-                                 &map_sect_offset, &map_sect_len);
+				  &map_sect_offset, &map_sect_len);
 
   /* See if we actually found the section.  */
   if (map_sect_len)
@@ -1721,7 +1714,7 @@ void
    file, then calls __vtv_verify_fail.  SET_HANDLE_PTR is the pointer
    to the set of valid vtable pointers, VTBL_PTR is the pointer that
    was not found in the set, and DEBUG_MSG is the message to be
-   written to the log file before failing. n */
+   written to the log file before failing.  */
 
 void
 __vtv_verify_fail_debug (void **set_handle_ptr, const void *vtbl_ptr, 
@@ -1767,9 +1760,9 @@ vtv_fail (const char *msg, void **data_s
                  "*** Unable to verify vtable pointer (%p) in set (%p) *** \n";
 
   snprintf (buffer, sizeof (buffer), format_str, vtbl_ptr,
-            is_set_handle_handle(*data_set_ptr) ?
-              ptr_from_set_handle_handle (*data_set_ptr) :
-	      *data_set_ptr);
+            is_set_handle_handle(*data_set_ptr)
+	    ? ptr_from_set_handle_handle (*data_set_ptr)
+	    : *data_set_ptr);
   buf_len = strlen (buffer);
   /*  Send this to to stderr.  */
   write (2, buffer, buf_len);
@@ -1792,9 +1785,9 @@ void
   char log_msg[256];
   snprintf (log_msg, sizeof (log_msg), "Looking for vtable %p in set %p.\n",
             vtbl_ptr,
-            is_set_handle_handle (*data_set_ptr) ?
-              ptr_from_set_handle_handle (*data_set_ptr) :
-              *data_set_ptr);
+            is_set_handle_handle (*data_set_ptr)
+	    ? ptr_from_set_handle_handle (*data_set_ptr)
+	    : *data_set_ptr);
   __vtv_log_verification_failure (log_msg, false);
 
   const char *format_str =
diff --git a/libvtv/vtv_rts.h b/libvtv/vtv_rts.h
--- a/libvtv/vtv_rts.h
+++ b/libvtv/vtv_rts.h
@@ -26,24 +26,26 @@
 
 #include <cstdlib>
 
-// These prototypes needs to be kept in sync with the compiler-generated declarations in vtable-class-hierarchy.c
+// These prototypes needs to be kept in sync with the compiler-generated
+// declarations in vtable-class-hierarchy.c.
 extern void 
-__VLTRegisterSet(void**, const void*, std::size_t, std::size_t, void**);
+__VLTRegisterSet(void **, const void *, std::size_t, std::size_t, void **);
 
 extern void 
-__VLTRegisterSetDebug(void**, const void*, std::size_t, std::size_t, void**);
+__VLTRegisterSetDebug(void **, const void *, std::size_t, std::size_t, void **);
 
 extern void 
-__VLTRegisterPair(void**, const void*, size_t, const void*);
+__VLTRegisterPair(void **, const void *, size_t, const void *);
 
 extern void 
-__VLTRegisterPairDebug(void**, const void*, size_t, const void*, 
-		       const char*, const char*);
+__VLTRegisterPairDebug(void **, const void *, size_t, const void *, 
+		       const char *, const char *);
 
-extern const void*
-__VLTVerifyVtablePointer(void**, const void*);
+extern const void *
+__VLTVerifyVtablePointer(void **, const void *);
 
-extern const void*
-__VLTVerifyVtablePointerDebug(void**, const void*, const char*, const char*);
+extern const void *
+__VLTVerifyVtablePointerDebug(void **, const void *,
+			      const char *, const char *);
 
 #endif /* _VTV_RTS_H */
diff --git a/libvtv/vtv_utils.cc b/libvtv/vtv_utils.cc
--- a/libvtv/vtv_utils.cc
+++ b/libvtv/vtv_utils.cc
@@ -60,8 +60,7 @@ static int vtv_failures_log_fd = -1;
    This function first checks to see if the user has specifed (via
    the environment variable VTV_LOGS_DIR) a directory to use for the
    vtable verification logs.  If that fails, the function will open
-   the logs in the current directory.
-*/
+   the logs in the current directory.  */
 
 int
 __vtv_open_log (const char *name)
@@ -138,10 +137,10 @@ vtv_log_write (int fd, const char *str)
  to vtv_log_write.  */
 
 int
-__vtv_add_to_log (int log_file, const char * format, ...)
+__vtv_add_to_log (int log_file, const char *format, ...)
 {
-  /* We dont want to dynamically allocate this buffer. This should be
-     more than enough in most cases. It if isn't we are careful not to
+  /* We dont want to dynamically allocate this buffer.  This should be
+     more than enough in most cases.  It if isn't we are careful not to
      do a buffer overflow.  */
   char output[1024];
 
diff --git a/libvtv/vtv_utils.h b/libvtv/vtv_utils.h
--- a/libvtv/vtv_utils.h
+++ b/libvtv/vtv_utils.h
@@ -52,11 +52,11 @@ VTV_not_an_error (void)
                        __attribute__ ((section (VTV_PROTECTED_VARS_SECTION)))
 
 /* The following logging routines try to use low level file access
-   routines and avoid calling malloc. We need this so that we dont
+   routines and avoid calling malloc.  We need this so that we dont
    disturb the order of calls to dlopen.  Changing the order of dlopen
-   calls may lead to deadlocks */
-int __vtv_open_log (const char * name);
-int __vtv_add_to_log (int log, const char * format, ...);
+   calls may lead to deadlocks.  */
+int __vtv_open_log (const char *name);
+int __vtv_add_to_log (int log, const char *format, ...);
 void __vtv_log_verification_failure (const char *, bool);
 
 #endif /* VTV_UTILS_H */
-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]