Skip to content

Commit

Permalink
Fix some problems in test code detected by cppcheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielk-1977 committed Aug 5, 2015
1 parent 707473b commit f048c47
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions ext/async/sqlite3async.c
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,7 @@ void sqlite3async_run(void){
** Control/configure the asynchronous IO system.
*/
int sqlite3async_control(int op, ...){
int rc = SQLITE_OK;
va_list ap;
va_start(ap, op);
switch( op ){
Expand All @@ -1645,7 +1646,8 @@ int sqlite3async_control(int op, ...){
&& eWhen!=SQLITEASYNC_HALT_NOW
&& eWhen!=SQLITEASYNC_HALT_IDLE
){
return SQLITE_MISUSE;
rc = SQLITE_MISUSE;
break;
}
async.eHalt = eWhen;
async_mutex_enter(ASYNC_MUTEX_QUEUE);
Expand All @@ -1657,7 +1659,8 @@ int sqlite3async_control(int op, ...){
case SQLITEASYNC_DELAY: {
int iDelay = va_arg(ap, int);
if( iDelay<0 ){
return SQLITE_MISUSE;
rc = SQLITE_MISUSE;
break;
}
async.ioDelay = iDelay;
break;
Expand All @@ -1668,7 +1671,8 @@ int sqlite3async_control(int op, ...){
async_mutex_enter(ASYNC_MUTEX_QUEUE);
if( async.nFile || async.pQueueFirst ){
async_mutex_leave(ASYNC_MUTEX_QUEUE);
return SQLITE_MISUSE;
rc = SQLITE_MISUSE;
break;
}
async.bLockFiles = bLock;
async_mutex_leave(ASYNC_MUTEX_QUEUE);
Expand All @@ -1692,9 +1696,11 @@ int sqlite3async_control(int op, ...){
}

default:
return SQLITE_ERROR;
rc = SQLITE_ERROR;
break;
}
return SQLITE_OK;
va_end(ap);
return rc;
}

#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ASYNCIO) */
Expand Down
4 changes: 2 additions & 2 deletions src/test1.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static int test_exec_hex(
int rc, i, j;
char *zErr = 0;
char *zHex;
char zSql[500];
char zSql[501];
char zBuf[30];
if( argc!=3 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
Expand All @@ -347,7 +347,7 @@ static int test_exec_hex(
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
zHex = argv[2];
for(i=j=0; i<sizeof(zSql) && zHex[j]; i++, j++){
for(i=j=0; i<(sizeof(zSql)-1) && zHex[j]; i++, j++){
if( zHex[j]=='%' && zHex[j+2] && zHex[j+2] ){
zSql[i] = (testHexToInt(zHex[j+1])<<4) + testHexToInt(zHex[j+2]);
j += 2;
Expand Down
2 changes: 1 addition & 1 deletion test/threadtest2.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int check_callback(void *pid, int argc, char **argv, char **notUsed2){
int id = (int)pid;
if( strcmp(argv[0],"ok") ){
all_stop = 1;
fprintf(stderr,"id: %s\n", id, argv[0]);
fprintf(stderr,"%d: %s\n", id, argv[0]);
}else{
/* fprintf(stderr,"%d: OK\n", id); */
}
Expand Down

0 comments on commit f048c47

Please sign in to comment.