Skip to content

Commit

Permalink
qapi: Mechanically convert FOO_lookup[...] to FOO_str(...)
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-14-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
  • Loading branch information
Markus Armbruster committed Sep 4, 2017
1 parent 5b5f825 commit 977c736
Show file tree
Hide file tree
Showing 45 changed files with 121 additions and 121 deletions.
2 changes: 1 addition & 1 deletion backends/hostmem.c
Expand Up @@ -304,7 +304,7 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
return;
} else if (maxnode == 0 && backend->policy != MPOL_DEFAULT) {
error_setg(errp, "host-nodes must be set for policy %s",
HostMemPolicy_lookup[backend->policy]);
HostMemPolicy_str(backend->policy));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion block/backup.c
Expand Up @@ -596,7 +596,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
error_setg(errp,
"a sync_bitmap was provided to backup_run, "
"but received an incompatible sync_mode (%s)",
MirrorSyncMode_lookup[sync_mode]);
MirrorSyncMode_str(sync_mode));
return NULL;
}

Expand Down
4 changes: 2 additions & 2 deletions block/file-posix.c
Expand Up @@ -1724,7 +1724,7 @@ static int raw_regular_truncate(int fd, int64_t offset, PreallocMode prealloc,
default:
result = -ENOTSUP;
error_setg(errp, "Unsupported preallocation mode: %s",
PreallocMode_lookup[prealloc]);
PreallocMode_str(prealloc));
return result;
}

Expand Down Expand Up @@ -1759,7 +1759,7 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset,

if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Preallocation mode '%s' unsupported for this "
"non-regular file", PreallocMode_lookup[prealloc]);
"non-regular file", PreallocMode_str(prealloc));
return -ENOTSUP;
}

Expand Down
2 changes: 1 addition & 1 deletion block/file-win32.c
Expand Up @@ -469,7 +469,7 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset,

if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
PreallocMode_lookup[prealloc]);
PreallocMode_str(prealloc));
return -ENOTSUP;
}

Expand Down
4 changes: 2 additions & 2 deletions block/gluster.c
Expand Up @@ -1047,7 +1047,7 @@ static int qemu_gluster_create(const char *filename,
default:
ret = -EINVAL;
error_setg(errp, "Unsupported preallocation mode: %s",
PreallocMode_lookup[prealloc]);
PreallocMode_str(prealloc));
break;
}

Expand Down Expand Up @@ -1099,7 +1099,7 @@ static int qemu_gluster_truncate(BlockDriverState *bs, int64_t offset,

if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
PreallocMode_lookup[prealloc]);
PreallocMode_str(prealloc));
return -ENOTSUP;
}

Expand Down
2 changes: 1 addition & 1 deletion block/iscsi.c
Expand Up @@ -2087,7 +2087,7 @@ static int iscsi_truncate(BlockDriverState *bs, int64_t offset,

if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
PreallocMode_lookup[prealloc]);
PreallocMode_str(prealloc));
return -ENOTSUP;
}

Expand Down
2 changes: 1 addition & 1 deletion block/nfs.c
Expand Up @@ -772,7 +772,7 @@ static int nfs_file_truncate(BlockDriverState *bs, int64_t offset,

if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
PreallocMode_lookup[prealloc]);
PreallocMode_str(prealloc));
return -ENOTSUP;
}

Expand Down
4 changes: 2 additions & 2 deletions block/qcow2.c
Expand Up @@ -2715,7 +2715,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,
int64_t prealloc_size =
qcow2_calc_prealloc_size(total_size, cluster_size, refcount_order);
qemu_opt_set_number(opts, BLOCK_OPT_SIZE, prealloc_size, &error_abort);
qemu_opt_set(opts, BLOCK_OPT_PREALLOC, PreallocMode_lookup[prealloc],
qemu_opt_set(opts, BLOCK_OPT_PREALLOC, PreallocMode_str(prealloc),
&error_abort);
}

Expand Down Expand Up @@ -3080,7 +3080,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
prealloc != PREALLOC_MODE_FALLOC && prealloc != PREALLOC_MODE_FULL)
{
error_setg(errp, "Unsupported preallocation mode '%s'",
PreallocMode_lookup[prealloc]);
PreallocMode_str(prealloc));
return -ENOTSUP;
}

Expand Down
2 changes: 1 addition & 1 deletion block/qed.c
Expand Up @@ -1399,7 +1399,7 @@ static int bdrv_qed_truncate(BlockDriverState *bs, int64_t offset,

if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
PreallocMode_lookup[prealloc]);
PreallocMode_str(prealloc));
return -ENOTSUP;
}

Expand Down
2 changes: 1 addition & 1 deletion block/rbd.c
Expand Up @@ -944,7 +944,7 @@ static int qemu_rbd_truncate(BlockDriverState *bs, int64_t offset,

if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
PreallocMode_lookup[prealloc]);
PreallocMode_str(prealloc));
return -ENOTSUP;
}

Expand Down
2 changes: 1 addition & 1 deletion block/sheepdog.c
Expand Up @@ -2176,7 +2176,7 @@ static int sd_truncate(BlockDriverState *bs, int64_t offset,

if (prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Unsupported preallocation mode '%s'",
PreallocMode_lookup[prealloc]);
PreallocMode_str(prealloc));
return -ENOTSUP;
}

Expand Down
4 changes: 2 additions & 2 deletions blockdev.c
Expand Up @@ -1466,8 +1466,8 @@ static int action_check_completion_mode(BlkActionState *s, Error **errp)
error_setg(errp,
"Action '%s' does not support Transaction property "
"completion-mode = %s",
TransactionActionKind_lookup[s->action->type],
ActionCompletionMode_lookup[s->txn_props->completion_mode]);
TransactionActionKind_str(s->action->type),
ActionCompletionMode_str(s->txn_props->completion_mode));
return -1;
}
return 0;
Expand Down
6 changes: 3 additions & 3 deletions blockjob.c
Expand Up @@ -208,7 +208,7 @@ static char *child_job_get_parent_desc(BdrvChild *c)
{
BlockJob *job = c->opaque;
return g_strdup_printf("%s job '%s'",
BlockJobType_lookup[job->driver->job_type],
BlockJobType_str(job->driver->job_type),
job->id);
}

Expand Down Expand Up @@ -553,7 +553,7 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp)
return NULL;
}
info = g_new0(BlockJobInfo, 1);
info->type = g_strdup(BlockJobType_lookup[job->driver->job_type]);
info->type = g_strdup(BlockJobType_str(job->driver->job_type));
info->device = g_strdup(job->id);
info->len = job->len;
info->busy = job->busy;
Expand Down Expand Up @@ -666,7 +666,7 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
job->refcnt = 1;

error_setg(&job->blocker, "block device is in use by block job: %s",
BlockJobType_lookup[driver->job_type]);
BlockJobType_str(driver->job_type));
block_job_add_bdrv(job, "main node", bs, 0, BLK_PERM_ALL, &error_abort);
bs->job = job;

Expand Down
4 changes: 2 additions & 2 deletions chardev/char.c
Expand Up @@ -931,7 +931,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,
ChardevReturn *ret;
Chardev *chr;

cc = char_get_class(ChardevBackendKind_lookup[backend->type], errp);
cc = char_get_class(ChardevBackendKind_str(backend->type), errp);
if (!cc) {
return NULL;
}
Expand Down Expand Up @@ -989,7 +989,7 @@ ChardevReturn *qmp_chardev_change(const char *id, ChardevBackend *backend,
return NULL;
}

cc = char_get_class(ChardevBackendKind_lookup[backend->type], errp);
cc = char_get_class(ChardevBackendKind_str(backend->type), errp);
if (!cc) {
return NULL;
}
Expand Down
12 changes: 6 additions & 6 deletions crypto/block-luks.c
Expand Up @@ -257,7 +257,7 @@ qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgorithm alg,
}

error_setg(errp, "Algorithm '%s' not supported",
QCryptoCipherAlgorithm_lookup[alg]);
QCryptoCipherAlgorithm_str(alg));
return NULL;
}

Expand Down Expand Up @@ -392,7 +392,7 @@ qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm cipher,
break;
default:
error_setg(errp, "Cipher %s not supported with essiv",
QCryptoCipherAlgorithm_lookup[cipher]);
QCryptoCipherAlgorithm_str(cipher));
return 0;
}
}
Expand Down Expand Up @@ -962,16 +962,16 @@ qcrypto_block_luks_create(QCryptoBlock *block,
goto error;
}

cipher_mode = QCryptoCipherMode_lookup[luks_opts.cipher_mode];
ivgen_alg = QCryptoIVGenAlgorithm_lookup[luks_opts.ivgen_alg];
cipher_mode = QCryptoCipherMode_str(luks_opts.cipher_mode);
ivgen_alg = QCryptoIVGenAlgorithm_str(luks_opts.ivgen_alg);
if (luks_opts.has_ivgen_hash_alg) {
ivgen_hash_alg = QCryptoHashAlgorithm_lookup[luks_opts.ivgen_hash_alg];
ivgen_hash_alg = QCryptoHashAlgorithm_str(luks_opts.ivgen_hash_alg);
cipher_mode_spec = g_strdup_printf("%s-%s:%s", cipher_mode, ivgen_alg,
ivgen_hash_alg);
} else {
cipher_mode_spec = g_strdup_printf("%s-%s", cipher_mode, ivgen_alg);
}
hash_alg = QCryptoHashAlgorithm_lookup[luks_opts.hash_alg];
hash_alg = QCryptoHashAlgorithm_str(luks_opts.hash_alg);


if (strlen(cipher_alg) >= QCRYPTO_BLOCK_LUKS_CIPHER_NAME_LEN) {
Expand Down
4 changes: 2 additions & 2 deletions crypto/block.c
Expand Up @@ -61,7 +61,7 @@ QCryptoBlock *qcrypto_block_open(QCryptoBlockOpenOptions *options,
if (options->format >= G_N_ELEMENTS(qcrypto_block_drivers) ||
!qcrypto_block_drivers[options->format]) {
error_setg(errp, "Unsupported block driver %s",
QCryptoBlockFormat_lookup[options->format]);
QCryptoBlockFormat_str(options->format));
g_free(block);
return NULL;
}
Expand Down Expand Up @@ -92,7 +92,7 @@ QCryptoBlock *qcrypto_block_create(QCryptoBlockCreateOptions *options,
if (options->format >= G_N_ELEMENTS(qcrypto_block_drivers) ||
!qcrypto_block_drivers[options->format]) {
error_setg(errp, "Unsupported block driver %s",
QCryptoBlockFormat_lookup[options->format]);
QCryptoBlockFormat_str(options->format));
g_free(block);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/cipher-afalg.c
Expand Up @@ -52,7 +52,7 @@ qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm alg,
return NULL;
}

mode_name = QCryptoCipherMode_lookup[mode];
mode_name = QCryptoCipherMode_str(mode);
name = g_strdup_printf("%s(%s)", mode_name, alg_name);

return name;
Expand Down
8 changes: 4 additions & 4 deletions crypto/cipher-builtin.c
Expand Up @@ -247,7 +247,7 @@ qcrypto_cipher_init_aes(QCryptoCipherMode mode,
mode != QCRYPTO_CIPHER_MODE_ECB &&
mode != QCRYPTO_CIPHER_MODE_XTS) {
error_setg(errp, "Unsupported cipher mode %s",
QCryptoCipherMode_lookup[mode]);
QCryptoCipherMode_str(mode));
return NULL;
}

Expand Down Expand Up @@ -379,7 +379,7 @@ qcrypto_cipher_init_des_rfb(QCryptoCipherMode mode,

if (mode != QCRYPTO_CIPHER_MODE_ECB) {
error_setg(errp, "Unsupported cipher mode %s",
QCryptoCipherMode_lookup[mode]);
QCryptoCipherMode_str(mode));
return NULL;
}

Expand Down Expand Up @@ -440,7 +440,7 @@ static QCryptoCipherBuiltin *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
break;
default:
error_setg(errp, "Unsupported cipher mode %s",
QCryptoCipherMode_lookup[mode]);
QCryptoCipherMode_str(mode));
return NULL;
}

Expand All @@ -460,7 +460,7 @@ static QCryptoCipherBuiltin *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
default:
error_setg(errp,
"Unsupported cipher algorithm %s",
QCryptoCipherAlgorithm_lookup[alg]);
QCryptoCipherAlgorithm_str(alg));
return NULL;
}

Expand Down
4 changes: 2 additions & 2 deletions crypto/cipher-gcrypt.c
Expand Up @@ -105,7 +105,7 @@ static QCryptoCipherGcrypt *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
break;
default:
error_setg(errp, "Unsupported cipher mode %s",
QCryptoCipherMode_lookup[mode]);
QCryptoCipherMode_str(mode));
return NULL;
}

Expand Down Expand Up @@ -160,7 +160,7 @@ static QCryptoCipherGcrypt *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,

default:
error_setg(errp, "Unsupported cipher algorithm %s",
QCryptoCipherAlgorithm_lookup[alg]);
QCryptoCipherAlgorithm_str(alg));
return NULL;
}

Expand Down
8 changes: 4 additions & 4 deletions crypto/cipher-nettle.c
Expand Up @@ -281,7 +281,7 @@ static QCryptoCipherNettle *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
break;
default:
error_setg(errp, "Unsupported cipher mode %s",
QCryptoCipherMode_lookup[mode]);
QCryptoCipherMode_str(mode));
return NULL;
}

Expand Down Expand Up @@ -420,7 +420,7 @@ static QCryptoCipherNettle *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,

default:
error_setg(errp, "Unsupported cipher algorithm %s",
QCryptoCipherAlgorithm_lookup[alg]);
QCryptoCipherAlgorithm_str(alg));
goto error;
}

Expand Down Expand Up @@ -491,7 +491,7 @@ qcrypto_nettle_cipher_encrypt(QCryptoCipher *cipher,

default:
error_setg(errp, "Unsupported cipher mode %s",
QCryptoCipherMode_lookup[cipher->mode]);
QCryptoCipherMode_str(cipher->mode));
return -1;
}
return 0;
Expand Down Expand Up @@ -537,7 +537,7 @@ qcrypto_nettle_cipher_decrypt(QCryptoCipher *cipher,

default:
error_setg(errp, "Unsupported cipher mode %s",
QCryptoCipherMode_lookup[cipher->mode]);
QCryptoCipherMode_str(cipher->mode));
return -1;
}
return 0;
Expand Down
2 changes: 1 addition & 1 deletion crypto/hmac-gcrypt.c
Expand Up @@ -52,7 +52,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg,

if (!qcrypto_hmac_supports(alg)) {
error_setg(errp, "Unsupported hmac algorithm %s",
QCryptoHashAlgorithm_lookup[alg]);
QCryptoHashAlgorithm_str(alg));
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion crypto/hmac-glib.c
Expand Up @@ -58,7 +58,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg,

if (!qcrypto_hmac_supports(alg)) {
error_setg(errp, "Unsupported hmac algorithm %s",
QCryptoHashAlgorithm_lookup[alg]);
QCryptoHashAlgorithm_str(alg));
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion crypto/hmac-nettle.c
Expand Up @@ -106,7 +106,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg,

if (!qcrypto_hmac_supports(alg)) {
error_setg(errp, "Unsupported hmac algorithm %s",
QCryptoHashAlgorithm_lookup[alg]);
QCryptoHashAlgorithm_str(alg));
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion crypto/pbkdf-gcrypt.c
Expand Up @@ -68,7 +68,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash,
hash_map[hash] == GCRY_MD_NONE) {
error_setg_errno(errp, ENOSYS,
"PBKDF does not support hash algorithm %s",
QCryptoHashAlgorithm_lookup[hash]);
QCryptoHashAlgorithm_str(hash));
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion crypto/pbkdf-nettle.c
Expand Up @@ -110,7 +110,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash,
default:
error_setg_errno(errp, ENOSYS,
"PBKDF does not support hash algorithm %s",
QCryptoHashAlgorithm_lookup[hash]);
QCryptoHashAlgorithm_str(hash));
return -1;
}
return 0;
Expand Down

0 comments on commit 977c736

Please sign in to comment.