diff options
author | Peter Eisentraut | 2011-09-10 20:12:46 +0000 |
---|---|---|
committer | Peter Eisentraut | 2011-09-10 20:12:46 +0000 |
commit | 52ce20589a8bac4eccaea043b1fe283daaf4f9e3 (patch) | |
tree | 2e3bdabd95a1db624ec982f5cd4634a7f540c858 /contrib | |
parent | 96a8aed4cb66b9a23e5b566ad549cd0c5eac5a74 (diff) |
Add missing format attributes
Add __attribute__ decorations for printf format checking to the places that
were missing them. Fix the resulting warnings. Add
-Wmissing-format-attribute to the standard set of warnings for GCC, so these
don't happen again.
The warning fixes here are relatively harmless. The one serious problem
discovered by this was already committed earlier in
cf15fb5cabfbc71e07be23cfbc813daee6c5014f.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/pg_upgrade/info.c | 2 | ||||
-rw-r--r-- | contrib/pg_upgrade/pg_upgrade.h | 16 | ||||
-rw-r--r-- | contrib/pg_upgrade/relfilenode.c | 4 | ||||
-rw-r--r-- | contrib/pgcrypto/px.h | 3 |
4 files changed, 16 insertions, 9 deletions
diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c index 5606486ef36..e41ab2b1071 100644 --- a/contrib/pg_upgrade/info.c +++ b/contrib/pg_upgrade/info.c @@ -286,7 +286,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo) (GET_MAJOR_VERSION(old_cluster.major_version) <= 804) ? "" : ", 'pg_largeobject_metadata', 'pg_largeobject_metadata_oid_index'"); - res = executeQueryOrDie(conn, query); + res = executeQueryOrDie(conn, "%s", query); ntups = PQntuples(res); diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h index 2abd91771f9..46aed74450d 100644 --- a/contrib/pg_upgrade/pg_upgrade.h +++ b/contrib/pg_upgrade/pg_upgrade.h @@ -292,8 +292,8 @@ void split_old_dump(void); /* exec.c */ -int exec_prog(bool throw_error, - const char *cmd,...); +int exec_prog(bool throw_error, const char *cmd, ...) + __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); void verify_directories(void); bool is_server_running(const char *datadir); void rename_old_pg_control(void); @@ -377,7 +377,8 @@ void init_tablespaces(void); /* server.c */ PGconn *connectToServer(ClusterInfo *cluster, const char *db_name); -PGresult *executeQueryOrDie(PGconn *conn, const char *fmt,...); +PGresult *executeQueryOrDie(PGconn *conn, const char *fmt, ...) + __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); void start_postmaster(ClusterInfo *cluster); void stop_postmaster(bool fast); @@ -390,9 +391,12 @@ void check_pghost_envvar(void); char *quote_identifier(const char *s); int get_user_info(char **user_name); void check_ok(void); -void report_status(eLogType type, const char *fmt,...); -void pg_log(eLogType type, char *fmt,...); -void prep_status(const char *fmt,...); +void report_status(eLogType type, const char *fmt, ...) + __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); +void pg_log(eLogType type, char *fmt, ...) + __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); +void prep_status(const char *fmt, ...) + __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); void check_ok(void); char *pg_strdup(const char *s); void *pg_malloc(int size); diff --git a/contrib/pg_upgrade/relfilenode.c b/contrib/pg_upgrade/relfilenode.c index 9354d92d36c..1aefd337f1f 100644 --- a/contrib/pg_upgrade/relfilenode.c +++ b/contrib/pg_upgrade/relfilenode.c @@ -71,7 +71,9 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr, } } - prep_status(""); /* in case nothing printed */ + prep_status(" "); /* in case nothing printed; pass a space so gcc + * doesn't complain about empty format + * string */ check_ok(); return msg; diff --git a/contrib/pgcrypto/px.h b/contrib/pgcrypto/px.h index 9709f9bdb60..610b7fad789 100644 --- a/contrib/pgcrypto/px.h +++ b/contrib/pgcrypto/px.h @@ -204,7 +204,8 @@ const char *px_resolve_alias(const PX_Alias *aliases, const char *name); void px_set_debug_handler(void (*handler) (const char *)); #ifdef PX_DEBUG -void px_debug(const char *fmt,...); +void px_debug(const char *fmt, ...) + __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); #else #define px_debug(...) #endif |