* Don't do "if (ptr != NULL) { ... } if (ptr == NULL) { ... }" instead use an if-else construction: "if (ptr != NULL) { ... } else { ... }"

* Use slcatprintf instead of snprintf into a local buffer (on the stack) followed by concatenating to our target string

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3345 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-01-04 19:11:16 +00:00
parent 17faff7281
commit 34d26a6719
1 changed files with 3 additions and 6 deletions

View File

@ -88,15 +88,13 @@ do { \
#define CHECK_VALID_TAG(_tag) \
do { \
assert(tag != TAG_SEPARATOR && tag != TAG_GROUP_END); \
} while(FALSE)
} while(0)
// function to printf into errbuf the calling strack for nested groups on error
#define PRNG_LEN 40 // low value to avoid stack overflow
static void print_nested_groups(struct define *group)
{
struct define *parent;
char groupdesc[PRNG_LEN];
if (group == NULL)
{
@ -106,11 +104,10 @@ static void print_nested_groups(struct define *group)
if (parent != NULL)
{
snprintf(groupdesc, PRNG_LEN, "\nNested inside element %x", (unsigned int)parent->element);
strlcat(errbuf, groupdesc, sizeof(errbuf));
slcatprintf(errbuf, sizeof(errbuf), "\nNested inside element %x", (unsigned int)parent->element);
print_nested_groups(parent);
}
if (parent == NULL)
else
{
strlcat(errbuf, "\n", sizeof(errbuf));
}