diff options
author | Alexander Traud <pabstraud@compuserve.com> | 2018-01-12 10:50:32 +0100 |
---|---|---|
committer | Alexander Traud <pabstraud@compuserve.com> | 2018-01-12 16:24:17 +0100 |
commit | eb9b85baec36feaeaae1abb04fade28675dcdf98 (patch) | |
tree | 9f430ebf99905de0f0128af5a1c60e272a202c75 /res | |
parent | e4ee41da4da208fc1a3bd9261e6b91569ef148a7 (diff) |
res_config_pgsql: Avoid typecasting an int to unsigned char.
clang 5.0 warned about this.
ASTERISK-27576
Change-Id: If41f400a51973c06cdb9b75462e535b616bfe385
Diffstat (limited to 'res')
-rw-r--r-- | res/res_config_pgsql.c | 9 |
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) { |