mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-15 04:40:05 +01:00
Fix C std23 related warnings with new glibc.
C standard library functions now preserves qualifiers passed to some functions. In case of strchr() if the passed argument is const qualified also the returned value is const qualified. Similarly if the passed argument is not const qualified neither is the return value. This patch makes libcryptsetup compliant with the change and should be backward compatible with older std libraries. Thanks Vojta Trefny for heads-up.
This commit is contained in:
@@ -77,7 +77,7 @@ static int crypt_sector_iv_init(struct crypt_sector_iv *ctx,
|
||||
ctx->type = IV_PLAIN;
|
||||
} else if (!strncasecmp(iv_name, "essiv:", 6)) {
|
||||
struct crypt_hash *h = NULL;
|
||||
char *hash_name = strchr(iv_name, ':');
|
||||
const char *hash_name = strchr(iv_name, ':');
|
||||
int hash_size;
|
||||
char tmp[256];
|
||||
|
||||
|
||||
@@ -3287,7 +3287,7 @@ int dm_is_dm_kernel_name(const char *name)
|
||||
int dm_uuid_cmp(const char *dm_uuid, const char *hdr_uuid)
|
||||
{
|
||||
int i, j;
|
||||
char *str;
|
||||
const char *str;
|
||||
|
||||
if (!dm_uuid || !hdr_uuid)
|
||||
return -EINVAL;
|
||||
@@ -3322,7 +3322,7 @@ int dm_uuid_cmp(const char *dm_uuid, const char *hdr_uuid)
|
||||
int dm_uuid_integrity_cmp(const char *dm_uuid, const char *dmi_uuid)
|
||||
{
|
||||
int i;
|
||||
char *str, *stri;
|
||||
const char *str, *stri;
|
||||
|
||||
if (!dm_uuid || !dmi_uuid)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
static void _error_hint(struct crypt_device *ctx, const char *device,
|
||||
const char *cipher, const char *mode, size_t keyLength)
|
||||
{
|
||||
char *c, cipher_spec[MAX_CIPHER_LEN * 3];
|
||||
const char *c;
|
||||
char cipher_spec[MAX_CIPHER_LEN * 3];
|
||||
|
||||
if (snprintf(cipher_spec, sizeof(cipher_spec), "%s-%s", cipher, mode) < 0)
|
||||
return;
|
||||
|
||||
@@ -1002,8 +1002,10 @@ static int TCRYPT_status_one(struct crypt_device *cd, const char *name,
|
||||
{
|
||||
struct crypt_dm_active_device dmd;
|
||||
struct dm_target *tgt = &dmd.segment;
|
||||
char dm_name[PATH_MAX], *c;
|
||||
const char *c;
|
||||
char dm_name[PATH_MAX];
|
||||
int r;
|
||||
size_t cipher_len = MAX_CIPHER_LEN;
|
||||
|
||||
if (snprintf(dm_name, sizeof(dm_name), "%s_%d", name, index) < 0)
|
||||
return -ENOMEM;
|
||||
@@ -1027,9 +1029,9 @@ static int TCRYPT_status_one(struct crypt_device *cd, const char *name,
|
||||
|
||||
if (is_tcrypt_subdev(dmd.uuid, base_uuid)) {
|
||||
if ((c = strchr(tgt->u.crypt.cipher, '-')))
|
||||
*c = '\0';
|
||||
cipher_len = c - tgt->u.crypt.cipher;
|
||||
strcat(cipher, "-");
|
||||
strncat(cipher, tgt->u.crypt.cipher, MAX_CIPHER_LEN);
|
||||
strncat(cipher, tgt->u.crypt.cipher, cipher_len);
|
||||
*key_size += crypt_volume_key_length(tgt->u.crypt.vk);
|
||||
tcrypt_hdr->d.mk_offset = tgt->u.crypt.offset * SECTOR_SIZE;
|
||||
device_free(cd, *device);
|
||||
|
||||
@@ -299,7 +299,8 @@ const char *key_type_name(key_type_t type)
|
||||
|
||||
key_type_t keyring_type_and_name(const char *key_name, const char **name)
|
||||
{
|
||||
char type[16], *name_tmp;
|
||||
const char *name_tmp;
|
||||
char type[16];
|
||||
size_t type_len;
|
||||
|
||||
if (!key_name || key_name[0] != '%')
|
||||
|
||||
Reference in New Issue
Block a user