make version field const

This commit is contained in:
Christian Grothoff 2020-04-07 11:47:47 +02:00
parent 9eb741b05b
commit aa65247662
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 12 additions and 19 deletions

View File

@ -49,7 +49,7 @@ struct TALER_AUDITOR_VersionInformation
* semantics of GNU libtool. See
* https://www.gnu.org/software/libtool/manual/html_node/Versioning.html#Versioning
*/
char *version;
const char *version;
};

View File

@ -122,6 +122,11 @@ struct TALER_AUDITOR_Handle
* /version data of the auditor, only valid if
* @e handshake_complete is past stage #MHS_VERSION.
*/
char *version;
/**
* Version information for the callback.
*/
struct TALER_AUDITOR_VersionInformation vi;
/**
@ -177,19 +182,6 @@ free_version_request (struct VersionRequest *vr)
}
/**
* Free version data object.
*
* @param vi data to free (pointer itself excluded)
*/
static void
free_version_info (struct TALER_AUDITOR_VersionInformation *vi)
{
GNUNET_free_non_null (vi->version);
vi->version = NULL;
}
/**
* Decode the JSON in @a resp_obj from the /version response and store the data
* in the @a key_data.
@ -201,9 +193,10 @@ free_version_info (struct TALER_AUDITOR_VersionInformation *vi)
*/
static enum TALER_ErrorCode
decode_version_json (const json_t *resp_obj,
struct TALER_AUDITOR_VersionInformation *vi,
struct TALER_AUDITOR_Handle *auditor,
enum TALER_AUDITOR_VersionCompatibility *vc)
{
struct TALER_AUDITOR_VersionInformation *vi = &auditor->vi;
unsigned int age;
unsigned int revision;
unsigned int current;
@ -239,7 +232,8 @@ decode_version_json (const json_t *resp_obj,
GNUNET_break_op (0);
return TALER_EC_VERSION_MALFORMED;
}
vi->version = GNUNET_strdup (ver);
auditor->version = GNUNET_strdup (ver);
vi->version = auditor->version;
*vc = TALER_AUDITOR_VC_MATCH;
if (TALER_PROTOCOL_CURRENT < current)
{
@ -317,7 +311,7 @@ version_completed_cb (void *cls,
break;
}
hr.ec = decode_version_json (resp_obj,
&auditor->vi,
auditor,
&vc);
if (TALER_EC_NONE != hr.ec)
{
@ -345,7 +339,6 @@ version_completed_cb (void *cls,
auditor->vr = NULL;
free_version_request (vr);
auditor->state = MHS_FAILED;
free_version_info (&auditor->vi);
/* notify application that we failed */
auditor->version_cb (auditor->version_cb_cls,
&hr,
@ -532,7 +525,7 @@ TALER_AUDITOR_disconnect (struct TALER_AUDITOR_Handle *auditor)
free_version_request (auditor->vr);
auditor->vr = NULL;
}
free_version_info (&auditor->vi);
GNUNET_free_non_null (auditor->version);
if (NULL != auditor->retry_task)
{
GNUNET_SCHEDULER_cancel (auditor->retry_task);