Skip to content

Commit 9cb4fe0

Browse files
committed
Eliminate pedantic warnings raised by static analysis
1 parent 1d298a8 commit 9cb4fe0

12 files changed

+65
-50
lines changed

src/njsAqDeqOptions.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ static napi_value njsAqDeqOptions_setMsgId(napi_env env,
348348
njsUtils_genericThrowError(env);
349349
return NULL;
350350
}
351-
if (dpiDeqOptions_setMsgId(options->handle, buffer, bufferLength) < 0)
351+
if (dpiDeqOptions_setMsgId(options->handle, buffer,
352+
(uint32_t) bufferLength) < 0)
352353
njsUtils_throwErrorDPI(env, options->oracleDb);
353354
return NULL;
354355
}
@@ -387,7 +388,7 @@ static napi_value njsAqDeqOptions_setTextAttribute(napi_env env,
387388
if (!njsUtils_setPropString(env, value, attributeName, &buffer,
388389
&bufferLength))
389390
return NULL;
390-
status = (*setter)(options->handle, buffer, bufferLength);
391+
status = (*setter)(options->handle, buffer, (uint32_t) bufferLength);
391392
free(buffer);
392393
if (status < 0)
393394
njsUtils_throwErrorDPI(env, options->oracleDb);

src/njsAqEnqOptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static napi_value njsAqEnqOptions_setTransformation(napi_env env,
175175
&valueLength))
176176
return NULL;
177177
status = dpiEnqOptions_setTransformation(options->handle, value,
178-
valueLength);
178+
(uint32_t) valueLength);
179179
free(value);
180180
if (status < 0)
181181
njsUtils_throwErrorDPI(env, options->oracleDb);

src/njsAqQueue.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ static bool njsAqQueue_createMessage(njsBaton *baton, njsAqQueue *queue,
171171
if (!njsUtils_copyStringFromJS(env, payloadObj, &buffer,
172172
&bufferLength))
173173
return false;
174-
status = dpiMsgProps_setPayloadBytes(tempHandle, buffer, bufferLength);
174+
status = dpiMsgProps_setPayloadBytes(tempHandle, buffer,
175+
(uint32_t) bufferLength);
175176
free(buffer);
176177
} else if (isDbObject) {
177178
if (!njsDbObject_getInstance(baton->oracleDb, env, payloadObj, &obj))
@@ -180,7 +181,8 @@ static bool njsAqQueue_createMessage(njsBaton *baton, njsAqQueue *queue,
180181
} else {
181182
NJS_CHECK_NAPI(env, napi_get_buffer_info(env, payloadObj,
182183
(void**) &buffer, &bufferLength))
183-
status = dpiMsgProps_setPayloadBytes(tempHandle, buffer, bufferLength);
184+
status = dpiMsgProps_setPayloadBytes(tempHandle, buffer,
185+
(uint32_t) bufferLength);
184186
}
185187
if (status < 0)
186188
return njsBaton_setErrorDPI(baton);
@@ -195,7 +197,8 @@ static bool njsAqQueue_createMessage(njsBaton *baton, njsAqQueue *queue,
195197
&buffer, &bufferLength, &found))
196198
return false;
197199
if (found) {
198-
status = dpiMsgProps_setCorrelation(tempHandle, buffer, bufferLength);
200+
status = dpiMsgProps_setCorrelation(tempHandle, buffer,
201+
(uint32_t) bufferLength);
199202
free(buffer);
200203
if (status < 0)
201204
return njsBaton_setErrorDPI(baton);
@@ -214,7 +217,8 @@ static bool njsAqQueue_createMessage(njsBaton *baton, njsAqQueue *queue,
214217
&buffer, &bufferLength, &found))
215218
return false;
216219
if (found) {
217-
status = dpiMsgProps_setExceptionQ(tempHandle, buffer, bufferLength);
220+
status = dpiMsgProps_setExceptionQ(tempHandle, buffer,
221+
(uint32_t) bufferLength);
218222
free(buffer);
219223
if (status < 0)
220224
return njsBaton_setErrorDPI(baton);

src/njsBaton.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ bool njsBaton_getSodaDocument(njsBaton *baton, njsSodaDatabase *db,
710710
NJS_CHECK_NAPI(env, napi_get_buffer_info(env, obj, &content,
711711
&contentLength))
712712
if (dpiSodaDb_createDocument(db->handle, NULL, 0, content,
713-
contentLength, NULL, 0, DPI_SODA_FLAGS_DEFAULT, handle) < 0)
713+
(uint32_t) contentLength, NULL, 0, DPI_SODA_FLAGS_DEFAULT,
714+
handle) < 0)
714715
return njsBaton_setErrorDPI(baton);
715716
}
716717

src/njsConnection.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static bool njsConnection_closeAsync(njsBaton *baton)
355355
} else if (conn->retag) {
356356
mode = DPI_MODE_CONN_CLOSE_RETAG;
357357
tag = conn->tag;
358-
tagLength = conn->tagLength;
358+
tagLength = (uint32_t) conn->tagLength;
359359
}
360360

361361
if (dpiConn_close(baton->dpiConnHandle, mode, tag, tagLength) < 0) {
@@ -929,7 +929,7 @@ static void njsConnection_finalize(napi_env env, void *finalizeData,
929929
if (conn->retag) {
930930
mode = DPI_MODE_CONN_CLOSE_RETAG;
931931
tag = conn->tag;
932-
tagLength = conn->tagLength;
932+
tagLength = (uint32_t) conn->tagLength;
933933
}
934934
dpiConn_close(conn->handle, mode, tag, tagLength);
935935
dpiConn_release(conn->handle);
@@ -1252,8 +1252,8 @@ static bool njsConnection_getDbObjectClassAsync(njsBaton *baton)
12521252
{
12531253
njsConnection *conn = (njsConnection*) baton->callingInstance;
12541254

1255-
if (dpiConn_getObjectType(conn->handle, baton->name, baton->nameLength,
1256-
&baton->dpiObjectTypeHandle) < 0)
1255+
if (dpiConn_getObjectType(conn->handle, baton->name,
1256+
(uint32_t) baton->nameLength, &baton->dpiObjectTypeHandle) < 0)
12571257
return njsBaton_setErrorDPI(baton);
12581258

12591259
return true;
@@ -1505,7 +1505,8 @@ static napi_value njsConnection_getOracleServerVersionString(napi_env env,
15051505
versionInfo.versionNum, versionInfo.releaseNum,
15061506
versionInfo.updateNum, versionInfo.portReleaseNum,
15071507
versionInfo.portUpdateNum);
1508-
return njsUtils_convertToString(env, versionString, strlen(versionString));
1508+
return njsUtils_convertToString(env, versionString,
1509+
(uint32_t) strlen(versionString));
15091510
}
15101511

15111512

@@ -1543,10 +1544,11 @@ static bool njsConnection_getQueueAsync(njsBaton *baton)
15431544
njsConnection *conn = (njsConnection*) baton->callingInstance;
15441545

15451546
if (baton->typeName && dpiConn_getObjectType(conn->handle, baton->typeName,
1546-
baton->typeNameLength, &baton->dpiObjectTypeHandle) < 0)
1547+
(uint32_t) baton->typeNameLength, &baton->dpiObjectTypeHandle) < 0)
15471548
return njsBaton_setErrorDPI(baton);
1548-
if (dpiConn_newQueue(conn->handle, baton->name, baton->nameLength,
1549-
baton->dpiObjectTypeHandle, &baton->dpiQueueHandle) < 0)
1549+
if (dpiConn_newQueue(conn->handle, baton->name,
1550+
(uint32_t) baton->nameLength, baton->dpiObjectTypeHandle,
1551+
&baton->dpiQueueHandle) < 0)
15501552
return njsBaton_setErrorDPI(baton);
15511553

15521554
return true;
@@ -1857,7 +1859,8 @@ static napi_value njsConnection_getTag(napi_env env,
18571859

18581860
if (!njsUtils_validateGetter(env, info, (njsBaseInstance**) &conn))
18591861
return NULL;
1860-
return njsUtils_convertToString(env, conn->tag, conn->tagLength);
1862+
return njsUtils_convertToString(env, conn->tag,
1863+
(uint32_t) conn->tagLength);
18611864
}
18621865

18631866

@@ -1988,8 +1991,8 @@ static bool njsConnection_prepareAndBind(njsConnection *conn, njsBaton *baton)
19881991
int status;
19891992

19901993
// prepare statement
1991-
if (dpiConn_prepareStmt(conn->handle, 0, baton->sql, baton->sqlLength,
1992-
NULL, 0, &baton->dpiStmtHandle) < 0)
1994+
if (dpiConn_prepareStmt(conn->handle, 0, baton->sql,
1995+
(uint32_t) baton->sqlLength, NULL, 0, &baton->dpiStmtHandle) < 0)
19931996
return njsBaton_setErrorDPI(baton);
19941997

19951998
// determine statement information
@@ -2001,7 +2004,7 @@ static bool njsConnection_prepareAndBind(njsConnection *conn, njsBaton *baton)
20012004
var = &baton->bindVars[i];
20022005
if (var->name) {
20032006
status = dpiStmt_bindByName(baton->dpiStmtHandle, var->name,
2004-
var->nameLength, var->dpiVarHandle);
2007+
(uint32_t) var->nameLength, var->dpiVarHandle);
20052008
} else {
20062009
status = dpiStmt_bindByPos(baton->dpiStmtHandle, var->pos,
20072010
var->dpiVarHandle);
@@ -2416,7 +2419,7 @@ static bool njsConnection_scanExecuteBindUnit(njsBaton *baton,
24162419
&baton->typeNameLength))
24172420
return false;
24182421
if (dpiConn_getObjectType(conn->handle, baton->typeName,
2419-
baton->typeNameLength, &objTypeHandle) < 0)
2422+
(uint32_t) baton->typeNameLength, &objTypeHandle) < 0)
24202423
return njsBaton_setErrorDPI(baton);
24212424
if (!njsDbObject_getSubClass(baton, objTypeHandle, env, &temp,
24222425
&var->objectType)) {
@@ -2700,7 +2703,7 @@ static napi_value njsConnection_setTextAttribute(napi_env env,
27002703
return NULL;
27012704

27022705
// call the ODPI-C function to set the value
2703-
if ((*setter)(conn->handle, buffer, bufferLength) < 0) {
2706+
if ((*setter)(conn->handle, buffer, (uint32_t) bufferLength) < 0) {
27042707
njsUtils_throwErrorDPI(env, conn->oracleDb);
27052708
free(buffer);
27062709
return NULL;
@@ -2760,12 +2763,12 @@ static bool njsConnection_subscribeAsync(njsBaton *baton)
27602763
return njsBaton_setErrorDPI(baton);
27612764
params.subscrNamespace = baton->subscription->subscrNamespace;
27622765
params.name = baton->name;
2763-
params.nameLength = baton->nameLength;
2766+
params.nameLength = (uint32_t) baton->nameLength;
27642767
params.protocol = DPI_SUBSCR_PROTO_CALLBACK;
27652768
params.callback = (dpiSubscrCallback) njsSubscription_eventHandler;
27662769
params.callbackContext = baton->subscription;
27672770
params.ipAddress = baton->ipAddress;
2768-
params.ipAddressLength = baton->ipAddressLength;
2771+
params.ipAddressLength = (uint32_t) baton->ipAddressLength;
27692772
params.portNumber = baton->portNumber;
27702773
params.timeout = baton->timeout;
27712774
params.qos = baton->qos;

src/njsDbObject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ static bool njsDbObject_transformToOracle(njsDbObject *obj, napi_env env,
875875
if (!njsUtils_copyStringFromJS(env, value, strBuffer, &length))
876876
return false;
877877
*nativeTypeNum = DPI_NATIVE_TYPE_BYTES;
878-
dpiData_setBytes(data, *strBuffer, length);
878+
dpiData_setBytes(data, *strBuffer, (uint32_t) length);
879879
return true;
880880

881881
// numbers are handled as doubles in JavaScript
@@ -910,7 +910,7 @@ static bool njsDbObject_transformToOracle(njsDbObject *obj, napi_env env,
910910
if (check) {
911911
NJS_CHECK_NAPI(env, napi_get_buffer_info(env, value,
912912
&bufferData, &length))
913-
dpiData_setBytes(data, bufferData, length);
913+
dpiData_setBytes(data, bufferData, (uint32_t) length);
914914
*nativeTypeNum = DPI_NATIVE_TYPE_BYTES;
915915
return true;
916916
}

src/njsOracleDb.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ static bool njsOracleDb_createPoolAsync(njsBaton *baton)
371371
params.externalAuth = baton->externalAuth;
372372
params.homogeneous = baton->homogeneous;
373373
params.plsqlFixupCallback = baton->plsqlFixupCallback;
374-
params.plsqlFixupCallbackLength = baton->plsqlFixupCallbackLength;
374+
params.plsqlFixupCallbackLength =
375+
(uint32_t) baton->plsqlFixupCallbackLength;
375376
if (params.externalAuth)
376377
params.homogeneous = 0;
377378
params.pingInterval = baton->poolPingInterval;
@@ -384,8 +385,9 @@ static bool njsOracleDb_createPoolAsync(njsBaton *baton)
384385

385386
// create pool
386387
if (dpiPool_create(baton->oracleDb->context, baton->user,
387-
baton->userLength, baton->password, baton->passwordLength,
388-
baton->connectString, baton->connectStringLength, &commonParams,
388+
(uint32_t) baton->userLength, baton->password,
389+
(uint32_t) baton->passwordLength, baton->connectString,
390+
(uint32_t) baton->connectStringLength, &commonParams,
389391
&params, &baton->dpiPoolHandle) < 0) {
390392
return njsBaton_setErrorDPI(baton);
391393
} else if (dpiPool_setTimeout(baton->dpiPoolHandle,
@@ -725,7 +727,7 @@ static napi_value njsOracleDb_getConnectionClass(napi_env env,
725727
if (!njsUtils_validateGetter(env, info, (njsBaseInstance**) &oracleDb))
726728
return NULL;
727729
return njsUtils_convertToString(env, oracleDb->connectionClass,
728-
oracleDb->connectionClassLength);
730+
(uint32_t) oracleDb->connectionClassLength);
729731
}
730732

731733

@@ -740,7 +742,7 @@ static napi_value njsOracleDb_getEdition(napi_env env, napi_callback_info info)
740742
if (!njsUtils_validateGetter(env, info, (njsBaseInstance**) &oracleDb))
741743
return NULL;
742744
return njsUtils_convertToString(env, oracleDb->edition,
743-
oracleDb->editionLength);
745+
(uint32_t) oracleDb->editionLength);
744746
}
745747

746748

@@ -909,7 +911,8 @@ static napi_value njsOracleDb_getOracleClientVersionString(napi_env env,
909911
versionInfo.versionNum, versionInfo.releaseNum,
910912
versionInfo.updateNum, versionInfo.portReleaseNum,
911913
versionInfo.portUpdateNum);
912-
return njsUtils_convertToString(env, versionString, strlen(versionString));
914+
return njsUtils_convertToString(env, versionString,
915+
(uint32_t) strlen(versionString));
913916
}
914917

915918

src/njsPool.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ static bool njsPool_getConnectionAsync(njsBaton *baton)
243243
return njsBaton_setErrorDPI(baton);
244244
params.matchAnyTag = baton->matchAnyTag;
245245
params.connectionClass = baton->connectionClass;
246-
params.connectionClassLength = baton->connectionClassLength;
246+
params.connectionClassLength = (uint32_t) baton->connectionClassLength;
247247
params.tag = baton->tag;
248-
params.tagLength = baton->tagLength;
248+
params.tagLength = (uint32_t) baton->tagLength;
249249

250250
// Sharding
251251
params.shardingKeyColumns = baton->shardingKeyColumns;
@@ -254,8 +254,9 @@ static bool njsPool_getConnectionAsync(njsBaton *baton)
254254
params.numSuperShardingKeyColumns = baton->numSuperShardingKeyColumns;
255255

256256
// acquire connection from pool
257-
if (dpiPool_acquireConnection(pool->handle, baton->user, baton->userLength,
258-
baton->password, baton->passwordLength, &params,
257+
if (dpiPool_acquireConnection(pool->handle, baton->user,
258+
(uint32_t) baton->userLength, baton->password,
259+
(uint32_t) baton->passwordLength, &params,
259260
&baton->dpiConnHandle) < 0)
260261
return njsBaton_setErrorDPI(baton);
261262

src/njsSodaCollection.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static bool njsSodaCollection_createIndexAsync(njsBaton *baton)
163163
if (baton->oracleDb->autoCommit)
164164
flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
165165
if (dpiSodaColl_createIndex(coll->handle, baton->indexSpec,
166-
baton->indexSpecLength, flags) < 0)
166+
(uint32_t) baton->indexSpecLength, flags) < 0)
167167
return njsBaton_setErrorDPI(baton);
168168

169169
return true;
@@ -269,8 +269,8 @@ static bool njsSodaCollection_dropIndexAsync(njsBaton *baton)
269269
flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
270270
if (baton->force)
271271
flags |= DPI_SODA_FLAGS_INDEX_DROP_FORCE;
272-
if (dpiSodaColl_dropIndex(coll->handle, baton->name, baton->nameLength,
273-
flags, &isDropped) < 0)
272+
if (dpiSodaColl_dropIndex(coll->handle, baton->name,
273+
(uint32_t) baton->nameLength, flags, &isDropped) < 0)
274274
return njsBaton_setErrorDPI(baton);
275275
baton->isDropped = (bool) isDropped;
276276
return true;

src/njsSodaDatabase.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ static bool njsSodaDatabase_createCollectionAsync(njsBaton *baton)
136136
if (baton->createCollectionMode == NJS_SODA_COLL_CREATE_MODE_MAP)
137137
flags |= DPI_SODA_FLAGS_CREATE_COLL_MAP;
138138

139-
if (dpiSodaDb_createCollection(db->handle, baton->name, baton->nameLength,
140-
baton->sodaMetaData, baton->sodaMetaDataLength, flags,
139+
if (dpiSodaDb_createCollection(db->handle, baton->name,
140+
(uint32_t) baton->nameLength, baton->sodaMetaData,
141+
(uint32_t) baton->sodaMetaDataLength, flags,
141142
&baton->dpiSodaCollHandle) < 0)
142143
return njsBaton_setErrorDPI(baton);
143144

@@ -222,9 +223,9 @@ static napi_value njsSodaDatabase_createDocument(napi_env env,
222223
}
223224

224225
// create ODPI-C document
225-
dpiStatus = dpiSodaDb_createDocument(db->handle, key, keyLength,
226-
content, contentLength, mediaType, mediaTypeLength,
227-
DPI_SODA_FLAGS_DEFAULT, &docHandle);
226+
dpiStatus = dpiSodaDb_createDocument(db->handle, key, (uint32_t) keyLength,
227+
content, (uint32_t) contentLength, mediaType,
228+
(uint32_t) mediaTypeLength, DPI_SODA_FLAGS_DEFAULT, &docHandle);
228229
if (key)
229230
free(key);
230231
if (mediaType)
@@ -432,8 +433,9 @@ static bool njsSodaDatabase_openCollectionAsync(njsBaton *baton)
432433

433434
if (db->oracleDb->autoCommit)
434435
flags |= DPI_SODA_FLAGS_ATOMIC_COMMIT;
435-
if (dpiSodaDb_openCollection(db->handle, baton->name, baton->nameLength,
436-
flags, &baton->dpiSodaCollHandle) < 0)
436+
if (dpiSodaDb_openCollection(db->handle, baton->name,
437+
(uint32_t) baton->nameLength, flags,
438+
&baton->dpiSodaCollHandle) < 0)
437439
return njsBaton_setErrorDPI(baton);
438440
return true;
439441
}

0 commit comments

Comments
 (0)