forked from github/server
fix coverity scan errors
This commit is contained in:
parent
77921a94ba
commit
02248e0c54
|
@ -13,6 +13,7 @@ endif (MSVC)
|
||||||
|
|
||||||
INCLUDE (CheckSymbolExists)
|
INCLUDE (CheckSymbolExists)
|
||||||
CHECK_SYMBOL_EXISTS(strlcat string.h HAVE_STRLCAT)
|
CHECK_SYMBOL_EXISTS(strlcat string.h HAVE_STRLCAT)
|
||||||
|
CHECK_SYMBOL_EXISTS(strdup string.h HAVE_STRDUP)
|
||||||
|
|
||||||
find_package (SQLite3)
|
find_package (SQLite3)
|
||||||
find_package (BerkeleyDB)
|
find_package (BerkeleyDB)
|
||||||
|
|
|
@ -270,6 +270,10 @@ if (HAVE_STRLCAT)
|
||||||
add_definitions(-DHAVE_BSDSTRING)
|
add_definitions(-DHAVE_BSDSTRING)
|
||||||
endif(HAVE_STRLCAT)
|
endif(HAVE_STRLCAT)
|
||||||
|
|
||||||
|
if (HAVE_STRDUP)
|
||||||
|
add_definitions(-DHAVE_STRDUP)
|
||||||
|
endif(HAVE_STRDUP)
|
||||||
|
|
||||||
if (DB_FOUND)
|
if (DB_FOUND)
|
||||||
include_directories (${DB_INCLUDE_DIR})
|
include_directories (${DB_INCLUDE_DIR})
|
||||||
target_link_libraries(convert ${DB_LIBRARIES})
|
target_link_libraries(convert ${DB_LIBRARIES})
|
||||||
|
|
|
@ -190,7 +190,7 @@ static char *sidename(side * s)
|
||||||
static char sidename_buf[4][SIDENAMEBUFLEN]; /* STATIC_RESULT: used for return, not across calls */
|
static char sidename_buf[4][SIDENAMEBUFLEN]; /* STATIC_RESULT: used for return, not across calls */
|
||||||
|
|
||||||
bufno = bufno % 4;
|
bufno = bufno % 4;
|
||||||
strncpy(sidename_buf[bufno], factionname(s->stealthfaction ? s->stealthfaction : s->faction), SIDENAMEBUFLEN);
|
strlcpy(sidename_buf[bufno], factionname(s->stealthfaction ? s->stealthfaction : s->faction), SIDENAMEBUFLEN);
|
||||||
return sidename_buf[bufno++];
|
return sidename_buf[bufno++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <critbit.h>
|
#include <critbit.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -14,12 +15,15 @@ void odata_create(order_data **pdata, size_t len, const char *str)
|
||||||
order_data *data;
|
order_data *data;
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
|
assert(pdata);
|
||||||
data = malloc(sizeof(order_data) + len + 1);
|
data = malloc(sizeof(order_data) + len + 1);
|
||||||
data->_refcount = 1;
|
data->_refcount = 1;
|
||||||
result = (char *)(data + 1);
|
result = (char *)(data + 1);
|
||||||
data->_str = (len > 0) ? result : NULL;
|
data->_str = (len > 0) ? result : NULL;
|
||||||
if (str) strcpy(result, str);
|
if (str) {
|
||||||
if (pdata) *pdata = data;
|
strcpy(result, str);
|
||||||
|
}
|
||||||
|
*pdata = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void odata_release(order_data * od)
|
void odata_release(order_data * od)
|
||||||
|
|
|
@ -277,7 +277,7 @@ static void dragon_name(unit * u)
|
||||||
else {
|
else {
|
||||||
char n[32];
|
char n[32];
|
||||||
|
|
||||||
snprintf(n, sizeof(n), "%s%s%s", silbe1[rng_int() % SIL1], silbe2[rng_int() % SIL1], silbe3[rng_int() % SIL1]);
|
snprintf(n, sizeof(n), "%s%s%s", silbe1[rng_int() % SIL1], silbe2[rng_int() % SIL2], silbe3[rng_int() % SIL3]);
|
||||||
if (rng_int() % 5 > 2) {
|
if (rng_int() % 5 > 2) {
|
||||||
sprintf(name, "%s, %s", n, str); /* "Name, der Titel" */
|
sprintf(name, "%s, %s", n, str); /* "Name, der Titel" */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue