Clean up and type fixes.

After discussions with Keith Bostic I've learned that always specifying the
full type (u_int32_t rather than int) as a general rule is not always a good
idea.  Now, as I review code I'm reverting some of those changes.  The new
rule of thumb is to use explict typing only in places that require it.
This commit is contained in:
Gregory Burd 2007-10-21 01:33:16 +01:00
parent 2529f39db1
commit 9ab52d89be
5 changed files with 14 additions and 13 deletions

View file

@ -589,7 +589,8 @@ open_db(p)
filename = p->db_filename;
if (!strcmp(p->db_filename, ":memory:"))
filename = 0;
rc = dbsql_create_env(&p->db, filename, p->crypt_key,0,flags);
rc = dbsql_create_env(&p->db, filename,
p->crypt_key, 0, flags);
switch (rc) {
case DB_RUNRECOVERY:
fprintf(g.errfp, "Database requires recovery.\n");
@ -966,7 +967,7 @@ do_meta_command(line, p)
fprintf(p->out, "\n\n");
} else if (c == 't' && n > 1 && strncmp(args[0], "tables", n) == 0) {
char **results;
int nRow, rc;
int nRow, nCol, rc;
char *err_msgs;
open_db(p);
if (num_args == 1) {
@ -977,7 +978,7 @@ do_meta_command(line, p)
"SELECT name FROM " TEMP_MASTER_NAME " "
"WHERE type IN ('table','view') "
"ORDER BY 1",
&results, &nRow, 0, &err_msgs);
&results, &nRow, &nCol, &err_msgs);
} else {
rc = p->db->exec_table_printf(p->db,
"SELECT name FROM " MASTER_NAME " "

View file

@ -183,16 +183,16 @@ typedef struct sm_cursor {
* the ATTACH statement during the session.
*/
struct __dbsql_db {
char *zName; /* Name of this database */
sm_t *pBt; /* The storage manager for this database */
u_int32_t schema_sig;/* Database schema version number for this file */
char *zName; /* Name of this database */
sm_t *pBt; /* The storage manager for this database */
int schema_sig; /* Database schema version number for this file */
hash_t tblHash; /* All tables indexed by name */
hash_t idxHash; /* All (named) indices indexed by name */
hash_t trigHash; /* All triggers indexed by name */
hash_t aFKey; /* Foreign keys indexed by to-table */
u_int8_t inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */
int inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */
DBSQL *dbp; /* A reference to our managing DBSQL */
u_int16_t flags; /* Flags associated with this database */
int flags; /* Flags associated with this database */
/*
* The DBSQL_SCHEMA_LOCKED flag is set when the first OP_Transaction or
* OP_Checkpoint opcode is emitted for a database. This prevents multiple

View file

@ -351,7 +351,7 @@ __random_func(context, argc, argv)
int argc;
const char **argv;
{
u_int32_t n;
int n;
static struct drand48_data rand;
static int first_time = 1;
if (first_time) {

View file

@ -2445,7 +2445,7 @@ case OP_SetSchemaSignature: {
** everyone (and their data).
*/
case OP_VerifySchemaSignature: {
u_int32_t sig;
int sig;
DBSQL_ASSERT(pOp->p1 >= 0 && pOp->p1 < db->nDb);
rc = __sm_get_schema_sig(db->aDb[pOp->p1].pBt, &sig);
if (rc == DBSQL_SUCCESS && sig != pOp->p2) {
@ -2950,7 +2950,7 @@ case OP_NewRecno: {
srand48_r(1, &rand); /* XXX create a portable rand function */
}
int i = pOp->p1;
u_int32_t v = 0;
int v = 0;
cursor_t *pC;
DBSQL_ASSERT(i >= 0 && i < p->nCursor);
if ((pC = &p->aCsr[i])->pCursor == 0) {
@ -3396,7 +3396,7 @@ case OP_Recno: {
break;
} else {
DBSQL_ASSERT(pC->pCursor != 0);
__sm_key(pC->pCursor, 0, sizeof(u_int32_t), (char*)&v);
__sm_key(pC->pCursor, 0, sizeof(int), (char*)&v);
v = KEY_TO_INT(v);
}
pTos->i = v;

View file

@ -533,7 +533,7 @@ dbsql_set_result_string(p, result, n)
p->s.flags = MEM_Str | MEM_Short;
p->s.z = p->s.zShort;
} else {
if (__dbsql_calloc(NULL, 1, n + 1, &p->s.z) != ENOMEM){
if (__dbsql_calloc(NULL, 1, n + 1, &p->s.z) != ENOMEM) {
memcpy(p->s.z, result, n);
p->s.z[n] = 0;
}