error: Move ERRP_GUARD() to the beginning of the function

Since the commit 05e385d2a9 ("error: Move ERRP_GUARD() to the beginning
of the function"), there are new codes that don't put ERRP_GUARD() at
the beginning of the functions.

As stated in the commit 05e385d2a9: "include/qapi/error.h advises to put
ERRP_GUARD() right at the beginning of the function, because only then
can it guard the whole function.", so clean up the few spots
disregarding the advice.

Inspired-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240312060337.3240965-1-zhao1.liu@linux.intel.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Zhao Liu 2024-03-12 14:03:37 +08:00 committed by Thomas Huth
parent 95e9053a34
commit 46ff64a826
6 changed files with 9 additions and 10 deletions

View File

@ -534,9 +534,9 @@ typedef struct CreateCo {
int coroutine_fn bdrv_co_create(BlockDriver *drv, const char *filename, int coroutine_fn bdrv_co_create(BlockDriver *drv, const char *filename,
QemuOpts *opts, Error **errp) QemuOpts *opts, Error **errp)
{ {
ERRP_GUARD();
int ret; int ret;
GLOBAL_STATE_CODE(); GLOBAL_STATE_CODE();
ERRP_GUARD();
if (!drv->bdrv_co_create_opts) { if (!drv->bdrv_co_create_opts) {
error_setg(errp, "Driver '%s' does not support image creation", error_setg(errp, "Driver '%s' does not support image creation",

View File

@ -46,11 +46,11 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
bool flat, bool flat,
Error **errp) Error **errp)
{ {
ERRP_GUARD();
ImageInfo **p_image_info; ImageInfo **p_image_info;
ImageInfo *backing_info; ImageInfo *backing_info;
BlockDriverState *backing; BlockDriverState *backing;
BlockDeviceInfo *info; BlockDeviceInfo *info;
ERRP_GUARD();
if (!bs->drv) { if (!bs->drv) {
error_setg(errp, "Block device %s is ejected", bs->node_name); error_setg(errp, "Block device %s is ejected", bs->node_name);
@ -330,8 +330,8 @@ void bdrv_query_image_info(BlockDriverState *bs,
bool skip_implicit_filters, bool skip_implicit_filters,
Error **errp) Error **errp)
{ {
ImageInfo *info;
ERRP_GUARD(); ERRP_GUARD();
ImageInfo *info;
info = g_new0(ImageInfo, 1); info = g_new0(ImageInfo, 1);
bdrv_do_query_node_info(bs, qapi_ImageInfo_base(info), errp); bdrv_do_query_node_info(bs, qapi_ImageInfo_base(info), errp);
@ -382,10 +382,10 @@ void bdrv_query_block_graph_info(BlockDriverState *bs,
BlockGraphInfo **p_info, BlockGraphInfo **p_info,
Error **errp) Error **errp)
{ {
ERRP_GUARD();
BlockGraphInfo *info; BlockGraphInfo *info;
BlockChildInfoList **children_list_tail; BlockChildInfoList **children_list_tail;
BdrvChild *c; BdrvChild *c;
ERRP_GUARD();
info = g_new0(BlockGraphInfo, 1); info = g_new0(BlockGraphInfo, 1);
bdrv_do_query_node_info(bs, qapi_BlockGraphInfo_base(info), errp); bdrv_do_query_node_info(bs, qapi_BlockGraphInfo_base(info), errp);

View File

@ -312,9 +312,9 @@ static void ccw_init(MachineState *machine)
static void s390_cpu_plug(HotplugHandler *hotplug_dev, static void s390_cpu_plug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp) DeviceState *dev, Error **errp)
{ {
ERRP_GUARD();
MachineState *ms = MACHINE(hotplug_dev); MachineState *ms = MACHINE(hotplug_dev);
S390CPU *cpu = S390_CPU(dev); S390CPU *cpu = S390_CPU(dev);
ERRP_GUARD();
g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu); g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu);
ms->possible_cpus->cpus[cpu->env.core_id].cpu = OBJECT(dev); ms->possible_cpus->cpus[cpu->env.core_id].cpu = OBJECT(dev);

View File

@ -478,9 +478,9 @@ static bool migrate_incoming_started(void)
*/ */
bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp) bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)
{ {
ERRP_GUARD();
MigrationIncomingState *mis = migration_incoming_get_current(); MigrationIncomingState *mis = migration_incoming_get_current();
ERRP_GUARD();
#ifndef CONFIG_LIVE_BLOCK_MIGRATION #ifndef CONFIG_LIVE_BLOCK_MIGRATION
if (new_caps[MIGRATION_CAPABILITY_BLOCK]) { if (new_caps[MIGRATION_CAPABILITY_BLOCK]) {
error_setg(errp, "QEMU compiled without old-style (blk/-b, inc/-i) " error_setg(errp, "QEMU compiled without old-style (blk/-b, inc/-i) "

View File

@ -283,10 +283,10 @@ static bool request_ufd_features(int ufd, uint64_t features)
static bool ufd_check_and_apply(int ufd, MigrationIncomingState *mis, static bool ufd_check_and_apply(int ufd, MigrationIncomingState *mis,
Error **errp) Error **errp)
{ {
ERRP_GUARD();
uint64_t asked_features = 0; uint64_t asked_features = 0;
static uint64_t supported_features; static uint64_t supported_features;
ERRP_GUARD();
/* /*
* it's not possible to * it's not possible to
* request UFFD_API twice per one fd * request UFFD_API twice per one fd
@ -371,6 +371,7 @@ static int test_ramblock_postcopiable(RAMBlock *rb, Error **errp)
*/ */
bool postcopy_ram_supported_by_host(MigrationIncomingState *mis, Error **errp) bool postcopy_ram_supported_by_host(MigrationIncomingState *mis, Error **errp)
{ {
ERRP_GUARD();
long pagesize = qemu_real_host_page_size(); long pagesize = qemu_real_host_page_size();
int ufd = -1; int ufd = -1;
bool ret = false; /* Error unless we change it */ bool ret = false; /* Error unless we change it */
@ -380,7 +381,6 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis, Error **errp)
uint64_t feature_mask; uint64_t feature_mask;
RAMBlock *block; RAMBlock *block;
ERRP_GUARD();
if (qemu_target_page_size() > pagesize) { if (qemu_target_page_size() > pagesize) {
error_setg(errp, "Target page size bigger than host page size"); error_setg(errp, "Target page size bigger than host page size");
goto out; goto out;

View File

@ -1557,14 +1557,13 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops = {
static int vhost_vdpa_probe_cvq_isolation(int device_fd, uint64_t features, static int vhost_vdpa_probe_cvq_isolation(int device_fd, uint64_t features,
int cvq_index, Error **errp) int cvq_index, Error **errp)
{ {
ERRP_GUARD();
uint64_t backend_features; uint64_t backend_features;
int64_t cvq_group; int64_t cvq_group;
uint8_t status = VIRTIO_CONFIG_S_ACKNOWLEDGE | uint8_t status = VIRTIO_CONFIG_S_ACKNOWLEDGE |
VIRTIO_CONFIG_S_DRIVER; VIRTIO_CONFIG_S_DRIVER;
int r; int r;
ERRP_GUARD();
r = ioctl(device_fd, VHOST_GET_BACKEND_FEATURES, &backend_features); r = ioctl(device_fd, VHOST_GET_BACKEND_FEATURES, &backend_features);
if (unlikely(r < 0)) { if (unlikely(r < 0)) {
error_setg_errno(errp, errno, "Cannot get vdpa backend_features"); error_setg_errno(errp, errno, "Cannot get vdpa backend_features");