fixes for -ansi -pedantic

This commit is contained in:
Enno Rehling 2011-03-07 17:26:50 +01:00
parent 78b7dcd727
commit 496aa22e65
20 changed files with 38 additions and 34 deletions

View file

@ -21,7 +21,7 @@ extern "C" {
typedef enum { typedef enum {
TNONE = 0, TINTEGER = 1, TREAL = 2, TSTRING = 3, TNONE = 0, TINTEGER = 1, TREAL = 2, TSTRING = 3,
TUNIT = 10, TFACTION = 11, TREGION = 12, TBUILDING = 13, TSHIP = 14, TUNIT = 10, TFACTION = 11, TREGION = 12, TBUILDING = 13, TSHIP = 14
} object_type; } object_type;
extern struct attrib_type at_object; extern struct attrib_type at_object;

View file

@ -296,7 +296,7 @@ static int read_ext(attrib * a, void *owner, struct storage *store)
a->data.v = 0; a->data.v = 0;
ur_add(data, a, resolve_bson); ur_add(data, a, resolve_bson);
return AT_READ_OK; return AT_READ_OK;
}; }
attrib_type at_lua_ext = { attrib_type at_lua_ext = {
"lua", init_ext, free_ext, age_ext, write_ext, read_ext "lua", init_ext, free_ext, age_ext, write_ext, read_ext

View file

@ -69,7 +69,7 @@ int tolua_faction_add_item(lua_State * L)
if (itype != NULL) { if (itype != NULL) {
item *i = i_change(&self->items, itype, number); item *i = i_change(&self->items, itype, number);
result = i ? i->number : 0; result = i ? i->number : 0;
} // if (itype!=NULL) } /* if (itype!=NULL) */
} }
lua_pushnumber(L, result); lua_pushnumber(L, result);
return 1; return 1;

View file

@ -1,7 +1,7 @@
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
// kernel includes /* kernel includes */
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/message.h> #include <kernel/message.h>
@ -9,10 +9,10 @@
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/unit.h> #include <kernel/unit.h>
// util includes /* util includes */
#include <util/message.h> #include <util/message.h>
// lua includes /* lua includes */
#include <lua.h> #include <lua.h>
#include <tolua.h> #include <tolua.h>

View file

@ -16,11 +16,11 @@ without prior permission by the authors of Eressea.
#include "bind_attrib.h" #include "bind_attrib.h"
#include "bindings.h" #include "bindings.h"
// attributes includes /* attributes includes */
#include <attributes/racename.h> #include <attributes/racename.h>
#include <attributes/key.h> #include <attributes/key.h>
// kernel includes /* kernel includes */
#include <kernel/building.h> #include <kernel/building.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/faction.h> #include <kernel/faction.h>
@ -37,7 +37,7 @@ without prior permission by the authors of Eressea.
#include <kernel/spell.h> #include <kernel/spell.h>
#include <kernel/unit.h> #include <kernel/unit.h>
// util includes /* util includes */
#include <util/attrib.h> #include <util/attrib.h>
#include <util/base36.h> #include <util/base36.h>
#include <util/event.h> #include <util/event.h>
@ -937,7 +937,7 @@ void tolua_unit_open(lua_State * L)
tolua_function(L, TOLUA_CAST "clear_orders", &tolua_unit_clear_orders); tolua_function(L, TOLUA_CAST "clear_orders", &tolua_unit_clear_orders);
tolua_variable(L, TOLUA_CAST "orders", &tolua_unit_get_orders, 0); tolua_variable(L, TOLUA_CAST "orders", &tolua_unit_get_orders, 0);
// key-attributes for named flags: /* key-attributes for named flags: */
tolua_function(L, TOLUA_CAST "set_flag", &tolua_unit_set_flag); tolua_function(L, TOLUA_CAST "set_flag", &tolua_unit_set_flag);
tolua_function(L, TOLUA_CAST "get_flag", &tolua_unit_get_flag); tolua_function(L, TOLUA_CAST "get_flag", &tolua_unit_get_flag);
tolua_variable(L, TOLUA_CAST "flags", &tolua_unit_get_flags, tolua_variable(L, TOLUA_CAST "flags", &tolua_unit_get_flags,
@ -945,21 +945,21 @@ void tolua_unit_open(lua_State * L)
tolua_variable(L, TOLUA_CAST "age", &tolua_unit_get_age, tolua_variable(L, TOLUA_CAST "age", &tolua_unit_get_age,
tolua_unit_set_age); tolua_unit_set_age);
// items: /* items: */
tolua_function(L, TOLUA_CAST "get_item", &tolua_unit_get_item); tolua_function(L, TOLUA_CAST "get_item", &tolua_unit_get_item);
tolua_function(L, TOLUA_CAST "add_item", &tolua_unit_add_item); tolua_function(L, TOLUA_CAST "add_item", &tolua_unit_add_item);
tolua_variable(L, TOLUA_CAST "items", &tolua_unit_get_items, 0); tolua_variable(L, TOLUA_CAST "items", &tolua_unit_get_items, 0);
tolua_function(L, TOLUA_CAST "get_pooled", &tolua_unit_get_pooled); tolua_function(L, TOLUA_CAST "get_pooled", &tolua_unit_get_pooled);
tolua_function(L, TOLUA_CAST "use_pooled", &tolua_unit_use_pooled); tolua_function(L, TOLUA_CAST "use_pooled", &tolua_unit_use_pooled);
// skills: /* skills: */
tolua_function(L, TOLUA_CAST "get_skill", &tolua_unit_getskill); tolua_function(L, TOLUA_CAST "get_skill", &tolua_unit_getskill);
tolua_function(L, TOLUA_CAST "eff_skill", &tolua_unit_effskill); tolua_function(L, TOLUA_CAST "eff_skill", &tolua_unit_effskill);
tolua_function(L, TOLUA_CAST "set_skill", &tolua_unit_setskill); tolua_function(L, TOLUA_CAST "set_skill", &tolua_unit_setskill);
tolua_function(L, TOLUA_CAST "add_notice", &tolua_unit_addnotice); tolua_function(L, TOLUA_CAST "add_notice", &tolua_unit_addnotice);
// npc logic: /* npc logic: */
tolua_function(L, TOLUA_CAST "add_handler", &tolua_unit_addhandler); tolua_function(L, TOLUA_CAST "add_handler", &tolua_unit_addhandler);
tolua_variable(L, TOLUA_CAST "race_name", &tolua_unit_get_racename, tolua_variable(L, TOLUA_CAST "race_name", &tolua_unit_get_racename,

View file

@ -23,7 +23,7 @@
#include <bindings/bind_ship.h> #include <bindings/bind_ship.h>
#include <bindings/bind_storage.h> #include <bindings/bind_storage.h>
#include <bindings/bind_unit.h> #include <bindings/bind_unit.h>
#endif // BINDINGS_TOLUA #endif /* BINDINGS_TOLUA */
#if MUSEUM_MODULE #if MUSEUM_MODULE
#include <modules/museum.h> #include <modules/museum.h>

View file

@ -731,7 +731,7 @@ static void
growing_trees_e3(region * r, const int current_season, growing_trees_e3(region * r, const int current_season,
const int last_weeks_season) const int last_weeks_season)
{ {
const static int transform[4][3] = { static const int transform[4][3] = {
{-1, -1, 0}, {-1, -1, 0},
{TREE_SEED, TREE_SAPLING, 2}, {TREE_SEED, TREE_SAPLING, 2},
{TREE_SAPLING, TREE_TREE, 2}, {TREE_SAPLING, TREE_TREE, 2},

View file

@ -2400,7 +2400,7 @@ report_plaintext(const char *filename, report_context * ctx,
rnl(F); rnl(F);
nr_paragraph(F, m, f); nr_paragraph(F, m, f);
} }
// /* */
} else { } else {
if (!fval(r->terrain, SEA_REGION) && rpeasants(r) / TRADE_FRACTION > 0) { if (!fval(r->terrain, SEA_REGION) && rpeasants(r) / TRADE_FRACTION > 0) {
rnl(F); rnl(F);

View file

@ -754,7 +754,7 @@ static xmlNodePtr report_root(report_context * ctx)
xmlAddChild(xmlReport, xml_region(ctx, sr)); xmlAddChild(xmlReport, xml_region(ctx, sr));
} }
return xmlReport; return xmlReport;
}; }
/* main function of the xmlreport. creates the header and traverses all regions */ /* main function of the xmlreport. creates the header and traverses all regions */
static int static int

View file

@ -96,8 +96,8 @@ typedef struct alliance_transaction {
struct alliance_transaction *next; struct alliance_transaction *next;
unit *u; unit *u;
order *ord; order *ord;
// alliance * al; /* alliance * al; */
// variant userdata; /* variant userdata; */
} alliance_transaction; } alliance_transaction;
static struct alliance_transaction *transactions[ALLIANCE_MAX]; static struct alliance_transaction *transactions[ALLIANCE_MAX];
@ -321,9 +321,9 @@ void alliance_cmd(void)
if (stree == NULL) { if (stree == NULL) {
syntaxtree *slang = stree = stree_create(); syntaxtree *slang = stree = stree_create();
while (slang) { while (slang) {
// struct tnode * root = calloc(sizeof(tnode), 1); /* struct tnode * root = calloc(sizeof(tnode), 1); */
struct tnode *leaf = calloc(sizeof(tnode), 1); struct tnode *leaf = calloc(sizeof(tnode), 1);
// add_command(root, leaf, LOC(slang->lang, "alliance"), NULL); /* add_command(root, leaf, LOC(slang->lang, "alliance"), NULL); */
add_command(leaf, NULL, LOC(slang->lang, "new"), &cmd_new); add_command(leaf, NULL, LOC(slang->lang, "new"), &cmd_new);
add_command(leaf, NULL, LOC(slang->lang, "invite"), &cmd_invite); add_command(leaf, NULL, LOC(slang->lang, "invite"), &cmd_invite);
add_command(leaf, NULL, LOC(slang->lang, "join"), &cmd_join); add_command(leaf, NULL, LOC(slang->lang, "join"), &cmd_join);

View file

@ -494,7 +494,9 @@ item *i_change(item ** pi, const item_type * itype, int delta)
if (i->number < 0) { if (i->number < 0) {
log_error(("serious accounting error. number of items is %d.\n", log_error(("serious accounting error. number of items is %d.\n",
i->number)); i->number));
/* FIXME what's this supposed to mean??
assert(i >= 0); assert(i >= 0);
*/
i->number = 0; i->number = 0;
} }
if (i->number == 0) { if (i->number == 0) {

View file

@ -53,7 +53,7 @@ extern "C" {
SPP_BUILDING, /* - : atoi() -> int */ SPP_BUILDING, /* - : atoi() -> int */
SPP_SHIP, /* - : atoi() -> int */ SPP_SHIP, /* - : atoi() -> int */
SPP_STRING, /* "c" */ SPP_STRING, /* "c" */
SPP_INT, /* "i" : atoi() -> int */ SPP_INT /* "i" : atoi() -> int */
} sppobj_t; } sppobj_t;
typedef struct spllprm { typedef struct spllprm {

View file

@ -1141,7 +1141,7 @@ void seen_done(seen_region * seehash[])
reuse = seehash[i]; reuse = seehash[i];
seehash[i] = NULL; seehash[i] = NULL;
} }
// free(seehash); /* free(seehash); */
} }
void free_seen(void) void free_seen(void)

View file

@ -22,7 +22,7 @@ extern "C" {
#define SMF_RIDING (1<<2) /* Bonus für berittene - an der rasse */ #define SMF_RIDING (1<<2) /* Bonus für berittene - an der rasse */
typedef struct skill { typedef struct skill {
skill_t id:8; unsigned int id:8;
unsigned int level:8; unsigned int level:8;
unsigned int weeks:8; unsigned int weeks:8;
unsigned int old:8; unsigned int old:8;

View file

@ -135,7 +135,7 @@ static int txt_open(struct storage *store, const char *filename, int mode)
FILE *F = fopen(filename, modes[mode]); FILE *F = fopen(filename, modes[mode]);
store->userdata = F; store->userdata = F;
if (F) { if (F) {
const char utf8_bom[4] = { 0xef, 0xbb, 0xbf }; char utf8_bom[4] = { (char)0xef, (char)0xbb, (char)0xbf };
if (mode == IO_READ) { if (mode == IO_READ) {
char token[8]; char token[8];
/* recognize UTF8 BOM */ /* recognize UTF8 BOM */

View file

@ -1869,9 +1869,9 @@ static int parse_races(xmlDocPtr doc)
assert(propValue != NULL); assert(propValue != NULL);
frc = rc_find((const char *)propValue); frc = rc_find((const char *)propValue);
if (frc == NULL) { if (frc == NULL) {
// log_error(("%s not registered, is familiar for %s\n", /* log_error(("%s not registered, is familiar for %s\n", */
// (const char*)propValue, rc->_name[0])); /* (const char*)propValue, rc->_name[0])); */
// assert(frc!=NULL); /* assert(frc!=NULL); */
frc = rc_add(rc_new((const char *)propValue)); frc = rc_add(rc_new((const char *)propValue));
} }
if (xml_bvalue(node, "default", false)) { if (xml_bvalue(node, "default", false)) {

View file

@ -16,6 +16,8 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/ **/
#define _GNU_SOURCE
#ifndef CONFIG_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H

View file

@ -51,7 +51,7 @@ escape_string_inplace(char * buffer, unsigned int len, unsigned int offset)
} }
d[i] = o; d[i] = o;
if (i<MAXQUOTES) { if (i<MAXQUOTES) {
// more than 32 hits! must go recursive // more than 32 hits! must go recursive
char * start = d[i]; char * start = d[i];
unsigned int nlen = len - (start-buffer) - MAXQUOTES; unsigned int nlen = len - (start-buffer) - MAXQUOTES;
escape_string_inplace(start, nlen, MAXQUOTES); escape_string_inplace(start, nlen, MAXQUOTES);
@ -121,11 +121,11 @@ INLINE_FUNCTION unsigned int jenkins_hash(unsigned int a)
INLINE_FUNCTION unsigned int wang_hash(unsigned int a) INLINE_FUNCTION unsigned int wang_hash(unsigned int a)
{ {
a = ~a + (a << 15); // a = (a << 15) - a - 1; a = ~a + (a << 15); /* a = (a << 15) - a - 1; */
a = a ^ (a >> 12); a = a ^ (a >> 12);
a = a + (a << 2); a = a + (a << 2);
a = a ^ (a >> 4); a = a ^ (a >> 4);
a = a * 2057; // a = (a + (a << 3)) + (a << 11); a = a * 2057; /* a = (a + (a << 3)) + (a << 11); */
a = a ^ (a >> 16); a = a ^ (a >> 16);
return a; return a;
} }

View file

@ -81,12 +81,12 @@ unicode_latin1_to_utf8(utf8_t * out, size_t * outlen, const char *in,
if (c > 0xBF) { if (c > 0xBF) {
if (op - out >= os - 1) if (op - out >= os - 1)
break; break;
*op++ = 0xC3; *op++ = (char) 0xC3;
*op++ = c - 64; *op++ = c - 64;
} else if (c > 0x7F) { } else if (c > 0x7F) {
if (op - out >= os - 1) if (op - out >= os - 1)
break; break;
*op++ = 0xC2; *op++ = (char) 0xC2;
*op++ = c; *op++ = c;
} else { } else {
if (op - out >= os) if (op - out >= os)

View file

@ -28,7 +28,7 @@
const xmlChar *xml_i(double number) const xmlChar *xml_i(double number)
{ {
static char buffer[128]; static char buffer[128];
snprintf(buffer, sizeof(buffer), "%.0lf", number); snprintf(buffer, sizeof(buffer), "%.0f", number);
return (const xmlChar *)buffer; return (const xmlChar *)buffer;
} }