Fix warning about format string not being a string literal

This commit is contained in:
Mukund Sivaraman 2009-09-21 10:04:09 +05:30
parent f0cc213c5a
commit df6e8ae046

View File

@ -58,9 +58,26 @@ void init_stats (void)
/*
* Display the statics of the tinyproxy server.
*/
int showstats (struct conn_s *connptr)
int
showstats (struct conn_s *connptr)
{
static const char *msg =
char *message_buffer;
char opens[16], reqs[16], badconns[16], denied[16], refused[16];
FILE *statfile;
snprintf (opens, sizeof (opens), "%lu", stats->num_open);
snprintf (reqs, sizeof (reqs), "%lu", stats->num_reqs);
snprintf (badconns, sizeof (badconns), "%lu", stats->num_badcons);
snprintf (denied, sizeof (denied), "%lu", stats->num_denied);
snprintf (refused, sizeof (refused), "%lu", stats->num_refused);
if (!config.statpage || (!(statfile = fopen (config.statpage, "r")))) {
message_buffer = (char *) safemalloc (MAXBUFFSIZE);
if (!message_buffer)
return -1;
snprintf
(message_buffer, MAXBUFFSIZE,
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" "
"\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
@ -77,31 +94,15 @@ int showstats (struct conn_s *connptr)
"</p>\n"
"<hr />\n"
"<p><em>Generated by %s version %s.</em></p>\n" "</body>\n"
"</html>\n";
char *message_buffer;
char opens[16], reqs[16], badconns[16], denied[16], refused[16];
FILE *statfile;
snprintf (opens, sizeof (opens), "%lu", stats->num_open);
snprintf (reqs, sizeof (reqs), "%lu", stats->num_reqs);
snprintf (badconns, sizeof (badconns), "%lu", stats->num_badcons);
snprintf (denied, sizeof (denied), "%lu", stats->num_denied);
snprintf (refused, sizeof (refused), "%lu", stats->num_refused);
if (!config.statpage || (!(statfile = fopen (config.statpage, "r")))) {
message_buffer = (char *) safemalloc (MAXBUFFSIZE);
if (!message_buffer)
return -1;
snprintf (message_buffer, MAXBUFFSIZE, msg,
"</html>\n",
PACKAGE, VERSION, PACKAGE, VERSION,
stats->num_open,
stats->num_reqs,
stats->num_badcons, stats->num_denied,
stats->num_refused, PACKAGE, VERSION);
if (send_http_message (connptr, 200, "OK", message_buffer) < 0) {
if (send_http_message (connptr, 200, "OK",
message_buffer) < 0) {
safefree (message_buffer);
return -1;
}