[asterisk-commits] res config pgsql: Avoid typecasting an int to unsigned char. (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jan 14 08:58:37 CST 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/7943 )

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(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 0244001..b4f5aa2 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -1250,7 +1250,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
@@ -1266,7 +1267,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 */
@@ -1323,14 +1324,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(%u)",
 						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/7943
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: If41f400a51973c06cdb9b75462e535b616bfe385
Gerrit-Change-Number: 7943
Gerrit-PatchSet: 2
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20180114/1d51225f/attachment.html>


More information about the asterisk-commits mailing list