From 28f02d2eaa30c08743d95565fe7404cba17b3955 Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Sat, 23 Apr 2022 16:16:22 +0300 Subject: [PATCH] doc/examples: do not use non-literals for printf() --- doc/examples/largepost.c | 18 +++++++++--------- doc/examples/sessions.c | 12 ++++++------ doc/examples/simplepost.c | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/examples/largepost.c b/doc/examples/largepost.c index 6cfaf833..da9c1c56 100644 --- a/doc/examples/largepost.c +++ b/doc/examples/largepost.c @@ -66,14 +66,14 @@ struct connection_info_struct }; -const char *askpage = - "\n\ - Upload a file, please!
\n\ - There are %u clients uploading at the moment.
\n\ -
\n\ - \n\ -
\n\ - "; +#define ASKPAGE \ + "\n" \ + "Upload a file, please!
\n" \ + "There are %u clients uploading at the moment.
\n" \ + "
\n" \ + "\n" \ + "
\n" \ + "" const char *busypage = "This server is busy, please try again later."; const char *completepage = @@ -271,7 +271,7 @@ answer_to_connection (void *cls, snprintf (buffer, sizeof (buffer), - askpage, + ASKPAGE, nr_of_uploading_clients); return send_page (connection, buffer, diff --git a/doc/examples/sessions.c b/doc/examples/sessions.c index 5b4d4b45..fc4a498c 100644 --- a/doc/examples/sessions.c +++ b/doc/examples/sessions.c @@ -339,12 +339,12 @@ fill_v1_form (const void *cls, struct MHD_Connection *connection) { enum MHD_Result ret; - const char *form = cls; char *reply; struct MHD_Response *response; + (void) cls; /* Unused */ if (-1 == asprintf (&reply, - form, + MAIN_PAGE, session->value_1)) { /* oops */ @@ -381,12 +381,12 @@ fill_v1_v2_form (const void *cls, struct MHD_Connection *connection) { enum MHD_Result ret; - const char *form = cls; char *reply; struct MHD_Response *response; + (void) cls; /* Unused */ if (-1 == asprintf (&reply, - form, + SECOND_PAGE, session->value_1, session->value_2)) { @@ -446,8 +446,8 @@ not_found_page (const void *cls, * List of all pages served by this HTTP server. */ static struct Page pages[] = { - { "/", "text/html", &fill_v1_form, MAIN_PAGE }, - { "/2", "text/html", &fill_v1_v2_form, SECOND_PAGE }, + { "/", "text/html", &fill_v1_form, NULL }, + { "/2", "text/html", &fill_v1_v2_form, NULL }, { "/S", "text/html", &serve_simple_form, SUBMIT_PAGE }, { "/F", "text/html", &serve_simple_form, LAST_PAGE }, { NULL, NULL, ¬_found_page, NULL } /* 404 */ diff --git a/doc/examples/simplepost.c b/doc/examples/simplepost.c index 0faa0948..52146ce3 100644 --- a/doc/examples/simplepost.c +++ b/doc/examples/simplepost.c @@ -41,8 +41,8 @@ const char *askpage = \ "; -const char *greetingpage = - "

Welcome, %s!

"; +#define GREETINGPAGE \ + "

Welcome, %s!

" const char *errorpage = "This doesn't seem to be right."; @@ -88,7 +88,7 @@ iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key, if (! answerstring) return MHD_NO; - snprintf (answerstring, MAXANSWERSIZE, greetingpage, data); + snprintf (answerstring, MAXANSWERSIZE, GREETINGPAGE, data); con_info->answerstring = answerstring; } else