All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cld: check parameters for HAIL_LOG
@ 2010-01-01 22:51 Colin McCabe
  0 siblings, 0 replies; 5+ messages in thread
From: Colin McCabe @ 2010-01-01 22:51 UTC (permalink / raw)
  To: Project Hail List; +Cc: Pete Zaitcev, Jeff Garzik, Colin McCabe

GCC has a nifty ability to typecheck varargs functions that follow the printf
conventions. This change uses that in HAIL_LOG. If you build with -Wall, gcc
can now give warnings about HAIL_LOG invocations where there are too many or
too few arguments, or arguments of the wrong types.
---
 include/hail_log.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/include/hail_log.h b/include/hail_log.h
index d6794b4..ca26f22 100644
--- a/include/hail_log.h
+++ b/include/hail_log.h
@@ -4,7 +4,8 @@
 #include <stdbool.h>
 
 struct hail_log {
-	void (*func)(int prio, const char *fmt, ...);
+	void (*func)(int prio, const char *fmt, ...)
+		__attribute__((format(printf,2,3)));
 	bool verbose;
 };
 
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] cld: check parameters for HAIL_LOG
@ 2010-01-01 22:54 Colin McCabe
  0 siblings, 0 replies; 5+ messages in thread
From: Colin McCabe @ 2010-01-01 22:54 UTC (permalink / raw)
  To: Project Hail List; +Cc: Pete Zaitcev, Jeff Garzik, Colin McCabe

GCC has a nifty ability to typecheck varargs functions that follow the printf
conventions. This change uses that in HAIL_LOG. If you build with -Wall, gcc
can now give warnings about HAIL_LOG invocations where there are too many or
too few arguments, or arguments of the wrong types.

Sorry for the duplicate email. I forgot the signoff originally.

Signed-off-by: Colin McCabe <cmccabe@alumni.cmu.edu>
---
 include/hail_log.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/include/hail_log.h b/include/hail_log.h
index d6794b4..ca26f22 100644
--- a/include/hail_log.h
+++ b/include/hail_log.h
@@ -4,7 +4,8 @@
 #include <stdbool.h>
 
 struct hail_log {
-	void (*func)(int prio, const char *fmt, ...);
+	void (*func)(int prio, const char *fmt, ...)
+		__attribute__((format(printf,2,3)));
 	bool verbose;
 };
 
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] cld: check parameters for HAIL_LOG
@ 2010-01-03 21:12 Colin McCabe
  0 siblings, 0 replies; 5+ messages in thread
From: Colin McCabe @ 2010-01-03 21:12 UTC (permalink / raw)
  To: Project Hail List; +Cc: Pete Zaitcev, Jeff Garzik, Colin McCabe

GCC has a nifty ability to typecheck varargs functions that follow the printf
conventions. This change uses that in HAIL_LOG. If you build with -Wall, gcc
can now give warnings about HAIL_LOG invocations where there are too many or
too few arguments, or arguments of the wrong types.

For non-GCC compilers, don't do anything (yet).

Signed-off-by: Colin McCabe <cmccabe@alumni.cmu.edu>
---
 include/hail_log.h |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/include/hail_log.h b/include/hail_log.h
index d6794b4..88074a3 100644
--- a/include/hail_log.h
+++ b/include/hail_log.h
@@ -3,8 +3,15 @@
 
 #include <stdbool.h>
 
+#ifdef __GNUC__
+#define ATTR_PRINTF(x,y) __attribute__((format(printf, x, y)))
+#else
+#define ATTR_PRINTF(x,y)
+#endif
+
 struct hail_log {
-	void (*func)(int prio, const char *fmt, ...);
+	void (*func)(int prio, const char *fmt, ...)
+		ATTR_PRINTF(2,3);
 	bool verbose;
 };
 
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] cld: check parameters for HAIL_LOG
@ 2010-01-04  0:45 Colin McCabe
  2010-01-04 10:18 ` Jeff Garzik
  0 siblings, 1 reply; 5+ messages in thread
From: Colin McCabe @ 2010-01-04  0:45 UTC (permalink / raw)
  To: Project Hail List; +Cc: Pete Zaitcev, Jeff Garzik, Colin McCabe

Another attempt at escaping the overly-aggressive spam filters...

GCC has a nifty ability to typecheck varargs functions that follow the printf
conventions. This change uses that in HAIL_LOG. If you build with -Wall, gcc
can now give warnings about HAIL_LOG invocations where there are too many or
too few arguments, or arguments of the wrong types.

For non-GCC compilers, don't do anything (yet).

Signed-off-by: Colin McCabe <cmccabe@alumni.cmu.edu>
---
 include/hail_log.h |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/include/hail_log.h b/include/hail_log.h
index d6794b4..88074a3 100644
--- a/include/hail_log.h
+++ b/include/hail_log.h
@@ -3,8 +3,15 @@
 
 #include <stdbool.h>
 
+#ifdef __GNUC__
+#define ATTR_PRINTF(x,y) __attribute__((format(printf, x, y)))
+#else
+#define ATTR_PRINTF(x,y)
+#endif
+
 struct hail_log {
-	void (*func)(int prio, const char *fmt, ...);
+	void (*func)(int prio, const char *fmt, ...)
+		ATTR_PRINTF(2,3);
 	bool verbose;
 };
 
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] cld: check parameters for HAIL_LOG
  2010-01-04  0:45 [PATCH] cld: check parameters for HAIL_LOG Colin McCabe
@ 2010-01-04 10:18 ` Jeff Garzik
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2010-01-04 10:18 UTC (permalink / raw)
  To: Colin McCabe; +Cc: Project Hail List, Pete Zaitcev

On 01/03/2010 07:45 PM, Colin McCabe wrote:
> Another attempt at escaping the overly-aggressive spam filters...
>
> GCC has a nifty ability to typecheck varargs functions that follow the printf
> conventions. This change uses that in HAIL_LOG. If you build with -Wall, gcc
> can now give warnings about HAIL_LOG invocations where there are too many or
> too few arguments, or arguments of the wrong types.
>
> For non-GCC compilers, don't do anything (yet).
>
> Signed-off-by: Colin McCabe<cmccabe@alumni.cmu.edu>
> ---
>   include/hail_log.h |    9 ++++++++-
>   1 files changed, 8 insertions(+), 1 deletions(-)

applied


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-01-04 10:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-04  0:45 [PATCH] cld: check parameters for HAIL_LOG Colin McCabe
2010-01-04 10:18 ` Jeff Garzik
  -- strict thread matches above, loose matches on Subject: below --
2010-01-03 21:12 Colin McCabe
2010-01-01 22:54 Colin McCabe
2010-01-01 22:51 Colin McCabe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.