0999158088e0fb3715eb27703c8c4f7123d77144 galt Mon Sep 21 16:51:20 2015 -0700 added GNU-C attributes to function declarations in src/inc, src/hg/inc, and some CGIs so that the compiler can catch errors where the parameter list given by the user does not match their format string. These var-args functions are like printf. diff --git src/hg/inc/jksql.h src/hg/inc/jksql.h index 361bf57..8013870 100644 --- src/hg/inc/jksql.h +++ src/hg/inc/jksql.h @@ -408,37 +408,45 @@ /* Find number of rows in table. */ int sqlFieldIndex(struct sqlConnection *conn, char *table, char *field); /* Returns index of field in a row from table, or -1 if it * doesn't exist. */ struct slName *sqlFieldNames(struct sqlConnection *conn, char *table); /* Returns field names from a table. */ unsigned int sqlLastAutoId(struct sqlConnection *conn); /* Return last automatically incremented id inserted into database. */ void sqlVaWarn(struct sqlConnection *sc, char *format, va_list args); /* Error message handler. */ -void sqlWarn(struct sqlConnection *sc, char *format, ...); +void sqlWarn(struct sqlConnection *sc, char *format, ...) /* Printf formatted error message that adds on sql * error message. */ +#if defined(__GNUC__) +__attribute__((format(printf, 2, 3))) +#endif +; -void sqlAbort(struct sqlConnection *sc, char *format, ...); +void sqlAbort(struct sqlConnection *sc, char *format, ...) /* Printf formatted error message that adds on sql * error message and abort. */ +#if defined(__GNUC__) +__attribute__((format(printf, 2, 3))) +#endif +; void sqlCleanupAll(void); /* Cleanup all open connections and resources. */ boolean sqlWildcardIn(char *s); /* Return TRUE if there is a sql wildcard char in string. */ char *sqlLikeFromWild(char *wild); /* Convert normal wildcard string to SQL wildcard by * mapping * to % and ? to _. Escape any existing % and _'s. */ /* flags controlling mysql tracing and time logging */ #define JKSQL_TRACE 0x01 /* enable tracing of each mysql query to stderr */ #define JKSQL_PROF 0x02 /* record time spend in database queries, * and dump at exit. */