mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-12 04:48:51 +00:00
Merge "res_config_pgsql: Avoid typecasting an int to unsigned char." into 13
This commit is contained in:
@@ -1250,7 +1250,8 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap
|
|||||||
struct columns *column;
|
struct columns *column;
|
||||||
struct tables *table;
|
struct tables *table;
|
||||||
char *elm;
|
char *elm;
|
||||||
int type, size, res = 0;
|
int type, res = 0;
|
||||||
|
unsigned int size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ignore database from the extconfig.conf since it was
|
* Ignore database from the extconfig.conf since it was
|
||||||
@@ -1266,7 +1267,7 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap
|
|||||||
|
|
||||||
while ((elm = va_arg(ap, char *))) {
|
while ((elm = va_arg(ap, char *))) {
|
||||||
type = va_arg(ap, require_type);
|
type = va_arg(ap, require_type);
|
||||||
size = va_arg(ap, int);
|
size = va_arg(ap, unsigned int);
|
||||||
AST_LIST_TRAVERSE(&table->columns, column, list) {
|
AST_LIST_TRAVERSE(&table->columns, column, list) {
|
||||||
if (strcmp(column->name, elm) == 0) {
|
if (strcmp(column->name, elm) == 0) {
|
||||||
/* Char can hold anything, as long as it is large enough */
|
/* Char can hold anything, as long as it is large enough */
|
||||||
@@ -1323,14 +1324,14 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap
|
|||||||
res = -1;
|
res = -1;
|
||||||
} else {
|
} else {
|
||||||
struct ast_str *sql = ast_str_create(100);
|
struct ast_str *sql = ast_str_create(100);
|
||||||
char fieldtype[15];
|
char fieldtype[10];
|
||||||
PGresult *result;
|
PGresult *result;
|
||||||
|
|
||||||
if (requirements == RQ_CREATECHAR || type == RQ_CHAR) {
|
if (requirements == RQ_CREATECHAR || type == RQ_CHAR) {
|
||||||
/* Size is minimum length; make it at least 50% greater,
|
/* Size is minimum length; make it at least 50% greater,
|
||||||
* just to be sure, because PostgreSQL doesn't support
|
* just to be sure, because PostgreSQL doesn't support
|
||||||
* resizing columns. */
|
* resizing columns. */
|
||||||
snprintf(fieldtype, sizeof(fieldtype), "CHAR(%hhu)",
|
snprintf(fieldtype, sizeof(fieldtype), "CHAR(%u)",
|
||||||
size < 15 ? size * 2 :
|
size < 15 ? size * 2 :
|
||||||
(size * 3 / 2 > 255) ? 255 : size * 3 / 2);
|
(size * 3 / 2 > 255) ? 255 : size * 3 / 2);
|
||||||
} else if (type == RQ_INTEGER1 || type == RQ_UINTEGER1 || type == RQ_INTEGER2) {
|
} else if (type == RQ_INTEGER1 || type == RQ_UINTEGER1 || type == RQ_INTEGER2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user