- Added GCC_PRINTF attribute to several funcs where it makes sense

- change some constants from double to float, to avoid "loss of precision due to implicit conversion" warnings
- removed duplicate prototypes for some funcs
- fixed some "increases required alignment of target type" warnings

svn-id: r42009
This commit is contained in:
Max Horn 2009-07-01 20:51:04 +00:00
parent 62acda5fdb
commit a6b57dc3a9
26 changed files with 52 additions and 74 deletions

View file

@ -26,6 +26,13 @@ CXXFLAGS+= -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-reorder
# Enable even more warnings...
CXXFLAGS+= -Wpointer-arith -Wcast-qual -Wcast-align
CXXFLAGS+= -Wshadow -Wimplicit -Wnon-virtual-dtor -Wwrite-strings
# TODO: Consider using -Wold-style-cast at some point
# CXXFLAGS+= -Wno-sign-compare
#CXXFLAGS+= -Wextra
CXXFLAGS+= -Wmissing-format-attribute
CXXFLAGS+= -Wredundant-decls
CXXFLAGS+= -Wconversion
#CXXFLAGS+= -Wshorten-64-to-32
# Disable RTTI and exceptions, and enabled checking of pointers returned by "new"
CXXFLAGS+= -fno-rtti -fno-exceptions -fcheck-new

View file

@ -993,7 +993,7 @@ public:
bool predictiveDialog(void);
private:
void printStatus(const char *message, ...);
void printStatus(const char *message, ...) GCC_PRINTF(2, 3);
void printText2(int l, const char *msg, int foff, int xoff, int yoff, int len, int fg, int bg, bool checkerboard = false);
void blitTextbox(const char *p, int y, int x, int len);
void eraseTextbox();

View file

@ -1977,7 +1977,7 @@ protected:
virtual void printScreenText(uint vgaSpriteId, uint color, const char *stringPtr, int16 x, int16 y, int16 width);
void printInteractText(uint16 num, const char *string);
void sendInteractText(uint16 num, const char *fmt, ...);
void sendInteractText(uint16 num, const char *fmt, ...) GCC_PRINTF(3, 4);
void checkLinkBox();
void hyperLinkOn(uint16 x);

View file

@ -70,7 +70,7 @@ int AGOSEngine::getScale(int16 y, int16 x) {
void AGOSEngine::vc75_setScale() {
_baseY = vcReadNextWord();
_scale = (float)vcReadNextWord() / 1000000.;
_scale = vcReadNextWord() / 1000000.0f;
}
void AGOSEngine::vc76_setScaleXOffs() {

View file

@ -37,8 +37,6 @@ const char **otherMessages;
const char *defaultCommandPreposition;
const char **commandPrepositionTable;
void generateMask(const byte *sprite, byte *mask, uint16 size, byte transparency);
/*! \brief Loads font data from the given file.
* The number of characters used in the font varies between game versions:
* 78 (Most PC, Amiga and Atari ST versions of Future Wars, but also Operation Stealth's Amiga demo),

View file

@ -80,8 +80,6 @@ extern int16 commandVar3[4];
extern char currentDatName[30];
extern uint16 musicIsPlaying;
void setTextWindow(uint16 param1, uint16 param2, uint16 param3, uint16 param4);
extern uint16 errorVar;
extern byte menuVar;

View file

@ -96,7 +96,6 @@ void *mallocAndZero(int32 size);
uint8 *mainProc14(uint16 overlay, uint16 idx);
void printInfoBlackBox(const char *string);
void waitForPlayerInput(void);
int initCt(const char * ctpName);
void loadPackedFileToMem(int fileIdx, uint8 * buffer);
int getNumObjectsByClass(int scriptIdx, int param);
void resetFileEntryRange(int param1, int param2);
@ -108,7 +107,6 @@ void resetPtr2(scriptInstanceStruct * ptr);
void getFileExtention(const char *name, char *buffer);
void *allocAndZero(int size);
void freeStuff2(void);
const char *getObjectName(int index, const char * string);
void mainLoop(void);
void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseY);
bool testMask(int x, int y, unsigned char* pData, int stride);

View file

@ -2095,7 +2095,7 @@ int IgorEngine::getHorizontalStepsCount(int minX, int minY, int maxX, int maxY)
float r2 = _walkScaleSpeedTable[scale - 1];
debugC(9, kDebugWalk, "getHorizontalStepsCount() maxX - minX = %d r1 = %f r2 = %f", maxX - minX, r1, r2);
int16 steps = roundReal((maxX - minX) / ((r1 + r2) / 2.));
int16 steps = roundReal((maxX - minX) / ((r1 + r2) / 2.0f));
int count = 0;
if (steps != 0) {
float r3 = (maxY - minY) / (float)steps;

View file

@ -230,11 +230,11 @@ const uint8 IgorEngine::_walkWidthScaleTable[] = {
};
const float IgorEngine::_walkScaleSpeedTable[] = {
0.6250, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.1250, 1.3750, 1.6250, 1.6250,
1.6250, 1.6250, 2.0000, 2.1250, 2.3750, 2.3750, 2.6250, 2.6250, 2.7500, 2.7500,
2.7500, 3.0000, 3.0000, 3.0000, 3.0000, 3.6250, 3.6250, 3.6250, 3.8750, 3.8750,
3.8750, 4.0000, 4.0000, 4.3750, 4.3750, 4.6250, 4.6250, 5.0000, 5.0000, 5.0000,
5.0000, 5.2500, 5.5000, 5.6250, 5.6250, 5.6250, 5.6250, 5.6250, 5.6250, 5.6250
0.6250f, 1.0000f, 1.0000f, 1.0000f, 1.0000f, 1.0000f, 1.1250f, 1.3750f, 1.6250f, 1.6250f,
1.6250f, 1.6250f, 2.0000f, 2.1250f, 2.3750f, 2.3750f, 2.6250f, 2.6250f, 2.7500f, 2.7500f,
2.7500f, 3.0000f, 3.0000f, 3.0000f, 3.0000f, 3.6250f, 3.6250f, 3.6250f, 3.8750f, 3.8750f,
3.8750f, 4.0000f, 4.0000f, 4.3750f, 4.3750f, 4.6250f, 4.6250f, 5.0000f, 5.0000f, 5.0000f,
5.0000f, 5.2500f, 5.5000f, 5.6250f, 5.6250f, 5.6250f, 5.6250f, 5.6250f, 5.6250f, 5.6250f
};
const uint8 IgorEngine::_walkScaleTable[] = {

View file

@ -260,7 +260,7 @@ private:
void drawBox(int x, int y, int w, int h, int fill);
bool getInput();
void printString(const char *string, int x, int y, int col1, int col2, int flags, ...);
void printString(const char *string, int x, int y, int col1, int col2, int flags, ...) GCC_PRINTF(2, 8);
};
} // end of namesapce Kyra

View file

@ -662,7 +662,7 @@ static int line_clip(rect_t *line, rect_t clip, int xfact, int yfact) {
return line_check_bar(&(line->x), &(line->width), clip.x, clip.width);
} else { // "normal" line
float start = 0.0, end = 1.0;
float start = 0.0f, end = 1.0f;
float xv = (float)line->width;
float yv = (float)line->height;
@ -682,7 +682,7 @@ static int line_clip(rect_t *line, rect_t clip, int xfact, int yfact) {
line->width = (int)(xv * (end - start));
line->height = (int)(yv * (end - start));
return (start > 1.0 || end < 0.0);
return (start > 1.0f || end < 0.0f);
}
}
@ -902,7 +902,7 @@ int gfxop_draw_rectangle(GfxState *state, rect_t rect, gfx_color_t color, gfx_li
int gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type) {
GfxDriver *drv = state->driver;
int reverse = 0; // switch color1 and color2
float mod_offset = 0.0, mod_breadth = 1.0; // 0.0 to 1.0: Color adjustment
float mod_offset = 0.0f, mod_breadth = 1.0f; // 0.0 to 1.0: Color adjustment
gfx_rectangle_fill_t driver_shade_type;
rect_t new_box;

View file

@ -482,7 +482,7 @@ void MidiDriver_Adlib::setNote(int voice, int note, bool key) {
if (bend < 8192)
bend = 8192 - bend;
delta = pow(2.0, (float)(bend % 8192) / 8192.0);
delta = (float)pow(2.0, (bend % 8192) / 8192.0);
if (bend > 8192)
fre = (int)(ym3812_note[n] * delta);

View file

@ -369,7 +369,7 @@ void ScummEngine::convertScaleTableToScaleSlot(int slot) {
*/
// Search for the bend on the left side
m = (resptr[199] - resptr[0]) / 199.0;
m = (resptr[199] - resptr[0]) / 199.0f;
for (lowerIdx = 0; lowerIdx < 199 && (resptr[lowerIdx] == 1 || resptr[lowerIdx] == 255); lowerIdx++) {
oldM = m;
m = (resptr[199] - resptr[lowerIdx+1]) / (float)(199 - (lowerIdx+1));
@ -383,7 +383,7 @@ void ScummEngine::convertScaleTableToScaleSlot(int slot) {
}
// Search for the bend on the right side
m = (resptr[199] - resptr[0]) / 199.0;
m = (resptr[199] - resptr[0]) / 199.0f;
for (upperIdx = 199; upperIdx > 1 && (resptr[upperIdx] == 1 || resptr[upperIdx] == 255); upperIdx--) {
oldM = m;
m = (resptr[upperIdx-1] - resptr[0]) / (float)(upperIdx-1);

View file

@ -574,13 +574,13 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i
if (width <= 0 || height <= 0)
return;
const byte *src = vs->getPixels(x, top);
const void *src = vs->getPixels(x, top);
int m = _textSurfaceMultiplier;
int vsPitch;
int pitch = vs->pitch;
if (_useCJKMode && _textSurfaceMultiplier == 2) {
scale2x(_fmtownsBuf, _screenWidth * m, src, vs->pitch, width, height);
scale2x(_fmtownsBuf, _screenWidth * m, (const byte *)src, vs->pitch, width, height);
src = _fmtownsBuf;
vsPitch = _screenWidth * m - width * m;
@ -599,7 +599,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i
// Compute pointer to the text surface
assert(_compositeBuf);
const byte *text = (byte *)_textSurface.getBasePtr(x * m, y * m);
const void *text = _textSurface.getBasePtr(x * m, y * m);
// The values x, width, etc. are all multiples of 8 at this point,
// so loop unrolloing might be a good idea...
@ -677,7 +677,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i
}
// Finally blit the whole thing to the screen
_system->copyRectToScreen(src, pitch, x, y, width, height);
_system->copyRectToScreen((const byte *)src, pitch, x, y, width, height);
}
// CGA

View file

@ -423,8 +423,8 @@ public:
void setPalette(int16 startEntry, int16 noEntries, byte *palette, uint8 setNow);
void setSystemPalette(const byte *colors, uint start, uint num);
uint8 quickMatch(uint8 r, uint8 g, uint8 b);
int32 fadeUp(float time = 0.75);
int32 fadeDown(float time = 0.75);
int32 fadeUp(float time = 0.75f);
int32 fadeDown(float time = 0.75f);
uint8 getFadeStatus();
void dimPalette(bool dim);
void waitForFade();

View file

@ -137,8 +137,6 @@ int GetActorFilmNumber(int ano);
void StoreActorReel(int actor, int column, OBJECT *pObj);
void NotPlayingReel(int actor, int filmNumber, int column);
bool ActorReelPlaying(int actor, int column);
void SetActorPlayFilm(int ano, SCNHANDLE hFilm);
SCNHANDLE GetActorPlayFilm(int ano);
/*----------------------------------------------------------------------*/
@ -161,8 +159,6 @@ struct Z_POSITIONS {
int z;
};
int SaveActors(SAVED_ACTOR *sActorInfo);
void RestoreActorProcess(int id, INT_CONTEXT *pic);
int SaveActors(PSAVED_ACTOR sActorInfo);

View file

@ -55,14 +55,6 @@ extern int newestString; // The overrun counter, in STRRES.C
#endif
//----------------- EXTERNAL FUNCTIONS ---------------------
// in BG.C
extern int BgWidth(void);
extern int BgHeight(void);
//----------------- LOCAL DEFINES --------------------
#define LPOSX 295 // X-co-ord of lead actor's position display

View file

@ -92,7 +92,6 @@ bool IsPolyCorner(HPOLYGON hPath, int x, int y);
int GetScale(HPOLYGON path, int y);
int GetBrightness(HPOLYGON hPath, int y);
void getNpathNode(HPOLYGON npath, int node, int *px, int *py);
void GetTagTag(HPOLYGON p, SCNHANDLE *hTagText, int *tagx, int *tagy);
SCNHANDLE GetPolyFilm(HPOLYGON p);
void GetPolyNode(HPOLYGON hp, int *pNodeX, int *pNodeY);
SCNHANDLE GetPolyScript(HPOLYGON p);
@ -108,8 +107,6 @@ void DisablePath(int path);
void EnablePath(int path);
void DisableRefer(int refer);
void EnableRefer(int refer);
void DisableBlock(int blockno);
void EnableBlock(int blockno);
HPOLYGON GetTagHandle(int tagno);
void DisableTag(CORO_PARAM, int tag);
void EnableTag(CORO_PARAM, int tag);
@ -152,7 +149,6 @@ bool PolyTagIsWanted(HPOLYGON hp);
bool PolyTagFollowsCursor(HPOLYGON hp);
SCNHANDLE GetPolyTagHandle(HPOLYGON hp);
bool IsTagPolygon(int tagno);
int GetTagPolyId(HPOLYGON hp);
void GetPolyMidBottom(HPOLYGON hp, int *pX, int *pY);
int PathCount(void);
void MovePolygon(PTYPE ptype, int id, int x, int y);

View file

@ -89,8 +89,6 @@ int clRunMode = 0;
// in BG.CPP
extern void ChangePalette(SCNHANDLE hPal);
extern int BgWidth(void);
extern int BgHeight(void);
// in BMV.CPP
void PlayBMV(CORO_PARAM, SCNHANDLE hFileStem, int myEscape);
@ -278,7 +276,6 @@ static COLORREF s_talkfontColor = 0;
//----------------- FORWARD REFERENCES --------------------
static int HeldObject(void);
void Offset(EXTREME extreme, int x, int y);
static void PostTag(CORO_PARAM, int tagno, TINSEL_EVENT event, HPOLYGON hp, int myEscape);
void ResetIdleTime(void);
static void SendTag(CORO_PARAM, int tagno, TINSEL_EVENT event, HPOLYGON hp, int myEscape, bool *result);

View file

@ -93,10 +93,6 @@ extern void InventoryProcess(CORO_PARAM, const void *);
extern void PrimeBackground();
extern SCNHANDLE GetSceneHandle(void);
// In TIMER.CPP
extern void FettleTimers(void);
extern void RebootTimers(void);
//----------------- FORWARD DECLARATIONS ---------------------
void SetNewScene(SCNHANDLE scene, int entrance, int transition);

View file

@ -39,7 +39,7 @@ Debugger::Debugger() {
_isAttached = false;
_errStr = NULL;
_firstTime = true;
_debuggerDialog = new GUI::ConsoleDialog(1.0, 0.67F);
_debuggerDialog = new GUI::ConsoleDialog(1.0f, 0.67f);
_debuggerDialog->setInputCallback(debuggerInputCallback, this);
_debuggerDialog->setCompletionCallback(debuggerCompletionCallback, this);

View file

@ -35,9 +35,9 @@
// powf, resulting in a linker error because of multiple definitions.
// Hence we re-define them here. The only potential drawback is that it
// might be a little bit slower this way.
#define powf pow
#define floorf floor
#define fabsf fabs
#define powf(x,y) ((float)pow(x,y))
#define floorf(x) ((float)floorf(x))
#define fabsf(x) ((float)fabs(x))
#endif
#define FIXEDPOINT_UDIV(x, y, point) (((x) << (point)) / ((y)))
@ -504,10 +504,10 @@ Bit16s *Partial::mixBuffersRingMix(Bit16s * buf1, Bit16s *buf2, int len) {
a = ((float)*buf1) / 8192.0f;
b = ((float)*buf2) / 8192.0f;
a = (a * b) + a;
if (a>1.0)
a = 1.0;
if (a<-1.0)
a = -1.0;
if (a > 1.0f)
a = 1.0f;
if (a < -1.0f)
a = -1.0f;
*buf1 = (Bit16s)(a * 8192.0f);
buf1++;
buf2++;
@ -537,10 +537,10 @@ Bit16s *Partial::mixBuffersRing(Bit16s * buf1, Bit16s *buf2, int len) {
a = ((float)*buf1) / 8192.0f;
b = ((float)*buf2) / 8192.0f;
a *= b;
if (a>1.0)
a = 1.0;
if (a<-1.0)
a = -1.0;
if (a > 1.0f)
a = 1.0f;
if (a < -1.0f)
a = -1.0f;
*buf1 = (Bit16s)(a * 8192.0f);
buf1++;
buf2++;

View file

@ -35,9 +35,9 @@
// powf, resulting in a linker error because of multiple definitions.
// Hence we re-define them here. The only potential drawback is that it
// might be a little bit slower this way.
#define powf pow
#define floorf floor
#define fabsf fabs
#define powf(x,y) ((float)pow(x,y))
#define floorf(x) ((float)floorf(x))
#define fabsf(x) ((float)fabs(x))
#endif
namespace MT32Emu {

View file

@ -22,7 +22,7 @@
#ifndef MT32EMU_SYNTH_H
#define MT32EMU_SYNTH_H
#include <stdarg.h>
#include "common/scummsys.h"
class revmodel;
@ -256,7 +256,7 @@ protected:
int report(ReportType type, const void *reportData);
File *openFile(const char *filename, File::OpenMode mode);
void closeFile(File *file);
void printDebug(const char *fmt, ...);
void printDebug(const char *fmt, ...) GCC_PRINTF(2, 3);
public:
static Bit8u calcSysexChecksum(const Bit8u *data, Bit32u len, Bit8u checksum);

View file

@ -35,9 +35,9 @@
// powf, resulting in a linker error because of multiple definitions.
// Hence we re-define them here. The only potential drawback is that it
// might be a little bit slower this way.
#define powf pow
#define floorf floor
#define fabsf fabs
#define powf(x,y) ((float)pow(x,y))
#define floorf(x) ((float)floorf(x))
#define fabsf(x) ((float)fabs(x))
#endif
#define FIXEDPOINT_MAKE(x, point) ((Bit32u)((1 << point) * x))
@ -730,7 +730,7 @@ Tables::Tables() {
bool Tables::init(Synth *synth, PCMWaveEntry *pcmWaves, float sampleRate, float masterTune) {
if (sampleRate <= 0.0f) {
synth->printDebug("Bad sampleRate (%d <= 0.0f)", sampleRate);
synth->printDebug("Bad sampleRate (%f <= 0.0f)", sampleRate);
return false;
}
if (initialisedSampleRate == 0.0f) {

View file

@ -60,7 +60,7 @@ static size_t read_stream_wrap(void *ptr, size_t size, size_t nmemb, void *datas
static int seek_stream_wrap(void *datasource, ogg_int64_t offset, int whence) {
Common::SeekableReadStream *stream = (Common::SeekableReadStream *)datasource;
stream->seek(offset, whence);
stream->seek((int32)offset, whence);
return stream->pos();
}