mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Always use json-c types in internal code.
Sometimes we used "struct json_foo_bar" and sometimes "json_foo_bar" json-c defined type. Stick with one notation in internal code.
This commit is contained in:
committed by
Milan Broz
parent
b36d4be8fa
commit
917b6836a9
@@ -15,7 +15,7 @@ static json_object *parse_json_len(struct crypt_device *cd, const char *json_are
|
|||||||
uint64_t max_length, int *json_len)
|
uint64_t max_length, int *json_len)
|
||||||
{
|
{
|
||||||
json_object *jobj;
|
json_object *jobj;
|
||||||
struct json_tokener *jtok;
|
json_tokener *jtok;
|
||||||
|
|
||||||
/* INT32_MAX is internal (json-c) json_tokener_parse_ex() limit */
|
/* INT32_MAX is internal (json-c) json_tokener_parse_ex() limit */
|
||||||
if (!json_area || max_length > INT32_MAX)
|
if (!json_area || max_length > INT32_MAX)
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ int LUKS2_generate_hdr(
|
|||||||
uint32_t opal_segment_number,
|
uint32_t opal_segment_number,
|
||||||
uint32_t opal_key_size)
|
uint32_t opal_key_size)
|
||||||
{
|
{
|
||||||
struct json_object *jobj_segment, *jobj_keyslots, *jobj_segments, *jobj_config;
|
json_object *jobj_segment, *jobj_keyslots, *jobj_segments, *jobj_config;
|
||||||
uuid_t partitionUuid;
|
uuid_t partitionUuid;
|
||||||
int r, digest;
|
int r, digest;
|
||||||
|
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ void JSON_DBG(struct crypt_device *cd, json_object *jobj, const char *desc)
|
|||||||
/*
|
/*
|
||||||
* JSON array helpers
|
* JSON array helpers
|
||||||
*/
|
*/
|
||||||
struct json_object *LUKS2_array_jobj(struct json_object *array, const char *num)
|
json_object *LUKS2_array_jobj(json_object *array, const char *num)
|
||||||
{
|
{
|
||||||
struct json_object *jobj1;
|
json_object *jobj1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < (int) json_object_array_length(array); i++) {
|
for (i = 0; i < (int) json_object_array_length(array); i++) {
|
||||||
@@ -63,9 +63,9 @@ struct json_object *LUKS2_array_jobj(struct json_object *array, const char *num)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct json_object *LUKS2_array_remove(struct json_object *array, const char *num)
|
json_object *LUKS2_array_remove(json_object *array, const char *num)
|
||||||
{
|
{
|
||||||
struct json_object *jobj1, *jobj_removing = NULL, *array_new;
|
json_object *jobj1, *jobj_removing = NULL, *array_new;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
jobj_removing = LUKS2_array_jobj(array, num);
|
jobj_removing = LUKS2_array_jobj(array, num);
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ out:
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int json_luks1_keyslot(const struct luks_phdr *hdr_v1, int keyslot, struct json_object **keyslot_object)
|
static int json_luks1_keyslot(const struct luks_phdr *hdr_v1, int keyslot, json_object **keyslot_object)
|
||||||
{
|
{
|
||||||
char *base64_str, cipher[LUKS_CIPHERNAME_L+LUKS_CIPHERMODE_L];
|
char *base64_str, cipher[LUKS_CIPHERNAME_L+LUKS_CIPHERMODE_L];
|
||||||
size_t base64_len;
|
size_t base64_len;
|
||||||
struct json_object *keyslot_obj, *field, *jobj_kdf, *jobj_af, *jobj_area;
|
json_object *keyslot_obj, *field, *jobj_kdf, *jobj_af, *jobj_area;
|
||||||
uint64_t offset, area_size, length;
|
uint64_t offset, area_size, length;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@@ -136,10 +136,10 @@ err:
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int json_luks1_keyslots(const struct luks_phdr *hdr_v1, struct json_object **keyslots_object)
|
static int json_luks1_keyslots(const struct luks_phdr *hdr_v1, json_object **keyslots_object)
|
||||||
{
|
{
|
||||||
int keyslot, r;
|
int keyslot, r;
|
||||||
struct json_object *keyslot_obj, *field;
|
json_object *keyslot_obj, *field;
|
||||||
|
|
||||||
keyslot_obj = json_object_new_object();
|
keyslot_obj = json_object_new_object();
|
||||||
if (!keyslot_obj)
|
if (!keyslot_obj)
|
||||||
@@ -165,11 +165,11 @@ static int json_luks1_keyslots(const struct luks_phdr *hdr_v1, struct json_objec
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int json_luks1_segment(const struct luks_phdr *hdr_v1, struct json_object **segment_object)
|
static int json_luks1_segment(const struct luks_phdr *hdr_v1, json_object **segment_object)
|
||||||
{
|
{
|
||||||
const char *c;
|
const char *c;
|
||||||
char cipher[LUKS_CIPHERNAME_L+LUKS_CIPHERMODE_L];
|
char cipher[LUKS_CIPHERNAME_L+LUKS_CIPHERMODE_L];
|
||||||
struct json_object *segment_obj, *field;
|
json_object *segment_obj, *field;
|
||||||
uint64_t number;
|
uint64_t number;
|
||||||
|
|
||||||
segment_obj = json_object_new_object();
|
segment_obj = json_object_new_object();
|
||||||
@@ -239,10 +239,10 @@ static int json_luks1_segment(const struct luks_phdr *hdr_v1, struct json_object
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int json_luks1_segments(const struct luks_phdr *hdr_v1, struct json_object **segments_object)
|
static int json_luks1_segments(const struct luks_phdr *hdr_v1, json_object **segments_object)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
struct json_object *segments_obj, *field;
|
json_object *segments_obj, *field;
|
||||||
|
|
||||||
segments_obj = json_object_new_object();
|
segments_obj = json_object_new_object();
|
||||||
if (!segments_obj)
|
if (!segments_obj)
|
||||||
@@ -264,12 +264,12 @@ static int json_luks1_segments(const struct luks_phdr *hdr_v1, struct json_objec
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int json_luks1_digest(const struct luks_phdr *hdr_v1, struct json_object **digest_object)
|
static int json_luks1_digest(const struct luks_phdr *hdr_v1, json_object **digest_object)
|
||||||
{
|
{
|
||||||
char keyslot_str[16], *base64_str;
|
char keyslot_str[16], *base64_str;
|
||||||
int r, ks;
|
int r, ks;
|
||||||
size_t base64_len;
|
size_t base64_len;
|
||||||
struct json_object *digest_obj, *array, *field;
|
json_object *digest_obj, *array, *field;
|
||||||
|
|
||||||
digest_obj = json_object_new_object();
|
digest_obj = json_object_new_object();
|
||||||
if (!digest_obj)
|
if (!digest_obj)
|
||||||
@@ -380,10 +380,10 @@ static int json_luks1_digest(const struct luks_phdr *hdr_v1, struct json_object
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int json_luks1_digests(const struct luks_phdr *hdr_v1, struct json_object **digests_object)
|
static int json_luks1_digests(const struct luks_phdr *hdr_v1, json_object **digests_object)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
struct json_object *digests_obj, *field;
|
json_object *digests_obj, *field;
|
||||||
|
|
||||||
digests_obj = json_object_new_object();
|
digests_obj = json_object_new_object();
|
||||||
if (!digests_obj)
|
if (!digests_obj)
|
||||||
@@ -400,10 +400,10 @@ static int json_luks1_digests(const struct luks_phdr *hdr_v1, struct json_object
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int json_luks1_object(struct luks_phdr *hdr_v1, struct json_object **luks1_object, uint64_t keyslots_size)
|
static int json_luks1_object(struct luks_phdr *hdr_v1, json_object **luks1_object, uint64_t keyslots_size)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
struct json_object *luks1_obj, *field;
|
json_object *luks1_obj, *field;
|
||||||
uint64_t json_size;
|
uint64_t json_size;
|
||||||
|
|
||||||
luks1_obj = json_object_new_object();
|
luks1_obj = json_object_new_object();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ struct luks2_reencrypt {
|
|||||||
|
|
||||||
/* already running reencryption */
|
/* already running reencryption */
|
||||||
json_object *jobj_segs_hot;
|
json_object *jobj_segs_hot;
|
||||||
struct json_object *jobj_segs_post;
|
json_object *jobj_segs_post;
|
||||||
|
|
||||||
/* backup segments */
|
/* backup segments */
|
||||||
json_object *jobj_segment_new;
|
json_object *jobj_segment_new;
|
||||||
|
|||||||
Reference in New Issue
Block a user