gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 13/26: doc/examples: do not use non-literals for printf(


From: gnunet
Subject: [libmicrohttpd] 13/26: doc/examples: do not use non-literals for printf()
Date: Mon, 25 Apr 2022 15:08:37 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 28f02d2eaa30c08743d95565fe7404cba17b3955
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sat Apr 23 16:16:22 2022 +0300

    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 =
-  "<html><body>\n\
-                       Upload a file, please!<br>\n\
-                       There are %u clients uploading at the moment.<br>\n\
-                       <form action=\"/filepost\" method=\"post\" 
enctype=\"multipart/form-data\">\n\
-                       <input name=\"file\" type=\"file\">\n\
-                       <input type=\"submit\" value=\" Send \"></form>\n\
-                       </body></html>";
+#define ASKPAGE \
+  "<html><body>\n" \
+  "Upload a file, please!<br>\n" \
+  "There are %u clients uploading at the moment.<br>\n" \
+  "<form action=\"/filepost\" method=\"post\" 
enctype=\"multipart/form-data\">\n" \
+  "<input name=\"file\" type=\"file\">\n" \
+  "<input type=\"submit\" value=\" Send \"></form>\n" \
+  "</body></html>"
 const char *busypage =
   "<html><body>This server is busy, please try again later.</body></html>";
 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, &not_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 =
                        <input type=\"submit\" value=\" Send \"></form>\
                        </body></html>";
 
-const char *greetingpage =
-  "<html><body><h1>Welcome, %s!</center></h1></body></html>";
+#define GREETINGPAGE \
+  "<html><body><h1>Welcome, %s!</center></h1></body></html>"
 
 const char *errorpage =
   "<html><body>This doesn't seem to be right.</body></html>";
@@ -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

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]