more C89-fixes

going down to strict -ansi c89 is quite overkill (no 'inline',
and /* */-style comments).
But with these fixes, the code compiles with the stringent flags:
 -Wextra -Wold-style-definition -Wmissing-prototypes
 -Wmissing-declarations and -Wdeclaration-after-statement

Change-Id: I36222f8f505bcba3d9d1309ad98b5ccb04ec17e3
This commit is contained in:
Pascal Massimino
2011-03-25 15:04:11 -07:00
parent 0de013b3a4
commit f8db5d5d1c
20 changed files with 63 additions and 42 deletions

View File

@ -266,7 +266,7 @@ clean-noinstLTLIBRARIES:
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libwebpencode.la: $(libwebpencode_la_OBJECTS) $(libwebpencode_la_DEPENDENCIES)
libwebpencode.la: $(libwebpencode_la_OBJECTS) $(libwebpencode_la_DEPENDENCIES)
$(libwebpencode_la_LINK) $(libwebpencode_la_OBJECTS) $(libwebpencode_la_LIBADD) $(LIBS)
mostlyclean-compile:

View File

@ -21,9 +21,11 @@ extern "C" {
static uint8_t clip1[255 + 510 + 1]; // clips [-255,510] to [0,255]
static int tables_ok = 0;
// We declare this variable 'volatile' to prevent instruction reordering
// and make sure it's set to true _last_ (so as to be thread-safe)
static volatile int tables_ok = 0;
static void InitTables() {
static void InitTables(void) {
if (!tables_ok) {
int i;
for (i = -255; i <= 255 + 255; ++i) {
@ -79,7 +81,7 @@ static void ITransform(const uint8_t* ref, const int16_t* in, uint8_t* dst) {
}
}
void FTransform(const uint8_t* src, const uint8_t* ref, int16_t* out) {
static void FTransform(const uint8_t* src, const uint8_t* ref, int16_t* out) {
int i;
int tmp[16];
for (i = 0; i < 4; ++i, src += BPS, ref += BPS) {
@ -636,7 +638,7 @@ VP8BlockCopy VP8Copy16x16 = Copy16x16;
//-----------------------------------------------------------------------------
void VP8EncDspInit() {
void VP8EncDspInit(void) {
InitTables();
}

View File

@ -25,7 +25,7 @@ static uint8_t clip1[255 + 510 + 1]; // clips [-255,510] to [0,255]
static int tables_ok = 0;
static void InitTables() {
static void InitTables(void) {
if (!tables_ok) {
int i;
for (i = -255; i <= 255; ++i) {

View File

@ -270,7 +270,7 @@ int VP8IteratorNext(VP8EncIterator* const it,
//-----------------------------------------------------------------------------
// Helper function to set mode properties
void VP8SetIntra16Mode(const VP8EncIterator* it, int mode) {
void VP8SetIntra16Mode(const VP8EncIterator* const it, int mode) {
int y;
uint8_t* preds = it->preds_;
for (y = 0; y < 4; ++y) {

View File

@ -38,7 +38,7 @@ int WebPPictureAlloc(WebPPicture* const picture) {
picture->y_stride = width;
picture->uv_stride = uv_width;
WebPPictureFree(picture); // erase previous buffer
picture->y = (uint8_t*)malloc(total_size);
picture->y = (uint8_t*)malloc((size_t)total_size);
if (picture->y == NULL) return 0;
picture->u = picture->y + y_size;
picture->v = picture->u + uv_size;
@ -163,7 +163,7 @@ enum { YUV_FRAC = 16 };
static inline int clip_uv(int v) {
v = (v + (257 << (YUV_FRAC + 2 - 1))) >> (YUV_FRAC + 2);
return ((v & ~0xff) == 0) ? v : (v < 0) ? 0u : 255u;
return ((v & ~0xff) == 0) ? v : (v < 0) ? 0 : 255;
}
static inline int rgb_to_y(int r, int g, int b) {

View File

@ -455,7 +455,7 @@ typedef enum {
typedef int (*VP8CPUInfo)(CPUFeature feature);
extern VP8CPUInfo CPUInfo;
void VP8EncDspInit(); // must be called before using anything from the above.
void VP8EncDspInit(void); // must be called before using any of the above
// in filter.c
extern void VP8InitFilter(VP8EncIterator* const it);

View File

@ -29,7 +29,7 @@ extern "C" {
//-----------------------------------------------------------------------------
int WebPGetEncoderVersion() {
int WebPGetEncoderVersion(void) {
return (ENC_MAJ_VERSION << 16) | (ENC_MIN_VERSION << 8) | ENC_REV_VERSION;
}
@ -39,6 +39,10 @@ int WebPGetEncoderVersion() {
static int DummyWriter(const uint8_t* data, size_t data_size,
const WebPPicture* const picture) {
// The following are to prevent 'unused variable' error message.
(void)data;
(void)data_size;
(void)picture;
return 1;
}