[compiler-rt] r174888 - [sanitizer] clang-format pass over scanf code.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Mon Feb 11 07:22:35 PST 2013


Author: eugenis
Date: Mon Feb 11 09:22:34 2013
New Revision: 174888

URL: http://llvm.org/viewvc/llvm-project?rev=174888&view=rev
Log:
[sanitizer] clang-format pass over scanf code.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
    compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_scanf_interceptor_test.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=174888&r1=174887&r2=174888&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Mon Feb 11 09:22:34 2013
@@ -30,7 +30,7 @@
 
 #if SANITIZER_INTERCEPT_READ
 INTERCEPTOR(SSIZE_T, read, int fd, void *ptr, SIZE_T count) {
-  void* ctx;
+  void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, read, fd, ptr, count);
   SSIZE_T res = REAL(read)(fd, ptr, count);
   if (res > 0)
@@ -39,14 +39,14 @@ INTERCEPTOR(SSIZE_T, read, int fd, void
     COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd);
   return res;
 }
-# define INIT_READ INTERCEPT_FUNCTION(read)
+#define INIT_READ INTERCEPT_FUNCTION(read)
 #else
-# define INIT_READ
+#define INIT_READ
 #endif
 
 #if SANITIZER_INTERCEPT_PREAD
 INTERCEPTOR(SSIZE_T, pread, int fd, void *ptr, SIZE_T count, OFF_T offset) {
-  void* ctx;
+  void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, pread, fd, ptr, count, offset);
   SSIZE_T res = REAL(pread)(fd, ptr, count, offset);
   if (res > 0)
@@ -55,14 +55,14 @@ INTERCEPTOR(SSIZE_T, pread, int fd, void
     COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd);
   return res;
 }
-# define INIT_PREAD INTERCEPT_FUNCTION(pread)
+#define INIT_PREAD INTERCEPT_FUNCTION(pread)
 #else
-# define INIT_PREAD
+#define INIT_PREAD
 #endif
 
 #if SANITIZER_INTERCEPT_PREAD64
 INTERCEPTOR(SSIZE_T, pread64, int fd, void *ptr, SIZE_T count, OFF64_T offset) {
-  void* ctx;
+  void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, pread64, fd, ptr, count, offset);
   SSIZE_T res = REAL(pread64)(fd, ptr, count, offset);
   if (res > 0)
@@ -71,14 +71,14 @@ INTERCEPTOR(SSIZE_T, pread64, int fd, vo
     COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd);
   return res;
 }
-# define INIT_PREAD64 INTERCEPT_FUNCTION(pread64)
+#define INIT_PREAD64 INTERCEPT_FUNCTION(pread64)
 #else
-# define INIT_PREAD64
+#define INIT_PREAD64
 #endif
 
 #if SANITIZER_INTERCEPT_WRITE
 INTERCEPTOR(SSIZE_T, write, int fd, void *ptr, SIZE_T count) {
-  void* ctx;
+  void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, write, fd, ptr, count);
   if (fd >= 0)
     COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd);
@@ -87,14 +87,14 @@ INTERCEPTOR(SSIZE_T, write, int fd, void
     COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, res);
   return res;
 }
-# define INIT_WRITE INTERCEPT_FUNCTION(write)
+#define INIT_WRITE INTERCEPT_FUNCTION(write)
 #else
-# define INIT_WRITE
+#define INIT_WRITE
 #endif
 
 #if SANITIZER_INTERCEPT_PWRITE
 INTERCEPTOR(SSIZE_T, pwrite, int fd, void *ptr, SIZE_T count, OFF_T offset) {
-  void* ctx;
+  void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, pwrite, fd, ptr, count, offset);
   if (fd >= 0)
     COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd);
@@ -103,15 +103,15 @@ INTERCEPTOR(SSIZE_T, pwrite, int fd, voi
     COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, res);
   return res;
 }
-# define INIT_PWRITE INTERCEPT_FUNCTION(pwrite)
+#define INIT_PWRITE INTERCEPT_FUNCTION(pwrite)
 #else
-# define INIT_PWRITE
+#define INIT_PWRITE
 #endif
 
 #if SANITIZER_INTERCEPT_PWRITE64
 INTERCEPTOR(SSIZE_T, pwrite64, int fd, void *ptr, OFF64_T count,
             OFF64_T offset) {
-  void* ctx;
+  void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, pwrite64, fd, ptr, count, offset);
   if (fd >= 0)
     COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd);
@@ -120,56 +120,55 @@ INTERCEPTOR(SSIZE_T, pwrite64, int fd, v
     COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, res);
   return res;
 }
-# define INIT_PWRITE64 INTERCEPT_FUNCTION(pwrite64)
+#define INIT_PWRITE64 INTERCEPT_FUNCTION(pwrite64)
 #else
-# define INIT_PWRITE64
+#define INIT_PWRITE64
 #endif
 
 #if SANITIZER_INTERCEPT_PRCTL
-INTERCEPTOR(int, prctl, int option,
-            unsigned long arg2, unsigned long arg3,  // NOLINT
-            unsigned long arg4, unsigned long arg5) {  // NOLINT
-  void* ctx;
+INTERCEPTOR(int, prctl, int option, unsigned long arg2,
+            unsigned long arg3,                       // NOLINT
+            unsigned long arg4, unsigned long arg5) { // NOLINT
+  void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, prctl, option, arg2, arg3, arg4, arg5);
   static const int PR_SET_NAME = 15;
   int res = REAL(prctl(option, arg2, arg3, arg4, arg5));
   if (option == PR_SET_NAME) {
     char buff[16];
-    internal_strncpy(buff, (char*)arg2, 15);
+    internal_strncpy(buff, (char *)arg2, 15);
     buff[15] = 0;
     COMMON_INTERCEPTOR_SET_THREAD_NAME(ctx, buff);
   }
   return res;
 }
-# define INIT_PRCTL INTERCEPT_FUNCTION(prctl)
+#define INIT_PRCTL INTERCEPT_FUNCTION(prctl)
 #else
-# define INIT_PRCTL
-#endif  // SANITIZER_INTERCEPT_PRCTL
-
+#define INIT_PRCTL
+#endif // SANITIZER_INTERCEPT_PRCTL
 
 #if SANITIZER_INTERCEPT_SCANF
 
 #include "sanitizer_common_interceptors_scanf.inc"
 
-INTERCEPTOR(int, vscanf, const char *format, va_list ap) {  // NOLINT
-  void* ctx;
+INTERCEPTOR(int, vscanf, const char *format, va_list ap) { // NOLINT
+  void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, vscanf, format, ap);
   va_list aq;
   va_copy(aq, ap);
-  int res = REAL(vscanf)(format, ap);  // NOLINT
+  int res = REAL(vscanf)(format, ap); // NOLINT
   if (res > 0)
     scanf_common(ctx, res, format, aq);
   va_end(aq);
   return res;
 }
 
-INTERCEPTOR(int, vsscanf, const char *str, const char *format,  // NOLINT
-    va_list ap) {
-  void* ctx;
+INTERCEPTOR(int, vsscanf, const char *str, const char *format, // NOLINT
+            va_list ap) {
+  void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, vsscanf, str, format, ap);
   va_list aq;
   va_copy(aq, ap);
-  int res = REAL(vsscanf)(str, format, ap);  // NOLINT
+  int res = REAL(vsscanf)(str, format, ap); // NOLINT
   if (res > 0)
     scanf_common(ctx, res, format, aq);
   va_end(aq);
@@ -177,67 +176,67 @@ INTERCEPTOR(int, vsscanf, const char *st
   return res;
 }
 
-INTERCEPTOR(int, vfscanf, void *stream, const char *format,  // NOLINT
-    va_list ap) {
-  void* ctx;
+INTERCEPTOR(int, vfscanf, void *stream, const char *format, // NOLINT
+            va_list ap) {
+  void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, vfscanf, stream, format, ap);
   va_list aq;
   va_copy(aq, ap);
-  int res = REAL(vfscanf)(stream, format, ap);  // NOLINT
+  int res = REAL(vfscanf)(stream, format, ap); // NOLINT
   if (res > 0)
     scanf_common(ctx, res, format, aq);
   va_end(aq);
   return res;
 }
 
-INTERCEPTOR(int, scanf, const char *format, ...) {  // NOLINT
-  void* ctx;
+INTERCEPTOR(int, scanf, const char *format, ...) { // NOLINT
+  void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, scanf, format);
   va_list ap;
   va_start(ap, format);
-  int res = vscanf(format, ap);  // NOLINT
+  int res = vscanf(format, ap); // NOLINT
   va_end(ap);
   return res;
 }
 
-INTERCEPTOR(int, fscanf, void* stream, const char *format, ...) {  // NOLINT
-  void* ctx;
+INTERCEPTOR(int, fscanf, void *stream, const char *format, ...) { // NOLINT
+  void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, fscanf, stream, format);
   va_list ap;
   va_start(ap, format);
-  int res = vfscanf(stream, format, ap);  // NOLINT
+  int res = vfscanf(stream, format, ap); // NOLINT
   va_end(ap);
   return res;
 }
 
-INTERCEPTOR(int, sscanf, const char *str, const char *format, ...) {  // NOLINT
-  void* ctx;
-  COMMON_INTERCEPTOR_ENTER(ctx, sscanf, str, format);  // NOLINT
+INTERCEPTOR(int, sscanf, const char *str, const char *format, ...) { // NOLINT
+  void *ctx;
+  COMMON_INTERCEPTOR_ENTER(ctx, sscanf, str, format); // NOLINT
   va_list ap;
   va_start(ap, format);
-  int res = vsscanf(str, format, ap);  // NOLINT
+  int res = vsscanf(str, format, ap); // NOLINT
   va_end(ap);
   return res;
 }
 
-#define INIT_SCANF \
-  INTERCEPT_FUNCTION(scanf);                    \
-  INTERCEPT_FUNCTION(sscanf);  /* NOLINT */     \
-  INTERCEPT_FUNCTION(fscanf);                   \
-  INTERCEPT_FUNCTION(vscanf);                   \
-  INTERCEPT_FUNCTION(vsscanf);                  \
+#define INIT_SCANF                                                             \
+  INTERCEPT_FUNCTION(scanf);                                                   \
+  INTERCEPT_FUNCTION(sscanf); /* NOLINT */                                     \
+  INTERCEPT_FUNCTION(fscanf);                                                  \
+  INTERCEPT_FUNCTION(vscanf);                                                  \
+  INTERCEPT_FUNCTION(vsscanf);                                                 \
   INTERCEPT_FUNCTION(vfscanf)
 
 #else
 #define INIT_SCANF
 #endif
 
-#define SANITIZER_COMMON_INTERCEPTORS_INIT \
-  INIT_READ;                               \
-  INIT_PREAD;                              \
-  INIT_PREAD64;                            \
-  INIT_PRCTL;                              \
-  INIT_WRITE;                              \
-  INIT_PWRITE;                             \
-  INIT_PWRITE64;                           \
+#define SANITIZER_COMMON_INTERCEPTORS_INIT                                     \
+  INIT_READ;                                                                   \
+  INIT_PREAD;                                                                  \
+  INIT_PREAD64;                                                                \
+  INIT_PRCTL;                                                                  \
+  INIT_WRITE;                                                                  \
+  INIT_PWRITE;                                                                 \
+  INIT_PWRITE64;                                                               \
   INIT_SCANF;

Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_scanf_interceptor_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_scanf_interceptor_test.cc?rev=174888&r1=174887&r2=174888&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_scanf_interceptor_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_scanf_interceptor_test.cc Mon Feb 11 09:22:34 2013
@@ -19,7 +19,7 @@
 
 using namespace __sanitizer;
 
-#define COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, size) \
+#define COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, size)                         \
   ((std::vector<unsigned> *)ctx)->push_back(size)
 
 #include "sanitizer_common/sanitizer_common_interceptors_scanf.inc"
@@ -35,20 +35,20 @@ static void testScanf3(void *ctx, int re
   va_end(ap);
 }
 
-static void testScanf2(const char *format, int scanf_result, unsigned n, va_list expected_sizes) {
+static void testScanf2(const char *format, int scanf_result, unsigned n,
+                       va_list expected_sizes) {
   std::vector<unsigned> scanf_sizes;
   // 16 args should be enough.
-  testScanf3((void *)&scanf_sizes, scanf_result, format,
-      scanf_buf, scanf_buf, scanf_buf, scanf_buf,
-      scanf_buf, scanf_buf, scanf_buf, scanf_buf,
-      scanf_buf, scanf_buf, scanf_buf, scanf_buf,
-      scanf_buf, scanf_buf, scanf_buf, scanf_buf);
-  ASSERT_EQ(n, scanf_sizes.size()) <<
-    "Unexpected number of format arguments: '" << format << "'";
+  testScanf3((void *)&scanf_sizes, scanf_result, format, scanf_buf, scanf_buf,
+             scanf_buf, scanf_buf, scanf_buf, scanf_buf, scanf_buf, scanf_buf,
+             scanf_buf, scanf_buf, scanf_buf, scanf_buf, scanf_buf, scanf_buf,
+             scanf_buf, scanf_buf);
+  ASSERT_EQ(n, scanf_sizes.size()) << "Unexpected number of format arguments: '"
+                                   << format << "'";
   for (unsigned i = 0; i < n; ++i)
-    EXPECT_EQ(va_arg(expected_sizes, unsigned), scanf_sizes[i]) <<
-      "Unexpect write size for argument " << i << ", format string '" <<
-      format << "'";
+    EXPECT_EQ(va_arg(expected_sizes, unsigned), scanf_sizes[i])
+        << "Unexpect write size for argument " << i << ", format string '"
+        << format << "'";
 }
 
 static void testScanf(const char *format, unsigned n, ...) {
@@ -58,7 +58,8 @@ static void testScanf(const char *format
   va_end(ap);
 }
 
-static void testScanfPartial(const char *format, int scanf_result, unsigned n, ...) {
+static void testScanfPartial(const char *format, int scanf_result, unsigned n,
+                             ...) {
   va_list ap;
   va_start(ap, n);
   testScanf2(format, scanf_result, n, ap);
@@ -66,15 +67,15 @@ static void testScanfPartial(const char
 }
 
 TEST(SanitizerCommonInterceptors, Scanf) {
-  const unsigned I = sizeof(int);  // NOLINT
-  const unsigned L = sizeof(long);  // NOLINT
-  const unsigned LL = sizeof(long long);  // NOLINT
-  const unsigned S = sizeof(short);  // NOLINT
-  const unsigned C = sizeof(char);  // NOLINT
-  const unsigned D = sizeof(double);  // NOLINT
-  const unsigned LD = sizeof(long double);  // NOLINT
-  const unsigned F = sizeof(float);  // NOLINT
-  const unsigned P = sizeof(char*);  // NOLINT
+  const unsigned I = sizeof(int);          // NOLINT
+  const unsigned L = sizeof(long);         // NOLINT
+  const unsigned LL = sizeof(long long);   // NOLINT
+  const unsigned S = sizeof(short);        // NOLINT
+  const unsigned C = sizeof(char);         // NOLINT
+  const unsigned D = sizeof(double);       // NOLINT
+  const unsigned LD = sizeof(long double); // NOLINT
+  const unsigned F = sizeof(float);        // NOLINT
+  const unsigned P = sizeof(char *);       // NOLINT
 
   testScanf("%d", 1, I);
   testScanf("%d%d%d", 3, I, I, I);
@@ -149,5 +150,6 @@ TEST(SanitizerCommonInterceptors, Scanf)
   testScanfPartial("%d%n%n%d //2\n", 2, 4, I, I, I, I);
 
   testScanfPartial("%d%n%n%d %s %s", 3, 5, I, I, I, I, scanf_buf_size);
-  testScanfPartial("%d%n%n%d %s %s", 4, 6, I, I, I, I, scanf_buf_size, scanf_buf_size);
+  testScanfPartial("%d%n%n%d %s %s", 4, 6, I, I, I, I, scanf_buf_size,
+                   scanf_buf_size);
 }





More information about the llvm-commits mailing list