Skip to content

Commit

Permalink
Use return value of snprintf instead of calling strlen unnecessarily (#…
Browse files Browse the repository at this point in the history
…420)

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
  • Loading branch information
alexhenrie authored Apr 18, 2020
1 parent fbe929d commit ca363be
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/cxoConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ static PyObject *cxoConnection_getVersion(cxoConnection *conn, void *unused)
{
dpiVersionInfo versionInfo;
char buffer[25];
int status;
int status, len;

if (cxoConnection_isConnected(conn) < 0)
return NULL;
Expand All @@ -1059,10 +1059,11 @@ static PyObject *cxoConnection_getVersion(cxoConnection *conn, void *unused)
Py_END_ALLOW_THREADS
if (status < 0)
return cxoError_raiseAndReturnNull();
snprintf(buffer, sizeof(buffer), "%d.%d.%d.%d.%d", versionInfo.versionNum,
versionInfo.releaseNum, versionInfo.updateNum,
versionInfo.portReleaseNum, versionInfo.portUpdateNum);
return PyUnicode_DecodeASCII(buffer, strlen(buffer), NULL);
len = snprintf(buffer, sizeof(buffer), "%d.%d.%d.%d.%d",
versionInfo.versionNum, versionInfo.releaseNum,
versionInfo.updateNum, versionInfo.portReleaseNum,
versionInfo.portUpdateNum);
return PyUnicode_DecodeASCII(buffer, len, NULL);
}


Expand Down

0 comments on commit ca363be

Please sign in to comment.