summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins2 <jenkins2@gerrit.asterisk.org>2018-01-14 09:04:19 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2018-01-14 09:04:19 -0600
commit0ab13bb403720201440e8073bb3d0b81a97315bb (patch)
treecae412d8fbfe5126f3dc99fbaddaf73bb2645811
parent516ab38df6ee2a196a54768e983f741f3bfc5fcb (diff)
parenteb9b85baec36feaeaae1abb04fade28675dcdf98 (diff)
Merge "res_config_pgsql: Avoid typecasting an int to unsigned char."
-rw-r--r--res/res_config_pgsql.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index e436e2ff8..cee4e488d 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -1215,7 +1215,8 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap
struct columns *column;
struct tables *table;
char *elm;
- int type, size, res = 0;
+ int type, res = 0;
+ unsigned int size;
/*
* Ignore database from the extconfig.conf since it was
@@ -1231,7 +1232,7 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap
while ((elm = va_arg(ap, char *))) {
type = va_arg(ap, require_type);
- size = va_arg(ap, int);
+ size = va_arg(ap, unsigned int);
AST_LIST_TRAVERSE(&table->columns, column, list) {
if (strcmp(column->name, elm) == 0) {
/* Char can hold anything, as long as it is large enough */
@@ -1288,14 +1289,14 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap
res = -1;
} else {
struct ast_str *sql = ast_str_create(100);
- char fieldtype[15];
+ char fieldtype[10];
PGresult *result;
if (requirements == RQ_CREATECHAR || type == RQ_CHAR) {
/* Size is minimum length; make it at least 50% greater,
* just to be sure, because PostgreSQL doesn't support
* resizing columns. */
- snprintf(fieldtype, sizeof(fieldtype), "CHAR(%hhu)",
+ snprintf(fieldtype, sizeof(fieldtype), "CHAR(%u)",
size < 15 ? size * 2 :
(size * 3 / 2 > 255) ? 255 : size * 3 / 2);
} else if (type == RQ_INTEGER1 || type == RQ_UINTEGER1 || type == RQ_INTEGER2) {