IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8610 for trunk/psLib/src/db


Ignore:
Timestamp:
Aug 25, 2006, 2:32:39 PM (20 years ago)
Author:
jhoblitt
Message:

add gcc format attributes to psStringAppend(), psStringPrepend(), p_psDBRunQuery(), & p_psDBRunQueryPrepared()
fix all of the format params errors found by the new attributes

Location:
trunk/psLib/src/db
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/db/psDB.c

    r8602 r8610  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.86 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-08-25 22:02:40 $
     14 *  @version $Revision: 1.87 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-08-26 00:32:39 $
    1616 *
    1717 *  Copyright (C) 2005-2006  Joshua Hoblitt, University of Hawaii
     
    12521252        } else if (item->type == PS_DATA_STRING) {
    12531253            // + column name + _ + varchar( + length + )
    1254             psStringAppend(&query, "%s VARCHAR(%s)", item->name, item->data.V);
     1254            psStringAppend(&query, "%s VARCHAR(%s)", item->name, (char *)item->data.V);
    12551255        } else {
    12561256            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     
    12891289        for (int i = 0; i < psArrayLength(pKeys); i++) {
    12901290            if (i < 1) {
    1291                 psStringAppend(&query, "%s", pKeys->data[i]);
     1291                psStringAppend(&query, "%s", (char *)pKeys->data[i]);
    12921292            } else {
    1293                 psStringAppend(&query, ", %s", pKeys->data[i]);
     1293                psStringAppend(&query, ", %s", (char *)pKeys->data[i]);
    12941294            }
    12951295        }
     
    16421642                // very large TEXT columns that really shouldn't be
    16431643                // used in a where clause...
    1644                 psStringAppend(&query, "%s LIKE '%s'", item->name, item->data.V);
     1644                psStringAppend(&query, "%s LIKE '%s'", item->name, (char *)item->data.V);
    16451645            } else {
    1646                 psStringAppend(&query, "%s = '%s'", item->name, item->data.V);
     1646                psStringAppend(&query, "%s = '%s'", item->name, (char *)item->data.V);
    16471647            }
    16481648        }
  • trunk/psLib/src/db/psDB.h

    r8336 r8610  
    1010 *  @author Joshua Hoblitt
    1111 *
    12  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-08-15 02:28:13 $
     12 *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-08-26 00:32:39 $
    1414 *
    1515 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    9090 * @return bool:    true on success
    9191 */
     92#ifdef __GNUC__
    9293bool p_psDBRunQuery(
    9394    psDB *dbh,                         ///< Database handle
    9495    const char *format,                ///< SQL string to execute
    9596    ...                                ///< Arguments for name formatting and metadata item data.
    96 );
     97) __attribute__((format(printf, 2, 3)));
     98
     99#else // __GNUC__
     100bool p_psDBRunQuery(
     101    psDB *dbh,                         ///< Database handle
     102    const char *format,                ///< SQL string to execute
     103    ...                                ///< Arguments for name formatting and metadata item data.
     104);
     105#endif // __GNUC__
    97106
    98107/** Executes a SQL query as a prepared statement
     
    104113 * @return long:    the number of database rows affected
    105114 */
     115#ifdef __GNUC__
    106116long p_psDBRunQueryPrepared(
    107117    psDB *dbh,                          ///< Database handle
     
    109119    const char *format,                 ///< SQL string to execute
    110120    ...
    111 );
     121) __attribute__((format(printf, 3, 4)));
     122#else // __GNUC__
     123long p_psDBRunQueryPrepared(
     124    psDB *dbh,                          ///< Database handle
     125    const psArray *rowSet,              ///< row data as psArray of psMetadata
     126    const char *format,                 ///< SQL string to execute
     127    ...
     128);
     129#endif // __GNUC__
    112130
    113131/** Fetches the result of a SQL query
Note: See TracChangeset for help on using the changeset viewer.