Commit 418e1d82 authored by Peter Eisentraut's avatar Peter Eisentraut

Refactor sprintf calls with computed format strings into multiple calls with

constant format strings, so that the compiler can more easily check the
formats for correctness.
parent 24cb6ab9
......@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.611 2010/06/03 21:02:11 petere Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.612 2010/06/16 00:54:16 petere Exp $
*
* NOTES
*
......@@ -3381,9 +3381,10 @@ BackendInitialize(Port *port)
(errmsg_internal("pg_getnameinfo_all() failed: %s",
gai_strerror(ret))));
}
snprintf(remote_ps_data, sizeof(remote_ps_data),
remote_port[0] == '\0' ? "%s" : "%s(%s)",
remote_host, remote_port);
if (remote_port[0] == '\0')
snprintf(remote_ps_data, sizeof(remote_ps_data), "%s", remote_host);
else
snprintf(remote_ps_data, sizeof(remote_ps_data), "%s(%s)", remote_host, remote_port);
if (Log_connections)
{
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.53 2010/05/09 02:15:59 tgl Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.54 2010/06/16 00:54:16 petere Exp $ */
#include "postgres_fe.h"
......@@ -815,7 +815,10 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
{
hour = -(*tzp / SECS_PER_HOUR);
min = (abs(*tzp) / MINS_PER_HOUR) % MINS_PER_HOUR;
sprintf(str + strlen(str), (min != 0) ? "%+03d:%02d" : "%+03d", hour, min);
if (min != 0)
sprintf(str + strlen(str), "%+03d:%02d", hour, min);
else
sprintf(str + strlen(str), "%+03d", hour);
}
break;
......@@ -869,7 +872,10 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
{
hour = -(*tzp / SECS_PER_HOUR);
min = (abs(*tzp) / MINS_PER_HOUR) % MINS_PER_HOUR;
sprintf(str + strlen(str), (min != 0) ? "%+03d:%02d" : "%+03d", hour, min);
if (min != 0)
sprintf(str + strlen(str), "%+03d:%02d", hour, min);
else
sprintf(str + strlen(str), "%+03d", hour);
}
}
break;
......@@ -915,7 +921,10 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
{
hour = -(*tzp / SECS_PER_HOUR);
min = (abs(*tzp) / MINS_PER_HOUR) % MINS_PER_HOUR;
sprintf(str + strlen(str), (min != 0) ? "%+03d:%02d" : "%+03d", hour, min);
if (min != 0)
sprintf(str + strlen(str), "%+03d:%02d", hour, min);
else
sprintf(str + strlen(str), "%+03d", hour);
}
}
break;
......@@ -977,7 +986,10 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
*/
hour = -(*tzp / SECS_PER_HOUR);
min = (abs(*tzp) / MINS_PER_HOUR) % MINS_PER_HOUR;
sprintf(str + strlen(str), (min != 0) ? " %+03d:%02d" : " %+03d", hour, min);
if (min != 0)
sprintf(str + strlen(str), " %+03d:%02d", hour, min);
else
sprintf(str + strlen(str), " %+03d", hour);
}
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment