Mesa (9.0): ralloc: Annotate printf functions with PRINTFLIKE(...)
Ian Romanick
idr at kemper.freedesktop.org
Fri Nov 2 19:23:37 UTC 2012
Module: Mesa
Branch: 9.0
Commit: 94cc306e41a2565b1dc7d410713ac78a9f1edaf3
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=94cc306e41a2565b1dc7d410713ac78a9f1edaf3
Author: Matt Turner <mattst88 at gmail.com>
Date: Tue Oct 23 13:30:09 2012 -0700
ralloc: Annotate printf functions with PRINTFLIKE(...)
This is a squash of the following two commits:
ralloc: Annotate printf functions with PRINTFLIKE(...)
Catches problems such as (in the gles3 branch)
glcpp-parse.y: In function '_glcpp_parser_handle_version_declaration':
glcpp-parse.y:1990:39: warning: format '%lli' expects argument of type
'long long int', but argument 4 has type 'int' [-Wformat]
As a side-effect, remove ralloc.c's likely/unlikely macros and just use
the ones from main/compiler.h.
NOTE: This is a candidate for the release branches.
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
(cherry picked from commit 41b14d125196e75cdd4599a4c1069b41e7000d48)
and
src/glsl/tests/Makefile.am: Specify -I... in AM_CPPFLAGS
When specifying per-target CFLAGS (e.g., ralloc_test_CFLAGS) AM_CFLAGS
are not used. AM_CPPFLAGS should be used for includes anyway.
Fixes a build problem since 41b14d125:
CC ralloc_test-ralloc.o
In file included from ../../../src/glsl/ralloc.c:42:0:
../../../src/glsl/ralloc.h:57:27: fatal error: main/compiler.h: No such file or directory
Acked-by: Paul Berry <stereotype441 at gmail.com>
(cherry picked from commit 67f1e7bf5f5d1482cb8684dd5a405b7bab5b1f34)
---
src/glsl/ralloc.c | 8 --------
src/glsl/ralloc.h | 9 ++++++---
src/glsl/tests/Makefile.am | 5 +----
3 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/src/glsl/ralloc.c b/src/glsl/ralloc.c
index 3da09b5..59e71c4 100644
--- a/src/glsl/ralloc.c
+++ b/src/glsl/ralloc.c
@@ -41,14 +41,6 @@ _CRTIMP int _vscprintf(const char *format, va_list argptr);
#include "ralloc.h"
-#ifdef __GNUC__
-#define likely(x) __builtin_expect(!!(x),1)
-#define unlikely(x) __builtin_expect(!!(x),0)
-#else
-#define likely(x) !!(x)
-#define unlikely(x) !!(x)
-#endif
-
#ifndef va_copy
#ifdef __va_copy
#define va_copy(dest, src) __va_copy((dest), (src))
diff --git a/src/glsl/ralloc.h b/src/glsl/ralloc.h
index 86306b1..67eb938 100644
--- a/src/glsl/ralloc.h
+++ b/src/glsl/ralloc.h
@@ -54,6 +54,7 @@ extern "C" {
#include <stddef.h>
#include <stdarg.h>
#include <stdbool.h>
+#include "main/compiler.h"
/**
* \def ralloc(ctx, type)
@@ -301,7 +302,7 @@ bool ralloc_strncat(char **dest, const char *str, size_t n);
*
* \return The newly allocated string.
*/
-char *ralloc_asprintf (const void *ctx, const char *fmt, ...);
+char *ralloc_asprintf (const void *ctx, const char *fmt, ...) PRINTFLIKE(2, 3);
/**
* Print to a string, given a va_list.
@@ -334,7 +335,8 @@ char *ralloc_vasprintf(const void *ctx, const char *fmt, va_list args);
* \return True unless allocation failed.
*/
bool ralloc_asprintf_rewrite_tail(char **str, size_t *start,
- const char *fmt, ...);
+ const char *fmt, ...)
+ PRINTFLIKE(3, 4);
/**
* Rewrite the tail of an existing string, starting at a given index.
@@ -376,7 +378,8 @@ bool ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt,
*
* \return True unless allocation failed.
*/
-bool ralloc_asprintf_append (char **str, const char *fmt, ...);
+bool ralloc_asprintf_append (char **str, const char *fmt, ...)
+ PRINTFLIKE(2, 3);
/**
* Append formatted text to the supplied string, given a va_list.
diff --git a/src/glsl/tests/Makefile.am b/src/glsl/tests/Makefile.am
index ee3cef6..957bb55 100644
--- a/src/glsl/tests/Makefile.am
+++ b/src/glsl/tests/Makefile.am
@@ -1,12 +1,9 @@
-INC = \
+AM_CPPFLAGS = \
-I$(top_builddir)/src/gtest/include \
-I$(top_builddir)/src/mesa \
-I$(top_builddir)/src/mapi \
-I$(top_builddir)/src/glsl
-AM_CFLAGS = $(INC)
-AM_CXXFLAGS = $(INC)
-
TESTS_ENVIRONMENT= \
export PYTHON2=$(PYTHON2); \
export PYTHON_FLAGS=$(PYTHON_FLAGS);
More information about the mesa-commit
mailing list