qga: make build_fs_mount_list() return a bool

Change build_fs_mount_list() to return bool, in accordance
with the guidance under = Rules = in include/qapi/error.h

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Suggested-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20220525144140.591926-10-marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2022-05-25 16:41:34 +02:00
parent b9947c9ce7
commit 561bfcb69d

View File

@ -673,7 +673,7 @@ static int dev_major_minor(const char *devpath,
/*
* Walk the mount table and build a list of local file systems
*/
static void build_fs_mount_list_from_mtab(FsMountList *mounts, Error **errp)
static bool build_fs_mount_list_from_mtab(FsMountList *mounts, Error **errp)
{
struct mntent *ment;
FsMount *mount;
@ -684,7 +684,7 @@ static void build_fs_mount_list_from_mtab(FsMountList *mounts, Error **errp)
fp = setmntent(mtab, "r");
if (!fp) {
error_setg(errp, "failed to open mtab file: '%s'", mtab);
return;
return false;
}
while ((ment = getmntent(fp))) {
@ -714,6 +714,7 @@ static void build_fs_mount_list_from_mtab(FsMountList *mounts, Error **errp)
}
endmntent(fp);
return true;
}
static void decode_mntname(char *name, int len)
@ -738,7 +739,7 @@ static void decode_mntname(char *name, int len)
}
}
static void build_fs_mount_list(FsMountList *mounts, Error **errp)
static bool build_fs_mount_list(FsMountList *mounts, Error **errp)
{
FsMount *mount;
char const *mountinfo = "/proc/self/mountinfo";
@ -751,8 +752,7 @@ static void build_fs_mount_list(FsMountList *mounts, Error **errp)
fp = fopen(mountinfo, "r");
if (!fp) {
build_fs_mount_list_from_mtab(mounts, errp);
return;
return build_fs_mount_list_from_mtab(mounts, errp);
}
while (getline(&line, &n, fp) != -1) {
@ -794,6 +794,7 @@ static void build_fs_mount_list(FsMountList *mounts, Error **errp)
free(line);
fclose(fp);
return true;
}
#endif
@ -1592,8 +1593,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
Error *local_err = NULL;
QTAILQ_INIT(&mounts);
build_fs_mount_list(&mounts, &local_err);
if (local_err) {
if (!build_fs_mount_list(&mounts, &local_err)) {
error_propagate(errp, local_err);
return NULL;
}
@ -1716,8 +1716,7 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
}
QTAILQ_INIT(&mounts);
build_fs_mount_list(&mounts, &local_err);
if (local_err) {
if (!build_fs_mount_list(&mounts, &local_err)) {
error_propagate(errp, local_err);
return -1;
}
@ -1798,8 +1797,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **errp)
Error *local_err = NULL;
QTAILQ_INIT(&mounts);
build_fs_mount_list(&mounts, &local_err);
if (local_err) {
if (!build_fs_mount_list(&mounts, &local_err)) {
error_propagate(errp, local_err);
return 0;
}
@ -1872,15 +1870,12 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
FsMountList mounts;
struct FsMount *mount;
int fd;
Error *local_err = NULL;
struct fstrim_range r;
slog("guest-fstrim called");
QTAILQ_INIT(&mounts);
build_fs_mount_list(&mounts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
if (!build_fs_mount_list(&mounts, errp)) {
return NULL;
}