gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: fixing misc warnings


From: gnunet
Subject: [taler-anastasis] branch master updated: fixing misc warnings
Date: Wed, 14 Oct 2020 11:19:21 +0200

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

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 562e382  fixing misc warnings
562e382 is described below

commit 562e3823543758a86c9dfb63cb54cf15932beca8
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Oct 14 11:19:18 2020 +0200

    fixing misc warnings
---
 src/backend/anastasis-httpd_policy.c        |  2 +-
 src/backend/anastasis-httpd_policy_upload.c |  6 ++--
 src/backend/anastasis-httpd_truth.c         | 12 ++++++++
 src/cli/anastasis-cli-assembler.c           | 18 ++----------
 src/include/anastasis.h                     |  9 +++---
 src/include/anastasis_database_plugin.h     | 24 +++++++--------
 src/include/anastasis_service.h             |  5 +++-
 src/include/anastasis_testing_lib.h         |  4 +--
 src/lib/anastasis.c                         | 33 ++++++++-------------
 src/lib/test_anastasis.c                    |  9 ++----
 src/lib/testing_api_cmd_truth_store.c       | 16 ++++------
 src/lib/testing_cmd_challenge_answer.c      | 45 ++++++++++++++---------------
 12 files changed, 83 insertions(+), 100 deletions(-)

diff --git a/src/backend/anastasis-httpd_policy.c 
b/src/backend/anastasis-httpd_policy.c
index cc853a4..0ca73ef 100644
--- a/src/backend/anastasis-httpd_policy.c
+++ b/src/backend/anastasis-httpd_policy.c
@@ -75,7 +75,7 @@ AH_return_policy (struct MHD_Connection *connection,
     {
       return TALER_MHD_reply_with_error (connection,
                                          MHD_HTTP_BAD_REQUEST,
-                                         43,
+                                         43, // FIXME: use proper EC!
                                          "version");
     }
     qs = db->get_recovery_document (db->cls,
diff --git a/src/backend/anastasis-httpd_policy_upload.c 
b/src/backend/anastasis-httpd_policy_upload.c
index 3c439b9..7830720 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -695,8 +695,8 @@ AH_handler_policy_post (struct MHD_Connection *connection,
       {
         return TALER_MHD_reply_with_error (connection,
                                            MHD_HTTP_BAD_REQUEST,
-                                           42 /*FIXME */,
-                                           "account public key malformed");
+                                           
TALER_EC_REQUEST_PARAMETER_MALFORMED,
+                                           "account public key (after /policy/ 
in URL)");
       }
     }
     puc->account = accountPubP;
@@ -924,8 +924,8 @@ AH_handler_policy_post (struct MHD_Connection *connection,
 
           qs = db->record_recdoc_payment (db->cls,
                                           &accountPubP,
-                                          &puc->payment_identifier,
                                           post_counter,
+                                          &puc->payment_identifier,
                                           &AH_annual_fee);
           if (qs >= 0)
           {
diff --git a/src/backend/anastasis-httpd_truth.c 
b/src/backend/anastasis-httpd_truth.c
index 6dfa245..036a6d5 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -28,6 +28,7 @@
 #include <gnunet/gnunet_rest_lib.h>
 #include "anastasis_authorization_plugin.h"
 #include <taler/taler_merchant_service.h>
+#include <taler/taler_json_lib.h>
 
 /**
  * Authentication plugin which is used to verify code based authentication
@@ -229,6 +230,7 @@ request_done (struct TM_HandlerContext *hc)
   hc->ctx = NULL;
 }
 
+
 /**
  * Transmit a payment request for @a order_id on @a connection
  *
@@ -269,6 +271,7 @@ make_payment_request (const char *order_id)
   return resp;
 }
 
+
 /**
  * Callbacks of this type are used to serve the result of submitting a
  * /contract request to a merchant.
@@ -348,6 +351,7 @@ proposal_cb (void *cls,
   gc->response_code = MHD_HTTP_PAYMENT_REQUIRED;
 }
 
+
 static MHD_RESULT
 return_key_share (const struct
                   ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
@@ -381,6 +385,7 @@ return_key_share (const struct
   return ret;
 }
 
+
 /**
  * Function called on all pending payments for the right
  * account.
@@ -410,6 +415,8 @@ ongoing_payment_cb (void *cls,
     gc->existing_order_timestamp = timestamp;
   }
 }
+
+
 /**
  * Callback to process a GET /check-payment request
  *
@@ -472,6 +479,8 @@ check_payment_cb (void *cls,
   GNUNET_assert (NULL != gc->resp);
   gc->response_code = MHD_HTTP_REQUEST_TIMEOUT;
 }
+
+
 /**
  * Helper function used to ask our backend to await
  * a payment for the user's account.
@@ -500,6 +509,8 @@ await_payment (struct GetContext *gc,
                                                gc);
   AH_trigger_curl ();
 }
+
+
 /**
  * Helper function used to ask our backend to begin
  * processing a payment for the user's account.
@@ -583,6 +594,7 @@ begin_payment (struct GetContext *gc,
   return MHD_YES;
 }
 
+
 /**
  * @param connection the MHD connection to handle
  * @param url handles a URL of the format 
"/truth/$TRUTH_PUBLIC_KEY[&response=$RESPONSE]"
diff --git a/src/cli/anastasis-cli-assembler.c 
b/src/cli/anastasis-cli-assembler.c
index fbd6d4b..2a9a2f4 100644
--- a/src/cli/anastasis-cli-assembler.c
+++ b/src/cli/anastasis-cli-assembler.c
@@ -193,12 +193,7 @@ struct ChallengeState
   /**
    * Answer to the challenge we are solving
    */
-  const void *answer;
-
-  /**
-   * Size of the answer we are solving
-   */
-  size_t answer_size;
+  const char *answer;
 
   /**
    * Referenece to the recovery process
@@ -445,13 +440,11 @@ read_keyboard_command (void *cls)
 
     cs->http_status = MHD_HTTP_PAYMENT_REQUIRED;
     cs->answer = "try";
-    cs->answer_size = strlen ("try");
     cs->challenge_index = truth_index;
 
     ANASTASIS_challenge_answer (ctx,
                                 challenges[truth_index].challenge,
                                 cs->answer,
-                                cs->answer_size,
                                 &challenge_try_cb,
                                 cs);
     start_read_keyboard ();
@@ -497,27 +490,22 @@ read_keyboard_command (void *cls)
 
     cs->http_status = MHD_HTTP_OK;
     cs->answer = challenge_answer;
-    cs->answer_size = strlen (challenge_answer);
     cs->challenge_index = truth_index;
 
     ANASTASIS_challenge_answer (ctx,
                                 challenges[truth_index].challenge,
                                 cs->answer,
-                                cs->answer_size,
                                 &challenge_answer_cb,
                                 cs);
-
     start_read_keyboard ();
     GNUNET_free (buffer);
-    buffer = NULL;
     return;
   }
 
   fprintf (stderr,
            "Unknown command '%s'\n",
-           (char *) buffer);
+           buffer);
   GNUNET_free (buffer);
-  buffer = NULL;
   start_read_keyboard ();
 }
 
@@ -863,4 +851,4 @@ main (int argc,
 }
 
 
-/* end of anastasis-cli-assembler.c */
\ No newline at end of file
+/* end of anastasis-cli-assembler.c */
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index fa98a08..845ef5c 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -116,24 +116,25 @@ typedef void
 (*ANASTASIS_AnswerFeedback)(void *af_cls,
                             enum TALER_ErrorCode ec);
 
+
 /**
  * Challenge answer from the user like input SMS pin. Is referenced to a 
challenge and
  * sends back an AnswerFeedback.
  *
- * @param challenge reference to the challenge which is answered
+ * @param ctx context for curl interaction
+ * @param c reference to the challenge which is answered
  * @param answer user input instruction defines which input is needed
- * @param answer_size size of the user answer
  * @param af reference to the answerfeedback which is passed back to the user
  * @param af_cls handle for the challenge answer struct
  */
 void
 ANASTASIS_challenge_answer (struct GNUNET_CURL_Context *ctx,
                             struct ANASTASIS_Challenge *c,
-                            const void *answer,
-                            size_t answer_size,
+                            const char *answer,
                             ANASTASIS_AnswerFeedback af,
                             void *af_cls);
 
+
 /**
  * Defines the instructions for a challenge, what does the user have to do to 
fulfill the challenge.
  * Also defines the method and other information for the challenge like a link 
for the video indent
diff --git a/src/include/anastasis_database_plugin.h 
b/src/include/anastasis_database_plugin.h
index 1c0f31a..f2c3e99 100644
--- a/src/include/anastasis_database_plugin.h
+++ b/src/include/anastasis_database_plugin.h
@@ -378,12 +378,11 @@ struct ANASTASIS_DatabasePlugin
    * @return transaction status
    */
   enum ANASTASIS_DB_QueryStatus
-  (*increment_lifetime)(void *cls,
-                        const struct
-                        ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub,
-                        const struct
-                        ANASTASIS_PaymentSecretP *payment_identifier,
-                        struct GNUNET_TIME_Relative lifetime);
+  (*increment_lifetime)(
+    void *cls,
+    const struct ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub,
+    const struct ANASTASIS_PaymentSecretP *payment_identifier,
+    struct GNUNET_TIME_Relative lifetime);
 
 
   /**
@@ -399,13 +398,12 @@ struct ANASTASIS_DatabasePlugin
    * @return transaction status
    */
   enum ANASTASIS_DB_QueryStatus
-  (*record_recdoc_payment)(void *cls,
-                           const struct
-                           ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub,
-                           uint32_t post_counter,
-                           const struct
-                           ANASTASIS_PaymentSecretP *payment_secret,
-                           const struct TALER_Amount *amount);
+  (*record_recdoc_payment)(
+    void *cls,
+    const struct ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub,
+    uint32_t post_counter,
+    const struct ANASTASIS_PaymentSecretP *payment_secret,
+    const struct TALER_Amount *amount);
 
   /**
    * Verify the provided code with the code on the server.
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 17ba57b..823694f 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -513,6 +513,7 @@ typedef void
   unsigned int http_status,
   const struct ANASTASIS_KeyShareDownloadDetails *kdd);
 
+
 /**
  * Does a GET /truth.
  *
@@ -520,7 +521,7 @@ typedef void
  * @param backend_url base URL of the merchant backend
  * @param truth_public_key identification of the Truth
  * @param truth_key Key used to Decrypt the Truth on the Server
- * @param answer Answer for the different authentication methods(code, hash)
+ * @param answer Answer for the different authentication methods(code, hash of 
answer as string)
  * @param cb callback which will work the response gotten from the backend
  * @param cb_cls closure to pass to the callback
  * @return handle for this operation, NULL upon errors
@@ -535,6 +536,7 @@ ANASTASIS_keyshare_lookup (
   ANASTASIS_KeyShareLookupCallback cb,
   void *cb_cls);
 
+
 /**
  * Cancel a GET /truth request.
  *
@@ -544,6 +546,7 @@ void
 ANASTASIS_keyshare_lookup_cancel (
   struct ANASTASIS_KeyShareLookupOperation *kslo);
 
+
 /**
  * Handle for a POST /truth operation.
  */
diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index 22634aa..8591cd8 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -727,7 +727,6 @@ ANASTASIS_TESTING_make_trait_challenge (unsigned int index,
  * @param challenge_ref reference to the recovery process
  * @param challenge_index defines the index of the trait to solve
  * @param answer to the challenge
- * @param answer_size size of the answer
  * @return the command
  */
 struct TALER_TESTING_Command
@@ -735,7 +734,6 @@ ANASTASIS_TESTING_cmd_challenge_answer (const char *label,
                                         unsigned int http_status,
                                         const char *challenge_ref,
                                         unsigned int challenge_index,
-                                        const void *answer,
-                                        size_t answer_size);
+                                        const char *answer);
 
 #endif
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 42c8e6b..73b1224 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -347,31 +347,19 @@ keyshare_lookup_cb (void *cls,
 }
 
 
-/**
- * Challenge answer from the user like input SMS pin. Is referenced to a 
challenge and
- * sends back an AnswerFeedback.
- *
- * @param challenge reference to the challenge which is answered
- * @param answer user input instruction defines which input is needed
- * @param answer_size size of the user answer
- * @param af reference to the answerfeedback which is passed back to the user
- * @param af_cls handle for the challenge answer struct
- */
 void
 ANASTASIS_challenge_answer (struct GNUNET_CURL_Context *ctx,
                             struct ANASTASIS_Challenge *c,
-                            const void *answer,
-                            size_t answer_size,
+                            const char *answer_str,
                             ANASTASIS_AnswerFeedback af,
                             void *af_cls)
 {
   c->af = af;
   c->ctx = ctx;
   c->af_cls = af_cls;
-  char *answer_str;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d challenge answer is %s\n", __FILE__, __LINE__,
-              (char *) answer);
+              answer_str);
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d challenge %s-%llu is solved with url %s \n", __FILE__,
@@ -381,25 +369,28 @@ ANASTASIS_challenge_answer (struct GNUNET_CURL_Context 
*ctx,
               c->url);
 
   c->http_status = MHD_HTTP_OK;
-  if (0 == strcmp (c->escrow_method,"question"))
+  if (0 == strcmp (c->escrow_method,
+                   "question"))
   {
-
     struct GNUNET_HashCode hashed_answer;
-    GNUNET_CRYPTO_hash (answer,
-                        answer_size,
+    char *str;
+
+    GNUNET_CRYPTO_hash (answer_str,
+                        strlen (answer_str),
                         &hashed_answer);
+    str = GNUNET_STRINGS_data_to_string_alloc (&hashed_answer,
+                                               sizeof (hashed_answer));
     c->kslo = ANASTASIS_keyshare_lookup (c->ctx,
                                          c->url,
                                          &c->truth_public_key,
                                          &c->truth_key,
-                                         answer_str,
+                                         str,
                                          &keyshare_lookup_cb,
                                          c);
+    GNUNET_free (str);
   }
   else
   {
-    answer_str = GNUNET_STRINGS_data_to_string_alloc (answer,
-                                                      answer_size);
     c->kslo = ANASTASIS_keyshare_lookup (c->ctx,
                                          c->url,
                                          &c->truth_public_key,
diff --git a/src/lib/test_anastasis.c b/src/lib/test_anastasis.c
index 1eb3dd9..9e047bf 100644
--- a/src/lib/test_anastasis.c
+++ b/src/lib/test_anastasis.c
@@ -303,20 +303,17 @@ run (void *cls,
                                             MHD_HTTP_OK,
                                             "recover-secret-1",
                                             0,
-                                            "HashOfSomeTruth1",
-                                            strlen ("HashOfSomeTruth1")),
+                                            "HashOfSomeTruth1"),
     ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-2",
                                             MHD_HTTP_OK,
                                             "recover-secret-1",
                                             1,
-                                            "HashOfSomeTruth2",
-                                            strlen ("HashOfSomeTruth2")),
+                                            "HashOfSomeTruth2"),
     ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-3",
                                             MHD_HTTP_OK,
                                             "recover-secret-1",
                                             2,
-                                            "HashOfSomeTruth3",
-                                            strlen ("HashOfSomeTruth3")),
+                                            "HashOfSomeTruth3"),
     TALER_TESTING_cmd_end ()
   };
 
diff --git a/src/lib/testing_api_cmd_truth_store.c 
b/src/lib/testing_api_cmd_truth_store.c
index 93789aa..13bd789 100644
--- a/src/lib/testing_api_cmd_truth_store.c
+++ b/src/lib/testing_api_cmd_truth_store.c
@@ -377,23 +377,21 @@ ANASTASIS_TESTING_make_truthkey (const char *key_str)
  * @return truth in json format
  */
 json_t *
-ANASTASIS_TESTING_make_truth_example (const char *method,
-                                      const char *mime_type,
-                                      const struct GNUNET_HashCode answer,
-                                      const struct
-                                      ANASTASIS_CRYPTO_TruthKeyP key)
+ANASTASIS_TESTING_make_truth_example (
+  const char *method,
+  const char *mime_type,
+  const struct GNUNET_HashCode answer, // FIXME: use pointer...
+  const struct ANASTASIS_CRYPTO_TruthKeyP key) // FIXME: use pointer...
 {
   json_t *truth_data;
   struct ANASTASIS_CRYPTO_EncryptedKeyShareP keyshare_data;
   void *encrypted_truth;
   size_t size_encrypted_truth;
 
-  GNUNET_assert (NULL != &answer);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d Hashed answer is %s-%llu b\n", __FILE__, __LINE__,
               TALER_B2S (&answer),
               (unsigned long long) sizeof (answer));
-  GNUNET_assert (NULL != &key);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d TruthKey is %s-%llu b\n", __FILE__, __LINE__,
               TALER_B2S (&key),
@@ -403,8 +401,6 @@ ANASTASIS_TESTING_make_truth_example (const char *method,
                               &keyshare_data,
                               sizeof (struct
                                       ANASTASIS_CRYPTO_EncryptedKeyShareP));
-  GNUNET_assert (NULL != &keyshare_data);
-
   ANASTASIS_CRYPTO_truth_encrypt (&key,
                                   &answer,
                                   sizeof (answer),
@@ -479,4 +475,4 @@ ANASTASIS_TESTING_cmd_truth_store (const char *label,
   };
 
   return cmd;
-}
\ No newline at end of file
+}
diff --git a/src/lib/testing_cmd_challenge_answer.c 
b/src/lib/testing_cmd_challenge_answer.c
index 1856eee..309dcaa 100644
--- a/src/lib/testing_cmd_challenge_answer.c
+++ b/src/lib/testing_cmd_challenge_answer.c
@@ -36,26 +36,27 @@ struct ChallengeState
    * The interpreter state.
    */
   struct TALER_TESTING_Interpreter *is;
+
   /**
    * Reference to the challenge we are solving
    */
   struct ANASTASIS_Challenge *c;
+
   /**
    * Expected status code.
    */
   unsigned int http_status;
+
   /**
    * Answer to the challenge we are solving
    */
-  const void *answer;
-  /**
-   * Size of the answer we are solving
-   */
-  size_t answer_size;
+  const char *answer;
+
   /**
    * Referenece to the recovery process
    */
   const char *challenge_ref;
+
   /**
    * Index of the challenge we are solving
    */
@@ -92,13 +93,13 @@ challenge_answer_run (void *cls,
   struct ChallengeState *cs = cls;
   const struct TALER_TESTING_Command *ref;
   const struct ANASTASIS_Challenge *c;
-  cs->is = is;
 
+  cs->is = is;
   if (NULL != cs->challenge_ref)
   {
-    ref = TALER_TESTING_interpreter_lookup_command
-            (is,
-            cs->challenge_ref);
+    ref = TALER_TESTING_interpreter_lookup_command (
+      is,
+      cs->challenge_ref);
     if (NULL == ref)
     {
       GNUNET_break (0);
@@ -119,7 +120,6 @@ challenge_answer_run (void *cls,
   ANASTASIS_challenge_answer (is->ctx,
                               (struct ANASTASIS_Challenge *) c,
                               cs->answer,
-                              cs->answer_size,
                               &challenge_answer_cb,
                               cs);
 }
@@ -157,8 +157,7 @@ ANASTASIS_TESTING_cmd_challenge_answer (const char *label,
                                         unsigned int http_status,
                                         const char *challenge_ref,
                                         unsigned int challenge_index,
-                                        const void *answer,
-                                        size_t answer_size)
+                                        const char *answer)
 {
   struct ChallengeState *cs;
 
@@ -167,17 +166,17 @@ ANASTASIS_TESTING_cmd_challenge_answer (const char *label,
   cs->challenge_ref = challenge_ref;
   cs->answer = answer;
   cs->challenge_index = challenge_index;
-  cs->answer_size = answer_size;
-
-  struct TALER_TESTING_Command cmd = {
-    .cls = cs,
-    .label = label,
-    .run = &challenge_answer_run,
-    .cleanup = &challenge_answer_cleanup,
-  };
-
-  return cmd;
+  {
+    struct TALER_TESTING_Command cmd = {
+      .cls = cs,
+      .label = label,
+      .run = &challenge_answer_run,
+      .cleanup = &challenge_answer_cleanup,
+    };
+
+    return cmd;
+  }
 }
 
 
-/* end of testing_cmd_challenge_answer.c */
\ No newline at end of file
+/* end of testing_cmd_challenge_answer.c */

-- 
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]