trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [2/2] git commit: TS-1084: Coalesce PRINTFLIKE and TS_PRINTFLIKE
Date Wed, 01 Feb 2012 05:08:19 GMT
TS-1084: Coalesce PRINTFLIKE and TS_PRINTFLIKE


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a6682c58
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a6682c58
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a6682c58

Branch: refs/heads/master
Commit: a6682c58778fba75413193ac2913bb8b82ea44b9
Parents: 05360bc
Author: James Peach <jpeach@apache.org>
Authored: Tue Jan 31 20:57:58 2012 -0800
Committer: James Peach <jpeach@apache.org>
Committed: Tue Jan 31 20:57:58 2012 -0800

----------------------------------------------------------------------
 lib/ts/Diags.h       |    8 --------
 lib/ts/Layout.cc     |    4 ++--
 lib/ts/ink_assert.cc |   11 ++---------
 lib/ts/ink_defs.h    |    9 ++++++---
 lib/ts/ink_error.h   |   18 +++++++++---------
 lib/ts/ink_memory.cc |    6 +++---
 lib/ts/ink_sprintf.h |    2 +-
 7 files changed, 23 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a6682c58/lib/ts/Diags.h
----------------------------------------------------------------------
diff --git a/lib/ts/Diags.h b/lib/ts/Diags.h
index 0f7122f..d5b85c2 100644
--- a/lib/ts/Diags.h
+++ b/lib/ts/Diags.h
@@ -44,14 +44,6 @@
 
 #define DIAGS_MAGIC 0x12345678
 
-#if !defined(TS_PRINTFLIKE)
-#if defined(__GNUC__) || defined(__clang__)
-#define TS_PRINTFLIKE(fmt, arg) __attribute__((format(printf, fmt, arg)))
-#else
-#define TS_PRINTFLIKE(fmt, arg)
-#endif
-#endif
-
 class Diags;
 
 // extern int diags_on_for_plugins;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a6682c58/lib/ts/Layout.cc
----------------------------------------------------------------------
diff --git a/lib/ts/Layout.cc b/lib/ts/Layout.cc
index 9566b4c..d4240f1 100644
--- a/lib/ts/Layout.cc
+++ b/lib/ts/Layout.cc
@@ -93,7 +93,7 @@ Layout::relative(char *buf, size_t bufsz, const char *file)
   }
   size_t path_len = strlen(path) + 1;
   if (path_len > bufsz) {
-    ink_error("Provided buffer is too small: %d, required %d\n", bufsz, path_len);
+    ink_error("Provided buffer is too small: %zu, required %zu\n", bufsz, path_len);
   }
   else {
     ink_strlcpy(buf, path, bufsz);
@@ -127,7 +127,7 @@ Layout::relative_to(char *buf, size_t bufsz, const char *dir, const char
*file)
   }
   size_t path_len = strlen(path) + 1;
   if (path_len > bufsz) {
-    ink_error("Provided buffer is too small: %d, required %d\n", bufsz, path_len);
+    ink_error("Provided buffer is too small: %zu, required %zu\n", bufsz, path_len);
   }
   else {
     ink_strlcpy(buf, path, bufsz);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a6682c58/lib/ts/ink_assert.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_assert.cc b/lib/ts/ink_assert.cc
index 38deb00..0999f38 100644
--- a/lib/ts/ink_assert.cc
+++ b/lib/ts/ink_assert.cc
@@ -33,15 +33,8 @@ Assertions
 #include "ink_string.h"       /* MAGIC_EDITING_TAG */
 
 int
-_ink_assert(const char *a, const char *f, int l)
+_ink_assert(const char *expression, const char *file, int line)
 {
-  char buf1[256];
-  char buf2[512];
-  ink_strlcpy(buf1, f, sizeof(buf1));
-  snprintf(buf2, sizeof(buf2), "%s:%d: failed assert `", buf1, l);
-  ink_strlcat(buf2, a, sizeof(buf2));
-  ink_strlcat(buf2, "`", sizeof(buf2));
-  ink_fatal(1, buf2);
-
+  ink_fatal(1, "%s:%d: failed assert `%s`", file, line, expression);
   return (0);
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a6682c58/lib/ts/ink_defs.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_defs.h b/lib/ts/ink_defs.h
index 7f5cec2..4f1d0b2 100644
--- a/lib/ts/ink_defs.h
+++ b/lib/ts/ink_defs.h
@@ -66,12 +66,15 @@ typedef void (*VI_PFN) (int);
  */
 #define	NOWARN_UNUSED(x)	(void)(x)
 #define	NOWARN_UNUSED_RETURN(x)	if (x) {}
-#ifdef __GNUC__
+
 /*  Enable this to get printf() style warnings on the Inktomi functions. */
 /* #define PRINTFLIKE(IDX, FIRST)  __attribute__((format (printf, IDX, FIRST))) */
-#define PRINTFLIKE(IDX, FIRST)
+#if !defined(TS_PRINTFLIKE)
+#if defined(__GNUC__) || defined(__clang__)
+#define TS_PRINTFLIKE(fmt, arg) __attribute__((format(printf, fmt, arg)))
 #else
-#define PRINTFLIKE(IDX, FIRST)
+#define TS_PRINTFLIKE(fmt, arg)
+#endif
 #endif
 
 /* Variables

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a6682c58/lib/ts/ink_error.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_error.h b/lib/ts/ink_error.h
index 2fde48e..5447ad9 100644
--- a/lib/ts/ink_error.h
+++ b/lib/ts/ink_error.h
@@ -43,15 +43,15 @@ extern "C" {
 #endif                          /* __cplusplus */
 
 inkcoreapi void ink_fatal_va(int return_code, const char *message_format, va_list ap);
-void ink_fatal(int return_code, const char *message_format, ...) PRINTFLIKE(2, 3);
-void ink_pfatal(int return_code, const char *message_format, ...) PRINTFLIKE(2, 3);
-void ink_warning(const char *message_format, ...) PRINTFLIKE(1, 2);
-void ink_pwarning(const char *message_format, ...) PRINTFLIKE(1, 2);
-void ink_notice(const char *message_format, ...) PRINTFLIKE(1, 2);
-void ink_eprintf(const char *message_format, ...) PRINTFLIKE(1, 2);
-void ink_error(const char *message_format, ...) PRINTFLIKE(1, 2);
-void ink_dprintf(int debug_level, const char *message_format, ...) PRINTFLIKE(2, 3);
-void ink_fatal_die(const char *message_format, ...) PRINTFLIKE(1, 2);
+void ink_fatal(int return_code, const char *message_format, ...) TS_PRINTFLIKE(2, 3);
+void ink_pfatal(int return_code, const char *message_format, ...) TS_PRINTFLIKE(2, 3);
+void ink_warning(const char *message_format, ...) TS_PRINTFLIKE(1, 2);
+void ink_pwarning(const char *message_format, ...) TS_PRINTFLIKE(1, 2);
+void ink_notice(const char *message_format, ...) TS_PRINTFLIKE(1, 2);
+void ink_eprintf(const char *message_format, ...) TS_PRINTFLIKE(1, 2);
+void ink_error(const char *message_format, ...) TS_PRINTFLIKE(1, 2);
+void ink_dprintf(int debug_level, const char *message_format, ...) TS_PRINTFLIKE(2, 3);
+void ink_fatal_die(const char *message_format, ...) TS_PRINTFLIKE(1, 2);
 
 void ink_die_die_die(int retval);
 void ink_segv();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a6682c58/lib/ts/ink_memory.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_memory.cc b/lib/ts/ink_memory.cc
index 95ec96e..5f43797 100644
--- a/lib/ts/ink_memory.cc
+++ b/lib/ts/ink_memory.cc
@@ -53,7 +53,7 @@ ats_malloc(size_t size)
     if (unlikely((ptr = malloc(size)) == NULL)) {
 #endif
       xdump();
-      ink_fatal(1, "ats_malloc: couldn't allocate %d bytes", size);
+      ink_fatal(1, "ats_malloc: couldn't allocate %zu bytes", size);
     }
   }
   return ptr;
@@ -69,7 +69,7 @@ ats_calloc(size_t nelem, size_t elsize)
 #endif
   if (unlikely(ptr == NULL)) {
     xdump();
-    ink_fatal(1, "ats_calloc: couldn't allocate %d %d byte elements", nelem, elsize);
+    ink_fatal(1, "ats_calloc: couldn't allocate %zu %zu byte elements", nelem, elsize);
   }
   return ptr;
 }                               /* End ats_calloc */
@@ -84,7 +84,7 @@ ats_realloc(void *ptr, size_t size)
 #endif
   if (unlikely(newptr == NULL)) {
     xdump();
-    ink_fatal(1, "ats_realloc: couldn't reallocate %d bytes", size);
+    ink_fatal(1, "ats_realloc: couldn't reallocate %zu bytes", size);
   }
   return newptr;
 }                               /* End ats_realloc */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a6682c58/lib/ts/ink_sprintf.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_sprintf.h b/lib/ts/ink_sprintf.h
index 322bb12..bdc737c 100644
--- a/lib/ts/ink_sprintf.h
+++ b/lib/ts/ink_sprintf.h
@@ -40,7 +40,7 @@
 
 int
 ink_bsprintf(char *buffer, const char *format, ...)
-PRINTFLIKE(2, 3);
+TS_PRINTFLIKE(2, 3);
 int
 ink_bvsprintf(char *buffer, const char *format, va_list ap);
 


Mime
View raw message