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

@@ -28,9 +28,11 @@ static int8_t sclip1[1020 + 1020 + 1]; // clips [-1020, 1020] to [-128, 127]
static int8_t sclip2[112 + 112 + 1]; // clips [-112, 112] to [-16, 15]
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;
void VP8DspInitTables() {
void VP8DspInitTables(void) {
if (!tables_ok) {
int i;
for (i = -255; i <= 255; ++i) {
@@ -685,7 +687,7 @@ void (*VP8SimpleHFilter16i)(uint8_t*, int, int) = SimpleHFilter16i;
//-----------------------------------------------------------------------------
void VP8DspInit() {
void VP8DspInit(void) {
// later we'll plug some SSE2 variant here
}

View File

@@ -496,10 +496,11 @@ static VP8StatusCode IDecCheckStatus(const WebPIDecoder* const idec) {
VP8StatusCode WebPIAppend(WebPIDecoder* const idec, const uint8_t* data,
uint32_t data_size) {
VP8StatusCode status;
if (idec == NULL || data == NULL) {
return VP8_STATUS_INVALID_PARAM;
}
const VP8StatusCode status = IDecCheckStatus(idec);
status = IDecCheckStatus(idec);
if (status != VP8_STATUS_SUSPENDED) {
return status;
}
@@ -516,10 +517,11 @@ VP8StatusCode WebPIAppend(WebPIDecoder* const idec, const uint8_t* data,
VP8StatusCode WebPIUpdate(WebPIDecoder* const idec, const uint8_t* data,
uint32_t data_size) {
VP8StatusCode status;
if (idec == NULL || data == NULL) {
return VP8_STATUS_INVALID_PARAM;
}
const VP8StatusCode status = IDecCheckStatus(idec);
status = IDecCheckStatus(idec);
if (status != VP8_STATUS_SUSPENDED) {
return status;
}
@@ -536,7 +538,7 @@ VP8StatusCode WebPIUpdate(WebPIDecoder* const idec, const uint8_t* data,
//------------------------------------------------------------------------------
uint8_t* WebPIDecGetRGB(const WebPIDecoder* idec, int *last_y,
uint8_t* WebPIDecGetRGB(const WebPIDecoder* const idec, int *last_y,
int* width, int* height, int* stride) {
if (!idec || !idec->dec_ || idec->params_.mode != MODE_RGB ||
idec->state_ <= STATE_PARTS0) {
@@ -551,9 +553,9 @@ uint8_t* WebPIDecGetRGB(const WebPIDecoder* idec, int *last_y,
return idec->params_.output;
}
uint8_t* WebPIDecGetYUV(const WebPIDecoder* idec, int *last_y, uint8_t** u,
uint8_t** v, int* width, int* height, int *stride,
int* uv_stride) {
uint8_t* WebPIDecGetYUV(const WebPIDecoder* const idec, int *last_y,
uint8_t** u, uint8_t** v, int* width, int* height,
int *stride, int* uv_stride) {
if (!idec || !idec->dec_ || idec->params_.mode != MODE_YUV ||
idec->state_ <= STATE_PARTS0) {
return NULL;

View File

@@ -18,7 +18,7 @@ extern "C" {
//-----------------------------------------------------------------------------
int WebPGetDecoderVersion() {
int WebPGetDecoderVersion(void) {
return (DEC_MAJ_VERSION << 16) | (DEC_MIN_VERSION << 8) | DEC_REV_VERSION;
}
@@ -39,7 +39,7 @@ int VP8InitIoInternal(VP8Io* const io, int version) {
return 1;
}
VP8Decoder* VP8New() {
VP8Decoder* VP8New(void) {
VP8Decoder* dec = (VP8Decoder*)calloc(1, sizeof(VP8Decoder));
if (dec) {
SetOk(dec);

View File

@@ -289,8 +289,8 @@ extern VP8PredFunc VP8PredLuma16[NUM_B_DC_MODES];
extern VP8PredFunc VP8PredChroma8[NUM_B_DC_MODES];
extern VP8PredFunc VP8PredLuma4[NUM_BMODES];
void VP8DspInit(); // must be called before anything using the above
void VP8DspInitTables(); // needs to be called no matter what.
void VP8DspInit(void); // must be called before anything using the above
void VP8DspInitTables(void); // needs to be called no matter what.
// simple filter (only for luma)
typedef void (*VP8SimpleFilterFunc)(uint8_t* p, int stride, int thresh);

View File

@@ -533,8 +533,9 @@ static uint8_t* Decode(WEBP_CSP_MODE mode, const uint8_t* data,
uint32_t data_size, int* width, int* height,
WebPDecParams* params_out) {
uint8_t* output;
WebPDecParams params = { 0 };
WebPDecParams params;
memset(&params, 0, sizeof(params));
params.mode = mode;
if (!WebPInitDecParams(data, data_size, width, height, &params)) {
return NULL;

View File

@@ -23,7 +23,7 @@ uint8_t VP8kClip[YUV_RANGE_MAX - YUV_RANGE_MIN];
static int done = 0;
void VP8YUVInit() {
void VP8YUVInit(void) {
int i;
if (done) {
return;

View File

@@ -57,7 +57,7 @@ inline static void VP8YuvToBgra(int y, int u, int v, uint8_t* const bgra) {
}
// Must be called before everything, to initialize the tables.
void VP8YUVInit();
void VP8YUVInit(void);
#if defined(__cplusplus) || defined(c_plusplus)
} // extern "C"

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;
}

View File

@@ -20,7 +20,7 @@ extern "C" {
// Return the decoder's version number, packed in hexadecimal using 8bits for
// each of major/minor/revision. E.g: v2.5.7 is 0x020507.
int WebPGetDecoderVersion();
int WebPGetDecoderVersion(void);
// Retrieve basic header information: width, height.
// This function will also validate the header and return 0 in
@@ -173,6 +173,8 @@ VP8StatusCode WebPIAppend(WebPIDecoder* const idec, const uint8_t* data,
// A variant of the above function to be used when data buffer contains
// partial data from the beginning. In this case data buffer is not copied
// to the internal memory.
// Note that the value of the 'data' pointer can change between calls to
// WebPIUpdate, for instance when the data buffer is resized to fit larger data.
VP8StatusCode WebPIUpdate(WebPIDecoder* const idec, const uint8_t* data,
uint32_t data_size);

View File

@@ -83,13 +83,13 @@ struct VP8Io {
};
// Internal, version-checked, entry point
extern int VP8InitIoInternal(VP8Io* const, int);
int VP8InitIoInternal(VP8Io* const, int);
// Main decoding object. This is an opaque structure.
typedef struct VP8Decoder VP8Decoder;
// Create a new decoder object.
VP8Decoder* VP8New();
VP8Decoder* VP8New(void);
// Must be called to make sure 'io' is initialized properly.
// Returns false in case of version mismatch. Upon such failure, no other

View File

@@ -24,7 +24,7 @@ extern "C" {
// Return the encoder's version number, packed in hexadecimal using 8bits for
// each of major/minor/revision. E.g: v2.5.7 is 0x020507.
int WebPGetEncoderVersion();
int WebPGetEncoderVersion(void);
//-----------------------------------------------------------------------------
// One-stop-shop call! No questions asked: