aboutsummaryrefslogtreecommitdiff
path: root/qga/commands-posix.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2022-11-04 17:07:11 +0100
committerMarkus Armbruster <armbru@redhat.com>2022-12-14 20:05:07 +0100
commit91eab32a3fcc14d3243cbd1c97f022796d4063e6 (patch)
tree633c10253ce9680e320a418dc13b3cd6b159a840 /qga/commands-posix.c
parent41462e41063c019df13e52735eae7197205a4b67 (diff)
downloadqemu-91eab32a3fcc14d3243cbd1c97f022796d4063e6.zip
qemu-91eab32a3fcc14d3243cbd1c97f022796d4063e6.tar.gz
qemu-91eab32a3fcc14d3243cbd1c97f022796d4063e6.tar.bz2
qapi qga: Elide redundant has_FOO in generated C
The has_FOO for pointer-valued FOO are redundant, except for arrays. They are also a nuisance to work with. Recent commit "qapi: Start to elide redundant has_FOO in generated C" provided the means to elide them step by step. This is the step for qga/qapi-schema.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Michael Roth <michael.roth@amd.com> Cc: Konstantin Kostiuk <kkostiuk@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20221104160712.3005652-30-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'qga/commands-posix.c')
-rw-r--r--qga/commands-posix.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 32493d6..1a28326 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -71,7 +71,7 @@ static void ga_wait_child(pid_t pid, int *status, Error **errp)
g_assert(rpid == pid);
}
-void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
+void qmp_guest_shutdown(const char *mode, Error **errp)
{
const char *shutdown_flag;
Error *local_err = NULL;
@@ -93,7 +93,7 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
#endif
slog("guest-shutdown called, mode: %s", mode);
- if (!has_mode || strcmp(mode, "powerdown") == 0) {
+ if (!mode || strcmp(mode, "powerdown") == 0) {
shutdown_flag = powerdown_flag;
} else if (strcmp(mode, "halt") == 0) {
shutdown_flag = halt_flag;
@@ -404,14 +404,14 @@ end:
return f;
}
-int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode,
+int64_t qmp_guest_file_open(const char *path, const char *mode,
Error **errp)
{
FILE *fh;
Error *local_err = NULL;
int64_t handle;
- if (!has_mode) {
+ if (!mode) {
mode = "r";
}
slog("guest-file-open called, filepath: %s, mode: %s", path, mode);
@@ -1037,7 +1037,6 @@ static bool build_guest_fsinfo_for_ccw_dev(char const *syspath,
return false;
}
- disk->has_ccw_address = true;
disk->ccw_address = g_new0(GuestCCWAddress, 1);
disk->ccw_address->cssid = cssid;
disk->ccw_address->ssid = ssid;
@@ -1084,12 +1083,10 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
devnode = udev_device_get_devnode(udevice);
if (devnode != NULL) {
disk->dev = g_strdup(devnode);
- disk->has_dev = true;
}
serial = udev_device_get_property_value(udevice, "ID_SERIAL");
if (serial != NULL && *serial != 0) {
disk->serial = g_strdup(serial);
- disk->has_serial = true;
}
}
@@ -1108,7 +1105,7 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
has_hwinf = false;
}
- if (has_hwinf || disk->has_dev || disk->has_serial) {
+ if (has_hwinf || disk->dev || disk->serial) {
QAPI_LIST_PREPEND(fs->disk, disk);
} else {
qapi_free_GuestDiskAddress(disk);
@@ -1411,7 +1408,6 @@ static void get_nvme_smart(GuestDiskInfo *disk)
return;
}
- disk->has_smart = true;
disk->smart = g_new0(GuestDiskSmart, 1);
disk->smart->type = GUEST_DISK_BUS_TYPE_NVME;
@@ -1449,7 +1445,7 @@ static void get_nvme_smart(GuestDiskInfo *disk)
static void get_disk_smart(GuestDiskInfo *disk)
{
- if (disk->has_address
+ if (disk->address
&& (disk->address->bus_type == GUEST_DISK_BUS_TYPE_NVME)) {
get_nvme_smart(disk);
}
@@ -1502,7 +1498,6 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
disk->name = dev_name;
disk->partition = false;
disk->alias = get_alias_for_syspath(disk_dir);
- disk->has_alias = (disk->alias != NULL);
QAPI_LIST_PREPEND(ret, disk);
/* Get address for non-virtual devices */
@@ -1522,8 +1517,6 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
error_get_pretty(local_err));
error_free(local_err);
local_err = NULL;
- } else if (disk->address != NULL) {
- disk->has_address = true;
}
}
@@ -1641,7 +1634,6 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
if (fd == -1) {
result->error = g_strdup_printf("failed to open: %s",
strerror(errno));
- result->has_error = true;
continue;
}
@@ -1656,7 +1648,6 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
r.minlen = has_minimum ? minimum : 0;
ret = ioctl(fd, FITRIM, &r);
if (ret == -1) {
- result->has_error = true;
if (errno == ENOTTY || errno == EOPNOTSUPP) {
result->error = g_strdup("trim not supported");
} else {
@@ -2967,7 +2958,7 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
QAPI_LIST_APPEND(tail, info);
}
- if (!info->has_hardware_address) {
+ if (!info->hardware_address) {
if (!guest_get_hw_addr(ifa, mac_addr, &obtained, errp)) {
goto error;
}
@@ -2977,7 +2968,6 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
(int) mac_addr[0], (int) mac_addr[1],
(int) mac_addr[2], (int) mac_addr[3],
(int) mac_addr[4], (int) mac_addr[5]);
- info->has_hardware_address = true;
}
}
@@ -3037,14 +3027,12 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
info->has_ip_addresses = true;
- if (!info->has_statistics) {
+ if (!info->statistics) {
interface_stat = g_malloc0(sizeof(*interface_stat));
if (guest_get_network_stats(info->name, interface_stat) == -1) {
- info->has_statistics = false;
g_free(interface_stat);
} else {
info->statistics = interface_stat;
- info->has_statistics = true;
}
}
}
@@ -3351,11 +3339,8 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
if (uname(&kinfo) != 0) {
error_setg_errno(errp, errno, "uname failed");
} else {
- info->has_kernel_version = true;
info->kernel_version = g_strdup(kinfo.version);
- info->has_kernel_release = true;
info->kernel_release = g_strdup(kinfo.release);
- info->has_machine = true;
info->machine = g_strdup(kinfo.machine);
}
@@ -3375,7 +3360,6 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
value = g_key_file_get_value(osrelease, "os-release", osfield, NULL); \
if (value != NULL) { \
ga_osrelease_replace_special(value); \
- info->has_ ## field = true; \
info->field = value; \
} \
} while (0)