qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>, Greg Kurz <groug@kaod.org>
Subject: [PULL v2 3/8] fsdev: Add return value to fsdev_throttle_parse_opts()
Date: Thu, 10 Oct 2019 15:18:04 +0200	[thread overview]
Message-ID: <20191010131809.1284004-4-groug@kaod.org> (raw)
In-Reply-To: <20191010131809.1284004-1-groug@kaod.org>

It is more convenient to use the return value of the function to notify
errors, rather than to be tied up setting up the &local_err boilerplate.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 fsdev/qemu-fsdev-throttle.c | 4 ++--
 fsdev/qemu-fsdev-throttle.h | 2 +-
 hw/9pfs/9p-local.c          | 3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c
index fe1d76dc76e7..5c83a1cc09c3 100644
--- a/fsdev/qemu-fsdev-throttle.c
+++ b/fsdev/qemu-fsdev-throttle.c
@@ -31,7 +31,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque)
     qemu_co_enter_next(&fst->throttled_reqs[true], NULL);
 }
 
-void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp)
+int fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp)
 {
     throttle_config_init(&fst->cfg);
     fst->cfg.buckets[THROTTLE_BPS_TOTAL].avg =
@@ -75,7 +75,7 @@ void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp)
     fst->cfg.op_size =
         qemu_opt_get_number(opts, "throttling.iops-size", 0);
 
-    throttle_is_valid(&fst->cfg, errp);
+    return throttle_is_valid(&fst->cfg, errp) ? 0 : -1;
 }
 
 void fsdev_throttle_init(FsThrottle *fst)
diff --git a/fsdev/qemu-fsdev-throttle.h b/fsdev/qemu-fsdev-throttle.h
index c98e2feab553..a21aecddc734 100644
--- a/fsdev/qemu-fsdev-throttle.h
+++ b/fsdev/qemu-fsdev-throttle.h
@@ -26,7 +26,7 @@ typedef struct FsThrottle {
     CoQueue      throttled_reqs[2];
 } FsThrottle;
 
-void fsdev_throttle_parse_opts(QemuOpts *, FsThrottle *, Error **);
+int fsdev_throttle_parse_opts(QemuOpts *, FsThrottle *, Error **);
 
 void fsdev_throttle_init(FsThrottle *);
 
diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index 6f7309f4e691..5c7f4cd9c7b0 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -1511,8 +1511,7 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
         return -1;
     }
 
-    fsdev_throttle_parse_opts(opts, &fse->fst, &local_err);
-    if (local_err) {
+    if (fsdev_throttle_parse_opts(opts, &fse->fst, &local_err)) {
         error_propagate_prepend(errp, local_err,
                                 "invalid throttle configuration: ");
         return -1;
-- 
2.21.0



  parent reply	other threads:[~2019-10-10 13:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10 13:18 [PULL v2 0/8] 9p patches 2019-10-10 Greg Kurz
2019-10-10 13:18 ` [PULL v2 1/8] 9p: unsigned type for type, version, path Greg Kurz
2019-10-10 13:18 ` [PULL v2 2/8] 9p: Simplify error path of v9fs_device_realize_common() Greg Kurz
2019-10-10 13:18 ` Greg Kurz [this message]
2019-10-10 13:18 ` [PULL v2 4/8] 9p: Treat multiple devices on one export as an error Greg Kurz
2019-10-10 13:18 ` [PULL v2 5/8] 9p: Added virtfs option 'multidevs=remap|forbid|warn' Greg Kurz
2019-10-10 13:18 ` [PULL v2 6/8] 9p: stat_to_qid: implement slow path Greg Kurz
2019-10-10 13:18 ` [PULL v2 7/8] 9p: Use variable length suffixes for inode remapping Greg Kurz
2019-10-10 13:18 ` [PULL v2 8/8] MAINTAINERS: Downgrade status of virtio-9p to "Odd Fixes" Greg Kurz
2019-10-14 14:08 ` [PULL v2 0/8] 9p patches 2019-10-10 Peter Maydell
2019-10-14 15:46   ` Greg Kurz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191010131809.1284004-4-groug@kaod.org \
    --to=groug@kaod.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).