[poppler] [PATCH] add "const" typing to Error handling

Kees Cook kees at outflux.net
Sat Apr 19 11:16:23 PDT 2008


Hello,

This patch fixes several chunks of warnings when code uses the defined
routines from Error.h.  For example:

SplashOutputDev.cc:1011: warning: deprecated conversion from string constant to 'char*'
SplashOutputDev.cc:1042: warning: deprecated conversion from string constant to 'char*'
SplashOutputDev.cc:1053: warning: deprecated conversion from string constant to 'char*'
...

Please keep me in CC, I'm not subscribed to the list.

Thanks,

-Kees

---
Fix const char declarations for error handlers.

Signed-off-by: Kees Cook <kees at outflux.net>
---
 Error.cc |   10 +++++-----
 Error.h  |    6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/poppler/Error.cc b/poppler/Error.cc
index 80e45aa..2eb2c3d 100644
--- a/poppler/Error.cc
+++ b/poppler/Error.cc
@@ -18,7 +18,7 @@
 #include "GlobalParams.h"
 #include "Error.h"
 
-static void defaultErrorFunction(int pos, char *msg, va_list args)
+static void defaultErrorFunction(int pos, const char *msg, va_list args)
 {
   if (pos >= 0) {
     fprintf(stderr, "Error (%d): ", pos);
@@ -30,14 +30,14 @@ static void defaultErrorFunction(int pos, char *msg, va_list args)
   fflush(stderr);
 }
 
-static void (*errorFunction)(int, char *, va_list args) = defaultErrorFunction;
+static void (*errorFunction)(int, const char *, va_list args) = defaultErrorFunction;
 
-void setErrorFunction(void (* f)(int, char *, va_list args))
+void setErrorFunction(void (* f)(int, const char *, va_list args))
 {
     errorFunction = f;
 }
 
-void CDECL error(int pos, char *msg, ...) {
+void CDECL error(int pos, const char *msg, ...) {
   va_list args;
   // NB: this can be called before the globalParams object is created
   if (globalParams && globalParams->getErrQuiet()) {
@@ -48,7 +48,7 @@ void CDECL error(int pos, char *msg, ...) {
   va_end(args);
 }
 
-void warning(char *msg, ...) {
+void warning(const char *msg, ...) {
   va_list args;
   va_start(args, msg);
   vprintf(msg, args);
diff --git a/poppler/Error.h b/poppler/Error.h
index 0f780c9..2afe961 100644
--- a/poppler/Error.h
+++ b/poppler/Error.h
@@ -16,9 +16,9 @@
 #include <stdarg.h>
 #include "poppler-config.h"
 
-extern void CDECL error(int pos, char *msg, ...) GCC_PRINTF_FORMAT (2, 3);
-void warning(char *msg, ...) GCC_PRINTF_FORMAT (1, 2);
+extern void CDECL error(int pos, const char *msg, ...) GCC_PRINTF_FORMAT (2, 3);
+void warning(const char *msg, ...) GCC_PRINTF_FORMAT (1, 2);
 
-void setErrorFunction(void (* f)(int , char *, va_list args));
+void setErrorFunction(void (* f)(int , const char *, va_list args));
 
 #endif


-- 
Kees Cook                                            @outflux.net


More information about the poppler mailing list