[Asterisk-code-review] res config pgsql: Avoid typecasting an int to unsigned char. (asterisk[15])
Alexander Traud
asteriskteam at digium.com
Fri Jan 12 03:52:05 CST 2018
Alexander Traud has uploaded this change for review. ( https://gerrit.asterisk.org/7944
Change subject: res_config_pgsql: Avoid typecasting an int to unsigned char.
......................................................................
res_config_pgsql: Avoid typecasting an int to unsigned char.
clang 5.0 warned about this.
ASTERISK-27576
Change-Id: If41f400a51973c06cdb9b75462e535b616bfe385
---
M res/res_config_pgsql.c
1 file changed, 5 insertions(+), 4 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/44/7944/1
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index abd00ca..3b65921 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -1215,7 +1215,8 @@
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 @@
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 @@
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(%d)",
size < 15 ? size * 2 :
(size * 3 / 2 > 255) ? 255 : size * 3 / 2);
} else if (type == RQ_INTEGER1 || type == RQ_UINTEGER1 || type == RQ_INTEGER2) {
--
To view, visit https://gerrit.asterisk.org/7944
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: If41f400a51973c06cdb9b75462e535b616bfe385
Gerrit-Change-Number: 7944
Gerrit-PatchSet: 1
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180112/5c76deb6/attachment-0001.html>
More information about the asterisk-code-review
mailing list