From: Craig Ringer Date: Tue, 29 Apr 2014 13:42:19 +0000 (+0800) Subject: bdr: Don't use c99-only const array initializers X-Git-Url: http://git.postgresql.org/gitweb/static/developers.postgresql.org?a=commitdiff_plain;h=7f4d12c2938235b9aadf1696a2d63ffe2f713e07;p=users%2Fandresfreund%2Fpostgres.git bdr: Don't use c99-only const array initializers --- diff --git a/contrib/bdr/bdr_init_replica.c b/contrib/bdr/bdr_init_replica.c index 067cbb66b8..cadbce82af 100644 --- a/contrib/bdr/bdr_init_replica.c +++ b/contrib/bdr/bdr_init_replica.c @@ -107,15 +107,15 @@ bdr_get_remote_status(PGconn *pgconn, Name dbname) { PGresult *res; char status; - static const int n_params = 2; + const int n_params = 2; Oid param_types[] = {NUMERICOID, TEXTOID}; const char *param_values[n_params]; - const int sysid_str_length = 33; - char sysid_str[sysid_str_length]; + /* Needs to fit max length of UINT64_FORMAT */ + char sysid_str[33]; - snprintf(sysid_str, sysid_str_length, UINT64_FORMAT, + snprintf(sysid_str, sizeof(sysid_str), UINT64_FORMAT, GetSystemIdentifier()); - sysid_str[sysid_str_length-1] = '\0'; + sysid_str[sizeof(sysid_str)-1] = '\0'; param_values[0] = sysid_str; param_types[0] = NUMERICOID; @@ -166,16 +166,16 @@ bdr_set_remote_status(PGconn *pgconn, Name dbname, PGresult *res; char *status_str; const uint64 sysid = GetSystemIdentifier(); - const int sysid_str_length = 33; - char sysid_str[sysid_str_length]; + /* Needs to fit max length of UINT64_FORMAT */ + char sysid_str[33]; if (status == prev_status) /* No action required (we could check the remote, but meh) */ return status; - snprintf(sysid_str, sysid_str_length, UINT64_FORMAT, + snprintf(sysid_str, sizeof(sysid_str), UINT64_FORMAT, GetSystemIdentifier()); - sysid_str[sysid_str_length-1] = '\0'; + sysid_str[sizeof(sysid_str)-1] = '\0'; if (status == '\0') {