From 14d62afb0decbbf48b23e587c7c1be9d5ec292cb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 16 May 2012 15:52:37 -0700 Subject: [PATCH] rename _log_warn to log_warning and get rid of the cumbersome #define --- src/bindings/helpers.c | 3 +-- src/gamecode/give.c | 3 +-- src/gamecode/laws.c | 8 +++----- src/kernel/command.c | 2 +- src/kernel/config.c | 5 ++--- src/kernel/connection.c | 2 +- src/kernel/item.c | 2 +- src/kernel/magic.c | 6 ++---- src/kernel/message.c | 4 ++-- src/kernel/pool.c | 2 +- src/kernel/reports.c | 5 ++--- src/kernel/save.c | 23 ++++++++++------------- src/kernel/spell.c | 4 ++-- src/kernel/terrain.c | 2 +- src/kernel/textstore.c | 4 ++-- src/kernel/unit.c | 2 +- src/kernel/xmlreader.c | 6 ++---- src/triggers/timeout.c | 5 ++--- src/util/attrib.c | 4 ++-- src/util/bsdstring.h | 2 +- src/util/filereader.c | 2 +- src/util/language.c | 3 +-- src/util/log.c | 2 +- src/util/log.h | 3 +-- src/util/nrmessage.c | 6 ++---- src/util/parser.c | 8 +++----- src/util/xml.c | 4 ++-- 27 files changed, 51 insertions(+), 71 deletions(-) diff --git a/src/bindings/helpers.c b/src/bindings/helpers.c index c17ffeb55..bc99cc108 100644 --- a/src/bindings/helpers.c +++ b/src/bindings/helpers.c @@ -271,8 +271,7 @@ static void lua_initfamiliar(unit * u) lua_pop(L, 1); } } else { - log_warning(("familiar(%s) calling '%s': not a function.\n", - unitname(u), fname)); + log_warning("familiar(%s) calling '%s': not a function.\n", unitname(u), fname); lua_pop(L, 1); } diff --git a/src/gamecode/give.c b/src/gamecode/give.c index 25e735812..bee31ab33 100644 --- a/src/gamecode/give.c +++ b/src/gamecode/give.c @@ -214,8 +214,7 @@ void give_men(int n, unit * u, unit * u2, struct order *ord) /* werewolves can't be given to non-werewolves and vice-versa */ error = 312; } else if (u2 && u2->number != 0 && u2->race != u->race) { - log_warning(("faction %s attempts to give %s to %s.\n", - itoa36(u->faction->no), u->race->_name[0], u2->race->_name[1])); + log_warning("faction %s attempts to give %s to %s.\n", itoa36(u->faction->no), u->race->_name[0], u2->race->_name[1]); error = 139; } else if (u2 != NULL && (get_racename(u2->attribs) || get_racename(u->attribs))) { diff --git a/src/gamecode/laws.c b/src/gamecode/laws.c index efab59d62..48998f647 100644 --- a/src/gamecode/laws.c +++ b/src/gamecode/laws.c @@ -1099,8 +1099,7 @@ static int restart_cmd(unit * u, struct order *ord) if (!checkpasswd(u->faction, (const char *)s_pass, false)) { cmistake(u, ord, 86, MSG_EVENT); - log_warning(("RESTART with wrong password, faction %s, pass %s\n", - factionid(u->faction), s_pass)); + log_warning("RESTART with wrong password, faction %s, pass %s\n", factionid(u->faction), s_pass); return 0; } restart_race(u, frace); @@ -1156,8 +1155,7 @@ static int quit_cmd(unit * u, struct order *ord) char buffer[64]; write_order(ord, buffer, sizeof(buffer)); cmistake(u, ord, 86, MSG_EVENT); - log_warning(("QUIT with illegal password for faction %s: %s\n", - factionid(f), buffer)); + log_warning("QUIT with illegal password for faction %s: %s\n", factionid(f), buffer); } return 0; } @@ -4382,7 +4380,7 @@ void update_subscriptions(void) strcat(strcpy(zText, basepath()), "/subscriptions"); F = fopen(zText, "r"); if (F == NULL) { - log_warning((0, "could not open %s.\n", zText)); + log_warning(0, "could not open %s.\n", zText); return; } for (;;) { diff --git a/src/kernel/command.c b/src/kernel/command.c index ca3e2f294..68d1fb75d 100644 --- a/src/kernel/command.c +++ b/src/kernel/command.c @@ -95,7 +95,7 @@ void do_command(const void *keys, struct unit *u, struct order *ord) skip_token(); if (do_command_i(keys, u, ord) != E_TOK_SUCCESS) { char *cmd = getcommand(ord); - log_warning(("%s failed command '%s'\n", unitname(u), cmd)); + log_warning("%s failed command '%s'\n", unitname(u), cmd); free(cmd); } } diff --git a/src/kernel/config.c b/src/kernel/config.c index d2b5d4541..f6f2d6352 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -746,7 +746,7 @@ void verify_data(void) lf = f->no; log_printf(stdout, "Partei %s:\n", factionid(f)); } - log_warning(("Einheit %s hat %d Personen\n", unitid(u), u->number)); + log_warning("Einheit %s hat %d Personen\n", unitid(u), u->number); } } if (f->no != 0 && ((mage > 3 && f->race != new_race[RC_ELF]) || mage > 4)) @@ -1143,8 +1143,7 @@ const char *strcheck(const char *s, size_t maxlen) static char buffer[16 * 1024]; if (strlen(s) > maxlen) { assert(maxlen < 16 * 1024); - log_warning(("[strcheck] String wurde auf %d Zeichen verkürzt:\n%s\n", - (int)maxlen, s)); + log_warning("[strcheck] String wurde auf %d Zeichen verkürzt:\n%s\n", (int)maxlen, s); strlcpy(buffer, s, maxlen); return buffer; } diff --git a/src/kernel/connection.c b/src/kernel/connection.c index 69606884d..ba49f1b54 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -677,7 +677,7 @@ int read_borders(struct storage *store) return result; } if (!type->name || !to || !from) { - log_warning(("erase invalid border '%s' between '%s' and '%s'\n", type->__name, regionname(from, 0), regionname(to, 0))); + log_warning("erase invalid border '%s' between '%s' and '%s'\n", type->__name, regionname(from, 0), regionname(to, 0)); erase_border(b); } } diff --git a/src/kernel/item.c b/src/kernel/item.c index f123d8e98..75eb19dea 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -355,7 +355,7 @@ resource_type *rt_find(const char *name) break; } if (!rtype) { - log_warning(("rt_find: unknown resource '%s'\n", name)); + log_warning("rt_find: unknown resource '%s'\n", name); } return rtype; } diff --git a/src/kernel/magic.c b/src/kernel/magic.c index 5da9bc57f..da4ff2bb0 100644 --- a/src/kernel/magic.c +++ b/src/kernel/magic.c @@ -944,8 +944,7 @@ boolean knowsspell(const region * r, const unit * u, const spell * sp) /* Magier? */ mage = get_mage(u); if (!mage) { - log_warning(("%s ist kein Magier, versucht aber zu zaubern.\n", - unitname(u))); + log_warning("%s ist kein Magier, versucht aber zu zaubern.\n", unitname(u)); return false; } /* steht der Spruch in der Spruchliste? */ @@ -955,8 +954,7 @@ boolean knowsspell(const region * r, const unit * u, const spell * sp) return false; } if (eff_skill(u, SK_MAGIC, u->region) >= sp->level) { - log_warning(("%s ist hat die erforderliche Stufe, kennt aber %s nicht.\n", - unitname(u), spell_name(sp, default_locale))); + log_warning("%s ist hat die erforderliche Stufe, kennt aber %s nicht.\n", unitname(u), spell_name(sp, default_locale)); } return false; } diff --git a/src/kernel/message.c b/src/kernel/message.c index c7ca71b06..c83479b28 100644 --- a/src/kernel/message.c +++ b/src/kernel/message.c @@ -149,7 +149,7 @@ message *msg_message(const char *name, const char *sig, ...) memset(args, 0, sizeof(args)); if (!mtype) { - log_warning(("trying to create message of unknown type \"%s\"\n", name)); + log_warning("trying to create message of unknown type \"%s\"\n", name); if (strcmp(name, "missing_message") != 0) { return msg_message("missing_message", "name", name); } @@ -200,7 +200,7 @@ caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level) #define LOG_ENGLISH #ifdef LOG_ENGLISH if (f && f->locale != default_locale) { - log_warning(("message for locale \"%s\": %s\n", locale_name(f->locale), s)); + log_warning("message for locale \"%s\": %s\n", locale_name(f->locale), s); } #endif unused(level); diff --git a/src/kernel/pool.c b/src/kernel/pool.c index 4d280d4ef..f5150851a 100644 --- a/src/kernel/pool.c +++ b/src/kernel/pool.c @@ -81,7 +81,7 @@ int change_resource(unit * u, const resource_type * rtype, int change) assert(!"undefined resource detected. rtype->uchange not initialized."); assert(i >= 0); if (i >= 100000000) { - log_warning(("%s has %d %s\n", unitname(u), i, rtype->_name[0])); + log_warning("%s has %d %s\n", unitname(u), i, rtype->_name[0]); } return i; } diff --git a/src/kernel/reports.c b/src/kernel/reports.c index 5bb42ccb4..3fef6cb51 100644 --- a/src/kernel/reports.c +++ b/src/kernel/reports.c @@ -837,8 +837,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf, } } if (size <= 1) { - log_warning(("bufunit ran out of space after writing %u bytes.\n", - (bufp - buf))); + log_warning("bufunit ran out of space after writing %u bytes.\n", (bufp - buf)); } return dh; } @@ -1548,7 +1547,7 @@ int write_reports(faction * f, time_t ltime) } } while (errno); if (!gotit) { - log_warning(("No report for faction %s!\n", factionid(f))); + log_warning("No report for faction %s!\n", factionid(f)); } ql_free(ctx.addresses); seen_done(ctx.seen); diff --git a/src/kernel/save.c b/src/kernel/save.c index a05445ab1..c7132c5df 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -347,7 +347,7 @@ static faction *factionorders(void) const char *pass = getstrtoken(); if (!checkpasswd(f, (const char *)pass, true)) { - log_warning(("Invalid password for faction %s\n", itoa36(fid))); + log_warning("Invalid password for faction %s\n", itoa36(fid)); ADDMSG(&f->msgs, msg_message("wrongpasswd", "faction password", f->no, pass)); return 0; @@ -360,7 +360,7 @@ static faction *factionorders(void) f->lastorders = global.data_turn + 1; } else { - log_warning(("orders for invalid faction %s\n", itoa36(fid))); + log_warning("orders for invalid faction %s\n", itoa36(fid)); } return f; } @@ -806,7 +806,7 @@ unit *read_unit(struct storage *store) if ((u->flags & UFL_ANON_FACTION) && !rule_stealth_faction()) { /* if this rule is broken, then fix broken units */ u->flags -= UFL_ANON_FACTION; - log_warning(("%s was anonymous.\n", unitname(u))); + log_warning("%s was anonymous.\n", unitname(u)); } /* Persistente Befehle einlesen */ free_orders(&u->orders); @@ -823,11 +823,10 @@ unit *read_unit(struct storage *store) orderp = &ord->next; ord = NULL; } else if (p == MAXPERSISTENT) { - log_warning(("%s had %d or more persistent orders\n", unitname(u), - MAXPERSISTENT)); + log_warning("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT); } } else if (n == MAXORDERS) { - log_warning(("%s had %d or more orders\n", unitname(u), MAXORDERS)); + log_warning("%s had %d or more orders\n", unitname(u), MAXORDERS); } if (ord != NULL) free_order(ord); @@ -1238,8 +1237,7 @@ faction *readfaction(struct storage * store) store->r_str_buf(store, email, sizeof(email)); if (set_email(&f->email, email) != 0) { - log_warning(("Invalid email address for faction %s: %s\n", itoa36(f->no), - email)); + log_warning("Invalid email address for faction %s: %s\n", itoa36(f->no), email); set_email(&f->email, ""); } @@ -1412,7 +1410,7 @@ static void repair_unit(unit * u) { } if (!found) { u->race = u->faction->race; - log_warning(("This toad did not have a changerace trigger: %s\n", unitname(u))); + log_warning("This toad did not have a changerace trigger: %s\n", unitname(u)); } } } @@ -1454,8 +1452,7 @@ int readgame(const char *filename, int mode, int backup) char buffer[64]; snprintf(buffer, sizeof(buffer), "%s.xml", game_name); if (strcmp(basefile, buffer) != 0) { - log_warning(("game mismatch: datafile contains %s, game is %s\n", - basefile, game_name)); + log_warning("game mismatch: datafile contains %s, game is %s\n", basefile, game_name); printf("WARNING: any key to continue, Ctrl-C to stop\n"); getchar(); } @@ -1480,7 +1477,7 @@ int readgame(const char *filename, int mode, int backup) if (pl == NULL) { pl = calloc(1, sizeof(plane)); } else { - log_warning(("the plane with id=%d already exists.\n", id)); + log_warning("the plane with id=%d already exists.\n", id); } pl->id = id; pl->name = store->r_str(store); @@ -1692,7 +1689,7 @@ int readgame(const char *filename, int mode, int backup) int no = 666; while (findfaction(no)) ++no; - log_warning(("renum(monsters, %d)\n", no)); + log_warning("renum(monsters, %d)\n", no); renumber_faction(f, no); } } else { diff --git a/src/kernel/spell.c b/src/kernel/spell.c index 7602c4874..ea3e41cef 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -63,7 +63,7 @@ spell *find_spell(const char *name) return sp; } } - log_warning(("find_spell: could not find spell '%s'\n", name)); + log_warning("find_spell: could not find spell '%s'\n", name); return 0; } @@ -121,6 +121,6 @@ spell *find_spellbyid(unsigned int id) } } - log_warning(("cannot find spell by id: %u\n", id)); + log_warning("cannot find spell by id: %u\n", id); return NULL; } diff --git a/src/kernel/terrain.c b/src/kernel/terrain.c index 6090f771c..14c776e14 100644 --- a/src/kernel/terrain.c +++ b/src/kernel/terrain.c @@ -127,7 +127,7 @@ terrain_t oldterrain(const struct terrain_type * terrain) if (newterrains[t] == terrain) return t; } - log_warning(("%s is not a classic terrain.\n", terrain->_name)); + log_warning("%s is not a classic terrain.\n", terrain->_name); return NOTERRAIN; } diff --git a/src/kernel/textstore.c b/src/kernel/textstore.c index 4c812158b..0bbbd48c7 100644 --- a/src/kernel/textstore.c +++ b/src/kernel/textstore.c @@ -142,14 +142,14 @@ static int txt_open(struct storage *store, const char *filename, int mode) store->r_tok_buf(store, token, sizeof(token)); if (memcmp(token, utf8_bom, 3) == 0) { if (enc_gamedata != XML_CHAR_ENCODING_UTF8) { - log_warning(("Found UTF-8 BOM, assuming unicode game data.\n")); + log_warning("Found UTF-8 BOM, assuming unicode game data.\n"); store->encoding = XML_CHAR_ENCODING_UTF8; } store->version = atoi(token + 3); } else { if (store->encoding == XML_CHAR_ENCODING_NONE) { store->encoding = XML_CHAR_ENCODING_8859_1; - log_warning(("No BOM, assuming 8859-1 game data.\n")); + log_warning("No BOM, assuming 8859-1 game data.\n"); } store->version = atoi(token); } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 2739aff0b..7344c4589 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1562,7 +1562,7 @@ int countheroes(const struct faction *f) #ifdef DEBUG_MAXHEROES int m = maxheroes(f); if (n > m) { - log_warning(("%s has %d of %d heroes\n", factionname(f), n, m)); + log_warning("%s has %d of %d heroes\n", factionname(f), n, m); } #endif return n; diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index d2b822882..40f32fe12 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -604,8 +604,7 @@ static int parse_ships(xmlDocPtr doc) if (st->coasts[c] != NULL) ++c; else { - log_warning(("ship %s mentions a non-existing terrain %s.\n", - st->name[0], propValue)); + log_warning("ship %s mentions a non-existing terrain %s.\n", st->name[0], propValue); } xmlFree(propValue); } @@ -2210,8 +2209,7 @@ xml_readstrings(xmlXPathContextPtr xpath, xmlNodePtr * nodeTab, int nodeNr, } xmlFree(propText); } else { - log_warning(("string %s has no text in locale %s\n", - zName, locale_name(lang))); + log_warning("string %s has no text in locale %s\n", zName, locale_name(lang)); } } xmlXPathFreeObject(result); diff --git a/src/triggers/timeout.c b/src/triggers/timeout.c index 44226099d..65a1dc10f 100644 --- a/src/triggers/timeout.c +++ b/src/triggers/timeout.c @@ -78,10 +78,9 @@ static int timeout_read(trigger * t, struct storage *store) read_triggers(store, &td->triggers); if (td->timer > 20) { trigger *tr = td->triggers; - log_warning(("there is a timeout lasting for another %d turns\n", - td->timer)); + log_warning("there is a timeout lasting for another %d turns\n", td->timer); while (tr) { - log_warning((" timeout triggers: %s\n", tr->type->name)); + log_warning(" timeout triggers: %s\n", tr->type->name); tr = tr->next; } } diff --git a/src/util/attrib.c b/src/util/attrib.c index c5854348b..147b006b5 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -45,14 +45,14 @@ void at_register(attrib_type * at) attrib_type *find; if (at->read == NULL) { - log_warning(("registering non-persistent attribute %s.\n", at->name)); + log_warning("registering non-persistent attribute %s.\n", at->name); } at->hashkey = __at_hashkey(at->name); find = at_hash[at->hashkey % MAXATHASH]; while (find && at->hashkey != find->hashkey) find = find->nexthash; if (find && find == at) { - log_warning(("attribute '%s' was registered more than once\n", at->name)); + log_warning("attribute '%s' was registered more than once\n", at->name); return; } else { assert(!find || !"hashkey is already in use"); diff --git a/src/util/bsdstring.h b/src/util/bsdstring.h index 0ed276b61..dc9e2919b 100644 --- a/src/util/bsdstring.h +++ b/src/util/bsdstring.h @@ -9,7 +9,7 @@ extern size_t strlcat(char *dst, const char *src, size_t siz); extern int wrptr(char **ptr, size_t * size, int bytes); #endif -#define WARN_STATIC_BUFFER() log_warning(("static buffer too small in %s:%d\n", __FILE__, __LINE__)) +#define WARN_STATIC_BUFFER() log_warning("static buffer too small in %s:%d\n", __FILE__, __LINE__) #if !defined(HAVE_STRLPRINTF) # define HAVE_STRLPRINTF diff --git a/src/util/filereader.c b/src/util/filereader.c index a70457b70..81ce78110 100644 --- a/src/util/filereader.c +++ b/src/util/filereader.c @@ -17,7 +17,7 @@ static char fbuf[MAXLINE]; static void unicode_warning(const char *bp) { - log_warning(("invalid sequence in UTF-8 string: %s\n", bp)); + log_warning("invalid sequence in UTF-8 string: %s\n", bp); } INLINE_FUNCTION int eatwhite(const char *ptr, size_t * total_size) diff --git a/src/util/language.c b/src/util/language.c index 0616bdba8..a763ffe04 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -148,8 +148,7 @@ const char *locale_string(const locale * lang, const char *key) find = find->nexthash; } if (!find) { - log_warning(("missing translation for \"%s\" in locale %s\n", key, - lang->name)); + log_warning("missing translation for \"%s\" in locale %s\n", key, lang->name); if (lang != default_locale) { return locale_string(default_locale, key); } diff --git a/src/util/log.c b/src/util/log.c index 75571ee77..e09946c3c 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -196,7 +196,7 @@ void _log_debug(const char *format, ...) } } -void _log_warn(const char *format, ...) +void log_warning(const char *format, ...) { const char * prefix = "WARNING"; const int mask = LOG_CPWARNING; diff --git a/src/util/log.h b/src/util/log.h index 301469e06..88607a343 100644 --- a/src/util/log.h +++ b/src/util/log.h @@ -19,12 +19,11 @@ extern "C" { extern void log_close(void); extern void log_flush(void); -#define log_warning(x) _log_warn x #define log_error(x) _log_error x #define log_debug _log_debug /* use macros above instead of these: */ - extern void _log_warn(const char *format, ...); + extern void log_warning(const char *format, ...); extern void _log_error(const char *format, ...); extern void _log_debug(const char *format, ...); extern void log_info(const char *format, ...); diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c index adb047df1..20b918ff4 100644 --- a/src/util/nrmessage.c +++ b/src/util/nrmessage.c @@ -56,12 +56,10 @@ nrmessage_type *nrt_find(const struct locale * lang, type = type->next; } if (!found) { - log_warning(("could not find nr-type %s for locale %s\n", - mtype->name, locale_name(lang))); + log_warning("could not find nr-type %s for locale %s\n", mtype->name, locale_name(lang)); } if (lang && found && found->lang != lang) { - log_warning(("could not find nr-type %s for locale %s, using %s\n", - mtype->name, locale_name(lang), locale_name(found->lang))); + log_warning("could not find nr-type %s for locale %s, using %s\n", mtype->name, locale_name(lang), locale_name(found->lang)); } return found; } diff --git a/src/util/parser.c b/src/util/parser.c index d6ae46c47..46d6ba8a8 100644 --- a/src/util/parser.c +++ b/src/util/parser.c @@ -36,7 +36,7 @@ static int eatwhitespace_c(const char **str_p) } else { ret = unicode_utf8_to_ucs4(&ucs, str, &len); if (ret != 0) { - log_warning(("illegal character sequence in UTF8 string: %s\n", str)); + log_warning("illegal character sequence in UTF8 string: %s\n", str); break; } if (!iswxspace((wint_t) ucs)) @@ -100,8 +100,7 @@ void skip_token(void) if (ret == 0) { state->current_token += len; } else { - log_warning(("illegal character sequence in UTF8 string: %s\n", - state->current_token)); + log_warning("illegal character sequence in UTF8 string: %s\n", state->current_token); } } if (iswxspace((wint_t) ucs) && quotechar == 0) { @@ -145,8 +144,7 @@ const char *parse_token(const char **str) } else { int ret = unicode_utf8_to_ucs4(&ucs, ctoken, &len); if (ret != 0) { - log_warning(("illegal character sequence in UTF8 string: %s\n", - ctoken)); + log_warning("illegal character sequence in UTF8 string: %s\n", ctoken); break; } } diff --git a/src/util/xml.c b/src/util/xml.c index cd1878206..bb6a9a302 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -57,10 +57,10 @@ boolean xml_bvalue(xmlNodePtr node, const char *name, boolean dflt) else if (strcmp((const char *)propValue, "true") == 0) result = true; else if (strcmp((const char *)propValue, "1") == 0) { - log_warning(("boolean value is '1': %s::%s\n", node->name, name)); + log_warning("boolean value is '1': %s::%s\n", node->name, name); result = true; } else if (strcmp((const char *)propValue, "0") == 0) { - log_warning(("boolean value is '0': %s::%s\n", node->name, name)); + log_warning("boolean value is '0': %s::%s\n", node->name, name); result = false; } xmlFree(propValue);