RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: [EMAIL PROTECTED] Module: rpm Date: 31-Mar-2008 15:20:29 Branch: HEAD Handle: 2008033113202900 Modified files: rpm/rpmio rpmrepo.c Log: - jbj: rpmrepo: study the mess with splint. Summary: Revision Changes Path 1.44 +56 -5 rpm/rpmio/rpmrepo.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/rpmio/rpmrepo.c ============================================================================ $ cvs diff -u -r1.43 -r1.44 rpmrepo.c --- rpm/rpmio/rpmrepo.c 28 Mar 2008 20:22:52 -0000 1.43 +++ rpm/rpmio/rpmrepo.c 31 Mar 2008 13:20:29 -0000 1.44 @@ -6,6 +6,41 @@ #if defined(WITH_SQLITE) #include <sqlite3.h> +#ifdef __LCLINT__ +/[EMAIL PROTECTED] -redecl @*/ +extern const char *sqlite3_errmsg(sqlite3 *db) + /[EMAIL PROTECTED]/; +extern int sqlite3_open( + const char *filename, /* Database filename (UTF-8) */ + /[EMAIL PROTECTED]@*/ sqlite3 **ppDb /* OUT: SQLite db handle */ +) + /[EMAIL PROTECTED] *ppDb @*/; +extern int sqlite3_exec( + sqlite3 *db, /* An open database */ + const char *sql, /* SQL to be evaluted */ + int (*callback)(void*,int,char**,char**), /* Callback function */ + void *, /* 1st argument to callback */ + /[EMAIL PROTECTED]@*/ char **errmsg /* Error msg written here */ +) + /[EMAIL PROTECTED] db, *errmsg @*/; +extern int sqlite3_prepare( + sqlite3 *db, /* Database handle */ + const char *zSql, /* SQL statement, UTF-8 encoded */ + int nByte, /* Maximum length of zSql in bytes. */ + /[EMAIL PROTECTED]@*/ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + /[EMAIL PROTECTED]@*/ const char **pzTail /* OUT: Pointer to unused portion of zSql */ +) + /[EMAIL PROTECTED] *ppStmt, *pzTail @*/; +extern int sqlite3_reset(sqlite3_stmt *pStmt) + /[EMAIL PROTECTED] pStmt @*/; +extern int sqlite3_step(sqlite3_stmt *pStmt) + /[EMAIL PROTECTED] pStmt @*/; +extern int sqlite3_finalize(/[EMAIL PROTECTED]@*/ sqlite3_stmt *pStmt) + /[EMAIL PROTECTED] pStmt @*/; +extern int sqlite3_close(sqlite3 * db) + /[EMAIL PROTECTED] db @*/; +/[EMAIL PROTECTED] =redecl @*/ +#endif #endif #include <rpmio_internal.h> /* XXX fdInitDigest() et al */ @@ -264,6 +299,7 @@ \n</package>\ \n"; +/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ static const char *primary_sql_init[] = { "PRAGMA synchronous = 0;", @@ -333,6 +369,7 @@ NULL }; /*XXX todo: DBVERSION needs to be set */ +/[EMAIL PROTECTED]@*/ /* packages 1 pkgKey INTEGER PRIMARY KEY */ /* packages 2 pkgId TEXT */ @@ -884,7 +921,7 @@ xx = sqlite3_exec(rfile->sqldb, *stmt, NULL, NULL, &msg); if (xx != SQLITE_OK) repo_error(1, "sqlite3_exec(%s, \"%s\"): %s\n", fn, *stmt, - (msg ? msg : "failed")); + (msg != NULL ? msg : "failed")); } fn = _free(fn); } @@ -924,11 +961,14 @@ } static const char * rfileHeaderSprintf(Header h, const char * qfmt) + /[EMAIL PROTECTED] fileSystem @*/ + /[EMAIL PROTECTED] h, fileSystem @*/ { const char * msg = NULL; const char * s = headerSprintf(h, qfmt, NULL, NULL, &msg); if (s == NULL) repo_error(1, _("headerSprintf(%s): %s"), qfmt, msg); +assert(s != NULL); return s; } @@ -944,11 +984,14 @@ } static int rfileSQLStep(rpmrfile rfile, sqlite3_stmt * stmt) + /[EMAIL PROTECTED] fileSystem @*/ + /[EMAIL PROTECTED] fileSystem @*/ { int loop = 1; int rc = 0; int xx; +/[EMAIL PROTECTED]@*/ while (loop) { rc = sqlite3_step(stmt); switch (rc) { @@ -960,6 +1003,7 @@ /[EMAIL PROTECTED]@*/ break; } } +/[EMAIL PROTECTED]@*/ xx = rfileSQL(rfile, "reset", sqlite3_reset(stmt)); @@ -968,6 +1012,8 @@ } static const char * rfileHeaderSprintfHack(Header h, const char * qfmt) + /[EMAIL PROTECTED] fileSystem @*/ + /[EMAIL PROTECTED] h, fileSystem @*/ { static const char mark[] = "'XXX'"; static size_t nmark = sizeof("'XXX'") - 1; @@ -978,10 +1024,13 @@ if (s == NULL) repo_error(1, _("headerSprintf(%s): %s"), qfmt, msg); +assert(s != NULL); /* XXX Find & replace 'XXX' with '%{DBINSTANCE}' the hard way. */ - for (f = s; *f && (fe = strstr(f, "'XXX'")) != NULL; fe += nmark, f = fe) +/[EMAIL PROTECTED]@*/ + for (f = s; *f != '\0' && (fe = strstr(f, "'XXX'")) != NULL; fe += nmark, f = fe) nsubs++; +/[EMAIL PROTECTED]@*/ if (nsubs > 0) { char instance[64]; @@ -992,11 +1041,13 @@ char * te = t; xx = xx; - for (f = s; *f && (fe = strstr(f, mark)) != NULL; fe += nmark, f = fe) { +/[EMAIL PROTECTED]@*/ + for (f = s; *f != '\0' && (fe = strstr(f, mark)) != NULL; fe += nmark, f = fe) { *fe = '\0'; te = stpcpy( stpcpy(te, f), instance); } - if (*f) +/[EMAIL PROTECTED]@*/ + if (*f != '\0') te = stpcpy(te, f); s = _free(s); s = t; @@ -1007,7 +1058,7 @@ static int rfileSQLWrite(rpmrfile rfile, /[EMAIL PROTECTED]@*/ const char * cmd) /[EMAIL PROTECTED] fileSystem @*/ - /[EMAIL PROTECTED] rfile, fileSystem @*/ + /[EMAIL PROTECTED] fileSystem @*/ { sqlite3_stmt * stmt; const char * tail; @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org