Merge pull request #2491 from janisozaur/fixes

Fix some compiler warnings
This commit is contained in:
Ted John 2015-12-14 22:02:41 +00:00
commit e0195fcffd
7 changed files with 20 additions and 10 deletions

View File

@ -1,7 +1,11 @@
#include "addresses.h"
#if defined(__GNUC__)
#define DISABLE_OPT __attribute__((noinline,optimize("O0")))
#ifdef __clang__
#define DISABLE_OPT __attribute__((noinline,optnone))
#else
#define DISABLE_OPT __attribute__((noinline,optimize("O0")))
#endif // __clang__
#else
#define DISABLE_OPT
#endif // defined(__GNUC__)

View File

@ -98,7 +98,7 @@ int cmdline_run(const char **argv, int argc)
*/
char** mutableArgv = malloc(argvsize);
memcpy(mutableArgv,argv,argvsize);
argc = argparse_parse(&argparse, argc, mutableArgv);
argc = argparse_parse(&argparse, argc, (const char**)mutableArgv);
if (version) {
print_version();
@ -130,7 +130,7 @@ int cmdline_run(const char **argv, int argc)
if (argc != 0) {
// see comment next to cmdline_call_action for expected return codes
gExitCode = cmdline_call_action(mutableArgv, argc);
gExitCode = cmdline_call_action((const char**)mutableArgv, argc);
free(mutableArgv);
if (gExitCode < 0) {
// action failed, don't change exit code
@ -236,7 +236,7 @@ struct { const char *firstArg; cmdline_action action; } cmdline_table[] = {
/**
* This function delegates starting the game to different handlers, if found.
*
*
* Three cases of return values are supported:
* - result < 0 means failure, will exit with error code
* This case is useful when user provided wrong arguments or the requested

View File

@ -434,8 +434,8 @@ int cmdline_for_sprite(const char **argv, int argc)
return -1;
}
printf("sprites: %lu\n", spriteFileHeader.num_entries);
printf("data size: %lu\n", spriteFileHeader.total_size);
printf("sprites: %u\n", spriteFileHeader.num_entries);
printf("data size: %u\n", spriteFileHeader.total_size);
sprite_file_close();
return 1;
@ -459,7 +459,7 @@ int cmdline_for_sprite(const char **argv, int argc)
printf("height: %d\n", g1->height);
printf("x offset: %d\n", g1->x_offset);
printf("y offset: %d\n", g1->y_offset);
printf("data offset: 0x%lX\n", (uint32)g1->offset);
printf("data offset: 0x%X\n", (uint32)g1->offset);
sprite_file_close();
return 1;

View File

@ -11,6 +11,7 @@ void http_dispose() { }
#else
#include <SDL.h>
#include "../core/Math.hpp"
// cURL includes windows.h, but we don't need all of it.
#define WIN32_LEAN_AND_MEAN
@ -65,7 +66,7 @@ static size_t http_request_write_func(void *ptr, size_t size, size_t nmemb, void
int newCapacity = writeBuffer->capacity;
int newLength = writeBuffer->length + newBytesLength;
while (newLength > newCapacity) {
newCapacity = max(4096, newCapacity * 2);
newCapacity = Math::Max(4096, newCapacity * 2);
}
if (newCapacity != writeBuffer->capacity) {
writeBuffer->ptr = (char*)realloc(writeBuffer->ptr, newCapacity);

View File

@ -1343,7 +1343,7 @@ int Network::Client_Handle_MAP(NetworkConnection& connection, NetworkPacket& pac
chunk_buffer.resize(offset + chunksize);
}
char status[256];
sprintf(status, "Downloading map ... (%lu / %lu)", (offset + chunksize) / 1000, size / 1000);
sprintf(status, "Downloading map ... (%u / %u)", (offset + chunksize) / 1000, size / 1000);
window_network_status_open(status);
memcpy(&chunk_buffer[offset], (void*)packet.Read(chunksize), chunksize);
if (offset + chunksize == size) {

View File

@ -64,12 +64,17 @@ typedef utf16* utf16string;
#define ror32(x, shift) (((uint32)(x) >> (shift)) | ((uint32)(x) << (32 - (shift))))
#define rol64(x, shift) (((uint64)(x) << (shift)) | ((uint32)(x) >> (64 - (shift))))
#define ror64(x, shift) (((uint64)(x) >> (shift)) | ((uint32)(x) << (64 - (shift))))
#ifndef __cplusplus
// in C++ you should be using Math::Min and Math::Max
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#endif // __cplusplus
#define sgn(x) ((x > 0) ? 1 : ((x < 0) ? -1 : 0))
#define clamp(l, x, h) (min(h, max(l, x)))

View File

@ -140,7 +140,7 @@ void window_server_start_open()
window->colours[1] = 26;
window->colours[2] = 26;
sprintf(_port, "%lu", gConfigNetwork.default_port);
sprintf(_port, "%u", gConfigNetwork.default_port);
safe_strncpy(_name, gConfigNetwork.server_name, sizeof(_name));
}