[epiphany/wip/sync] sync: Add const keyword before input parameters
- From: Gabriel Ivașcu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/sync] sync: Add const keyword before input parameters
- Date: Thu, 9 Mar 2017 17:44:38 +0000 (UTC)
commit c69bae33b2277f4538717e366479f99c4480d0b6
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date: Thu Mar 9 19:33:21 2017 +0200
sync: Add const keyword before input parameters
src/sync/ephy-sync-crypto.c | 66 ++++++++++++++++++++++-------------------
src/sync/ephy-sync-crypto.h | 12 ++++----
src/sync/ephy-sync-secret.c | 2 +-
src/sync/ephy-sync-service.c | 4 +-
src/sync/ephy-sync-service.h | 4 +-
src/sync/ephy-sync-utils.c | 4 +-
src/sync/ephy-sync-utils.h | 2 +-
7 files changed, 49 insertions(+), 45 deletions(-)
---
diff --git a/src/sync/ephy-sync-crypto.c b/src/sync/ephy-sync-crypto.c
index ec582a1..9697ca7 100644
--- a/src/sync/ephy-sync-crypto.c
+++ b/src/sync/ephy-sync-crypto.c
@@ -129,13 +129,13 @@ ephy_sync_crypto_hawk_artifacts_free (SyncCryptoHawkArtifacts *artifacts)
}
static SyncCryptoHawkHeader *
-ephy_sync_crypto_hawk_header_new (char *header,
+ephy_sync_crypto_hawk_header_new (const char *header,
SyncCryptoHawkArtifacts *artifacts)
{
SyncCryptoHawkHeader *hheader;
hheader = g_slice_new (SyncCryptoHawkHeader);
- hheader->header = header;
+ hheader->header = g_strdup (header);
hheader->artifacts = artifacts;
return hheader;
@@ -188,9 +188,9 @@ ephy_sync_crypto_kw (const char *name)
}
static guint8 *
-ephy_sync_crypto_xor (guint8 *a,
- guint8 *b,
- gsize length)
+ephy_sync_crypto_xor (const guint8 *a,
+ const guint8 *b,
+ gsize length)
{
guint8 *xored;
@@ -205,9 +205,9 @@ ephy_sync_crypto_xor (guint8 *a,
}
static gboolean
-ephy_sync_crypto_equals (guint8 *a,
- guint8 *b,
- gsize length)
+ephy_sync_crypto_equals (const guint8 *a,
+ const guint8 *b,
+ gsize length)
{
g_assert (a);
g_assert (b);
@@ -313,7 +313,7 @@ ephy_sync_crypto_calculate_payload_hash (const char *payload,
static char *
ephy_sync_crypto_calculate_mac (const char *type,
- guint8 *key,
+ const guint8 *key,
gsize key_len,
SyncCryptoHawkArtifacts *artifacts)
{
@@ -342,7 +342,7 @@ ephy_sync_crypto_calculate_mac (const char *type,
static char *
ephy_sync_crypto_append_to_header (char *header,
const char *name,
- char *value)
+ const char *value)
{
char *new_header;
char *tmp;
@@ -359,14 +359,14 @@ ephy_sync_crypto_append_to_header (char *header,
}
static void
-ephy_sync_crypto_hkdf (guint8 *in,
- gsize in_len,
- guint8 *salt,
- gsize salt_len,
- guint8 *info,
- gsize info_len,
- guint8 *out,
- gsize out_len)
+ephy_sync_crypto_hkdf (const guint8 *in,
+ gsize in_len,
+ guint8 *salt,
+ gsize salt_len,
+ const guint8 *info,
+ gsize info_len,
+ guint8 *out,
+ gsize out_len)
{
char *prk_hex;
char *tmp_hex;
@@ -651,12 +651,12 @@ ephy_sync_crypto_process_session_token (const char *sessionToken,
}
void
-ephy_sync_crypto_compute_sync_keys (const char *bundle,
- guint8 *respHMACkey,
- guint8 *respXORkey,
- guint8 *unwrapBKey,
- guint8 **kA,
- guint8 **kB)
+ephy_sync_crypto_compute_sync_keys (const char *bundle,
+ const guint8 *respHMACkey,
+ const guint8 *respXORkey,
+ const guint8 *unwrapBKey,
+ guint8 **kA,
+ guint8 **kB)
{
guint8 *bdl;
guint8 *ciphertext;
@@ -805,10 +805,11 @@ SyncCryptoHawkHeader *
ephy_sync_crypto_compute_hawk_header (const char *url,
const char *method,
const char *id,
- guint8 *key,
+ const guint8 *key,
gsize key_len,
SyncCryptoHawkOptions *options)
{
+ SyncCryptoHawkHeader *hheader;
SyncCryptoHawkArtifacts *artifacts;
SoupURI *uri;
char *resource;
@@ -906,13 +907,16 @@ ephy_sync_crypto_compute_hawk_header (const char *url,
header = ephy_sync_crypto_append_to_header (header, "dlg", artifacts->dlg);
}
+ hheader = ephy_sync_crypto_hawk_header_new (header, artifacts);
+
soup_uri_free (uri);
g_free (hash);
g_free (mac);
g_free (nonce);
g_free (resource);
+ g_free (header);
- return ephy_sync_crypto_hawk_header_new (header, artifacts);
+ return hheader;
}
SyncCryptoRSAKeyPair *
@@ -1041,9 +1045,9 @@ ephy_sync_crypto_random_hex_gen (void *ctx,
}
char *
-ephy_sync_crypto_base64_urlsafe_encode (guint8 *data,
- gsize data_len,
- gboolean strip)
+ephy_sync_crypto_base64_urlsafe_encode (const guint8 *data,
+ gsize data_len,
+ gboolean strip)
{
char *base64;
char *out;
@@ -1144,8 +1148,8 @@ ephy_sync_crypto_aes_256 (SyncCryptoAES256Mode mode,
}
char *
-ephy_sync_crypto_encode_hex (guint8 *data,
- gsize data_len)
+ephy_sync_crypto_encode_hex (const guint8 *data,
+ gsize data_len)
{
char *retval;
gsize length;
diff --git a/src/sync/ephy-sync-crypto.h b/src/sync/ephy-sync-crypto.h
index 31985ef..334bf71 100644
--- a/src/sync/ephy-sync-crypto.h
+++ b/src/sync/ephy-sync-crypto.h
@@ -89,9 +89,9 @@ void ephy_sync_crypto_process_session_token (const char
guint8 **reqHMACkey,
guint8 **requestKey);
void ephy_sync_crypto_compute_sync_keys (const char *bundle,
- guint8 *respHMACkey,
- guint8 *respXORkey,
- guint8 *unwrapBKey,
+ const guint8 *respHMACkey,
+ const guint8 *respXORkey,
+ const guint8 *unwrapBKey,
guint8 **kA,
guint8 **kB);
void ephy_sync_crypto_derive_master_keys (const guint8 *kB,
@@ -106,7 +106,7 @@ char *ephy_sync_crypto_decrypt_record (const char
SyncCryptoHawkHeader *ephy_sync_crypto_compute_hawk_header (const char *url,
const char *method,
const char *id,
- guint8 *key,
+ const guint8 *key,
gsize key_len,
SyncCryptoHawkOptions *options);
SyncCryptoRSAKeyPair *ephy_sync_crypto_generate_rsa_key_pair (void);
@@ -117,7 +117,7 @@ char *ephy_sync_crypto_create_assertion (const char
void ephy_sync_crypto_random_hex_gen (void *ctx,
gsize length,
guint8 *dst);
-char *ephy_sync_crypto_base64_urlsafe_encode (guint8 *data,
+char *ephy_sync_crypto_base64_urlsafe_encode (const guint8 *data,
gsize data_len,
gboolean strip);
guint8 *ephy_sync_crypto_base64_urlsafe_decode (const char *text,
@@ -128,7 +128,7 @@ guint8 *ephy_sync_crypto_aes_256 (SyncCryptoAES
const guint8 *data,
gsize data_len,
gsize *out_len);
-char *ephy_sync_crypto_encode_hex (guint8 *data,
+char *ephy_sync_crypto_encode_hex (const guint8 *data,
gsize data_len);
guint8 *ephy_sync_crypto_decode_hex (const char *hex);
diff --git a/src/sync/ephy-sync-secret.c b/src/sync/ephy-sync-secret.c
index b7b1640..1a2ba2e 100644
--- a/src/sync/ephy-sync-secret.c
+++ b/src/sync/ephy-sync-secret.c
@@ -90,7 +90,7 @@ load_tokens_cb (SecretService *service,
GError *ret_error = NULL;
const char *tokens;
const char *email;
- char *user_email;
+ const char *user_email;
matches = secret_service_search_finish (service, result, &error);
diff --git a/src/sync/ephy-sync-service.c b/src/sync/ephy-sync-service.c
index 27d2040..cc73349 100644
--- a/src/sync/ephy-sync-service.c
+++ b/src/sync/ephy-sync-service.c
@@ -705,7 +705,7 @@ ephy_sync_service_is_signed_in (EphySyncService *self)
return self->user_email != NULL;
}
-char *
+const char *
ephy_sync_service_get_user_email (EphySyncService *self)
{
g_return_val_if_fail (EPHY_IS_SYNC_SERVICE (self), NULL);
@@ -746,7 +746,7 @@ ephy_sync_service_set_sync_time (EphySyncService *self,
g_settings_set_double (EPHY_SETTINGS_MAIN, EPHY_PREFS_SYNC_TIME, time);
}
-char *
+const char *
ephy_sync_service_get_token (EphySyncService *self,
EphySyncTokenType type)
{
diff --git a/src/sync/ephy-sync-service.h b/src/sync/ephy-sync-service.h
index 2f46478..e459b4f 100644
--- a/src/sync/ephy-sync-service.h
+++ b/src/sync/ephy-sync-service.h
@@ -34,13 +34,13 @@ G_DECLARE_FINAL_TYPE (EphySyncService, ephy_sync_service, EPHY, SYNC_SERVICE, GO
EphySyncService *ephy_sync_service_new (void);
gboolean ephy_sync_service_is_signed_in (EphySyncService *self);
-char *ephy_sync_service_get_user_email (EphySyncService *self);
+const char *ephy_sync_service_get_user_email (EphySyncService *self);
void ephy_sync_service_set_user_email (EphySyncService *self,
const char *email);
double ephy_sync_service_get_sync_time (EphySyncService *self);
void ephy_sync_service_set_sync_time (EphySyncService *self,
double time);
-char *ephy_sync_service_get_token (EphySyncService *self,
+const char *ephy_sync_service_get_token (EphySyncService *self,
EphySyncTokenType type);
void ephy_sync_service_set_token (EphySyncService *self,
const char *value,
diff --git a/src/sync/ephy-sync-utils.c b/src/sync/ephy-sync-utils.c
index a590e87..b5efc8a 100644
--- a/src/sync/ephy-sync-utils.c
+++ b/src/sync/ephy-sync-utils.c
@@ -157,8 +157,8 @@ ephy_sync_utils_find_and_replace (const char *src,
}
guint8 *
-ephy_sync_utils_concatenate_bytes (guint8 *bytes,
- gsize bytes_len,
+ephy_sync_utils_concatenate_bytes (const guint8 *bytes,
+ gsize bytes_len,
...)
{
va_list args;
diff --git a/src/sync/ephy-sync-utils.h b/src/sync/ephy-sync-utils.h
index 50f3ec2..883689d 100644
--- a/src/sync/ephy-sync-utils.h
+++ b/src/sync/ephy-sync-utils.h
@@ -43,7 +43,7 @@ EphySyncTokenType ephy_sync_utils_token_type_from_name (const char *na
char *ephy_sync_utils_find_and_replace (const char *src,
const char *find,
const char *repl);
-guint8 *ephy_sync_utils_concatenate_bytes (guint8 *bytes,
+guint8 *ephy_sync_utils_concatenate_bytes (const guint8 *bytes,
gsize bytes_len,
...) G_GNUC_NULL_TERMINATED;
gint64 ephy_sync_utils_current_time_seconds (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]