[prev in list] [next in list] [prev in thread] [next in thread]
List: asterisk-commits
Subject: [asterisk-commits] =?utf-8?q?res_config_pgsql=3A_Avoid_typecastin?= =?utf-8?q?g_an_int_to_unsigned_c
From: SVN commits to the Asterisk project <asterisk-commits () lists ! digium ! com>
Date: 2018-01-14 15:04:19
Message-ID: mailman.7361.1515942304.1215.asterisk-commits () lists ! digium ! com
[Download RAW message or body]
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/7942 )
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 e436e2f..cee4e48 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(%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/7942
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If41f400a51973c06cdb9b75462e535b616bfe385
Gerrit-Change-Number: 7942
Gerrit-PatchSet: 2
Gerrit-Owner: Alexander Traud <pabstraud@compuserve.com>
Gerrit-Reviewer: Alexander Traud <pabstraud@compuserve.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com>
[Attachment #3 (text/html)]
<p>Jenkins2 <strong>merged</strong> this change.</p><p><a \
href="https://gerrit.asterisk.org/7942">View Change</a></p><div \
style="white-space:pre-wrap">Approvals: Kevin Harwell: Looks good to me, but someone \
else must approve Richard Mudgett: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: \
pre-wrap;">res_config_pgsql: Avoid typecasting an int to unsigned char.<br><br>clang \
5.0 warned about this.<br><br>ASTERISK-27576<br><br>Change-Id: \
If41f400a51973c06cdb9b75462e535b616bfe385<br>---<br>M res/res_config_pgsql.c<br>1 \
file changed, 5 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: \
monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_config_pgsql.c \
b/res/res_config_pgsql.c<br>index e436e2f..cee4e48 100644<br>--- \
a/res/res_config_pgsql.c<br>+++ b/res/res_config_pgsql.c<br>@@ -1215,7 +1215,8 @@<br> \
struct columns *column;<br> struct tables *table;<br> char *elm;<br>- int type, \
size, res = 0;<br>+ int type, res = 0;<br>+ unsigned int size;<br> <br> /*<br> * \
Ignore database from the extconfig.conf since it was<br>@@ -1231,7 +1232,7 @@<br> \
<br> while ((elm = va_arg(ap, char *))) {<br> type = va_arg(ap, \
require_type);<br>- size = va_arg(ap, int);<br>+ size = va_arg(ap, unsigned \
int);<br> AST_LIST_TRAVERSE(&table->columns, column, list) {<br> if \
(strcmp(column->name, elm) == 0) {<br> /* Char can hold anything, as long as \
it is large enough */<br>@@ -1288,14 +1289,14 @@<br> res = -1;<br> } else \
{<br> struct ast_str *sql = ast_str_create(100);<br>- char \
fieldtype[15];<br>+ char fieldtype[10];<br> PGresult *result;<br> <br> if \
(requirements == RQ_CREATECHAR || type == RQ_CHAR) {<br> /* Size is minimum \
length; make it at least 50% greater,<br> * just to be sure, because PostgreSQL \
doesn't support<br> * resizing columns. */<br>- snprintf(fieldtype, \
sizeof(fieldtype), "CHAR(%hhu)",<br>+ snprintf(fieldtype, \
sizeof(fieldtype), "CHAR(%u)",<br> size < 15 ? size * 2 :<br> \
(size * 3 / 2 > 255) ? 255 : size * 3 / 2);<br> } else if (type == RQ_INTEGER1 \
|| type == RQ_UINTEGER1 || type == RQ_INTEGER2) {<br></pre><p>To view, visit <a \
href="https://gerrit.asterisk.org/7942">change 7942</a>. To unsubscribe, visit <a \
href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope \
itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" \
itemtype="http://schema.org/ViewAction"><link itemprop="url" \
href="https://gerrit.asterisk.org/7942"/><meta itemprop="name" content="View \
Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: \
If41f400a51973c06cdb9b75462e535b616bfe385 </div> <div style="display:none"> \
Gerrit-Change-Number: 7942 </div> <div style="display:none"> Gerrit-PatchSet: 2 \
</div> <div style="display:none"> Gerrit-Owner: Alexander Traud \
<pabstraud@compuserve.com> </div> <div style="display:none"> Gerrit-Reviewer: \
Alexander Traud <pabstraud@compuserve.com> </div> <div style="display:none"> \
Gerrit-Reviewer: Jenkins2 </div> <div style="display:none"> Gerrit-Reviewer: Kevin \
Harwell <kharwell@digium.com> </div> <div style="display:none"> \
Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-commits mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-commits
--===============6611836506956393370==--
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic