chiark / gitweb /
fix conversion error in stop.c
authorjschueller <julien.schueller@gmail.com>
Mon, 31 Aug 2015 09:27:19 +0000 (11:27 +0200)
committerjschueller <julien.schueller@gmail.com>
Mon, 31 Aug 2015 09:27:19 +0000 (11:27 +0200)
hi,

I got this error when compiling git head with gcc:

```
make[2]: Entering directory '/home/schueller/projects/nlopt/build/util'
/bin/sh ../libtool  --tag=CC   --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../util -I..  -I../../api   -g -O2 -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -Wno-long-long -pedantic -Wshadow -Wwrite-strings -Wredundant-decls -Wundef -Wconversion -MT stop.lo -MD -MP -MF .deps/stop.Tpo -c -o stop.lo ../../util/stop.c
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../../util -I.. -I../../api -g -O2 -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -Wno-long-long -pedantic -Wshadow -Wwrite-strings -Wredundant-decls -Wundef -Wconversion -MT stop.lo -MD -MP -MF .deps/stop.Tpo -c ../../util/stop.c  -fPIC -DPIC -o .libs/stop.o
../../util/stop.c: In function ‘char* nlopt_vsprintf(char*, const char*, __va_list_tag*)’:
../../util/stop.c:151:20: error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]
         p = realloc(p, len);
                    ^
Makefile:426: recipe for target 'stop.lo' failed
```

util/stop.c

index 8d999bfadf497d92b447fa0fb29d35a5eb643f66..0eeed3ddb8ddd6b636f9b7e5c249b55449b8d492 100644 (file)
@@ -148,7 +148,7 @@ char *nlopt_vsprintf(char *p, const char *format, va_list ap)
         /* C99 vsnprintf returns the required number of bytes (excluding \0)
            if the buffer is too small; older versions (e.g. MS) return -1 */
         len = ret >= 0 ? (size_t)(ret + 1) : (len*3)>>1;
-        p = realloc(p, len);
+        p = (char *) realloc(p, len);
         if (!p) abort();
     }
     return p;