[PATCH v1 12/13] app_common: Remove functions and macros

Ryan Long ryan.long at oarcorp.com
Sun Aug 1 23:23:46 UTC 2021


- Moved functions from app_common to the file they are used
- Got rid of FileIsNewer() since it's not being used
- Removed macros
---
 tester/covoar/TraceReaderLogQEMU.cc | 14 +++++++++
 tester/covoar/app_common.cc         | 58 -------------------------------------
 tester/covoar/app_common.h          |  3 --
 tester/covoar/covoar.cc             | 20 +++++++++++++
 4 files changed, 34 insertions(+), 61 deletions(-)

diff --git a/tester/covoar/TraceReaderLogQEMU.cc b/tester/covoar/TraceReaderLogQEMU.cc
index 37952a3..e65628e 100644
--- a/tester/covoar/TraceReaderLogQEMU.cc
+++ b/tester/covoar/TraceReaderLogQEMU.cc
@@ -63,6 +63,20 @@
 
 #define MAX_LINE_LENGTH 512
 
+bool ReadUntilFound( FILE *file, const char *line )
+{
+  char discardBuff[100];
+  size_t  len = strlen( line );
+
+  do {
+    if ( !fgets( discardBuff, 99, file ) )
+      return false;
+
+    if ( strncmp( discardBuff, line, len ) == 0 )
+      return true;
+  } while (1);
+}
+
 namespace Trace {
 
   TraceReaderLogQEMU::TraceReaderLogQEMU()
diff --git a/tester/covoar/app_common.cc b/tester/covoar/app_common.cc
index 568d108..9fece7b 100644
--- a/tester/covoar/app_common.cc
+++ b/tester/covoar/app_common.cc
@@ -40,68 +40,10 @@
 #include "app_common.h"
 #include "DesiredSymbols.h"
 #include "Explanations.h"
-
-#if HAVE_STAT64
-#define STAT stat64
-#else
-#define STAT stat
-#endif
-
-#if HAVE_OPEN64
-#define OPEN fopen64
-#else
-#define OPEN fopen
-#endif
-
 /*
  *  Global variables for the program
  */
 
 
-bool FileIsNewer(
-  const char *f1,
-  const char *f2
-)
-{
-  struct STAT buf1, buf2;
-
-   if (STAT( f2, &buf2 ) == -1)
-    return true;
-
-  if (STAT( f1, &buf1 ) == -1)
-    exit (1);
-
-  if (buf1.st_mtime > buf2.st_mtime)
-    return true;
-
-  return false;
-}
-
-bool FileIsReadable( const char *f1 )
-{
-  struct STAT buf1;
-
-  if (STAT( f1, &buf1 ) == -1)
-    return false;
-
-  if (buf1.st_size == 0)
-    return false;
-
-  // XXX check permission ??
-  return true;
-}
-
-bool ReadUntilFound( FILE *file, const char *line )
-{
-  char discardBuff[100];
-  size_t  len = strlen( line );
-
-  do {
-    if ( !fgets( discardBuff, 99, file ) )
-      return false;
 
-    if ( strncmp( discardBuff, line, len ) == 0 )
-      return true;
-  } while (1);
-}
 
diff --git a/tester/covoar/app_common.h b/tester/covoar/app_common.h
index 454d389..5da4bb3 100644
--- a/tester/covoar/app_common.h
+++ b/tester/covoar/app_common.h
@@ -14,8 +14,5 @@
 
 
 
-bool FileIsNewer( const char *f1, const char *f2 );
-bool FileIsReadable( const char *f1 );
-bool ReadUntilFound( FILE *file, const char *line );
 
 #endif
diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index 5c7833a..751d77a 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -30,6 +30,12 @@
 #include "TargetFactory.h"
 #include "GcovData.h"
 
+#if HAVE_STAT64
+#define STAT stat64
+#else
+#define STAT stat
+#endif
+
 #if defined(_WIN32) || defined(__CYGWIN__)
   #define kill(p,s) raise(s)
 #endif
@@ -40,6 +46,20 @@ typedef std::list<std::string> CoverageNames;
 typedef std::list<Coverage::ExecutableInfo*> Executables;
 typedef std::string option_error;
 
+bool FileIsReadable( const char *f1 )
+{
+  struct STAT buf1;
+
+  if (STAT( f1, &buf1 ) == -1)
+    return false;
+
+  if (buf1.st_size == 0)
+    return false;
+
+  // XXX check permission ??
+  return true;
+}
+
 /*
  * Create a build path from the executable paths. Also extract the build prefix
  * and BSP names.
-- 
1.8.3.1



More information about the devel mailing list