From: Krzysztof Kozlowski <krzk@kernel.org>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
qemu-devel@nongnu.org
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Subject: [Qemu-devel] [PATCH 1/2] char: Constify data pointed by few arguments and local variables
Date: Sun, 5 Mar 2017 23:45:29 +0200 [thread overview]
Message-ID: <20170305214530.19733-1-krzk@kernel.org> (raw)
In few places the function arguments and local variables are not
modifying data passed through pointers so this can be made const for
code safeness.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
chardev/char.c | 18 +++++++++---------
include/sysemu/char.h | 2 +-
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/chardev/char.c b/chardev/char.c
index 54cd5f408150..a2571409bf65 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -102,7 +102,7 @@ static void qemu_chr_fe_write_log(Chardev *s,
static int qemu_chr_fe_write_buffer(Chardev *s,
const uint8_t *buf, int len, int *offset)
{
- ChardevClass *cc = CHARDEV_GET_CLASS(s);
+ const ChardevClass *cc = CHARDEV_GET_CLASS(s);
int res = 0;
*offset = 0;
@@ -129,7 +129,7 @@ static int qemu_chr_fe_write_buffer(Chardev *s,
return res;
}
-static bool qemu_chr_replay(Chardev *chr)
+static bool qemu_chr_replay(const Chardev *chr)
{
return qemu_chr_has_feature(chr, QEMU_CHAR_FEATURE_REPLAY);
}
@@ -137,7 +137,7 @@ static bool qemu_chr_replay(Chardev *chr)
int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len)
{
Chardev *s = be->chr;
- ChardevClass *cc;
+ const ChardevClass *cc;
int ret;
if (!s) {
@@ -369,7 +369,7 @@ void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
static void qemu_char_open(Chardev *chr, ChardevBackend *backend,
bool *be_opened, Error **errp)
{
- ChardevClass *cc = CHARDEV_GET_CLASS(chr);
+ const ChardevClass *cc = CHARDEV_GET_CLASS(chr);
/* Any ChardevCommon member would work */
ChardevCommon *common = backend ? backend->u.null.data : NULL;
@@ -513,10 +513,10 @@ unavailable:
return false;
}
-static bool qemu_chr_is_busy(Chardev *s)
+static bool qemu_chr_is_busy(const Chardev *s)
{
if (CHARDEV_IS_MUX(s)) {
- MuxChardev *d = MUX_CHARDEV(s);
+ const MuxChardev *d = MUX_CHARDEV(s);
return d->mux_cnt >= 0;
} else {
return s->be != NULL;
@@ -549,7 +549,7 @@ void qemu_chr_fe_set_handlers(CharBackend *b,
bool set_open)
{
Chardev *s;
- ChardevClass *cc;
+ const ChardevClass *cc;
int fe_open;
s = b->chr;
@@ -603,7 +603,7 @@ void qemu_chr_fe_take_focus(CharBackend *b)
int qemu_chr_wait_connected(Chardev *chr, Error **errp)
{
- ChardevClass *cc = CHARDEV_GET_CLASS(chr);
+ const ChardevClass *cc = CHARDEV_GET_CLASS(chr);
if (cc->chr_wait_connected) {
return cc->chr_wait_connected(chr, errp);
@@ -1223,7 +1223,7 @@ QemuOptsList qemu_chardev_opts = {
},
};
-bool qemu_chr_has_feature(Chardev *chr,
+bool qemu_chr_has_feature(const Chardev *chr,
ChardevFeature feature)
{
return test_bit(feature, chr->features);
diff --git a/include/sysemu/char.h b/include/sysemu/char.h
index 450881d42cb5..2b11bbc40692 100644
--- a/include/sysemu/char.h
+++ b/include/sysemu/char.h
@@ -432,7 +432,7 @@ void qemu_chr_fe_accept_input(CharBackend *be);
int qemu_chr_add_client(Chardev *s, int fd);
Chardev *qemu_chr_find(const char *name);
-bool qemu_chr_has_feature(Chardev *chr,
+bool qemu_chr_has_feature(const Chardev *chr,
ChardevFeature feature);
void qemu_chr_set_feature(Chardev *chr,
ChardevFeature feature);
--
2.9.3
next reply other threads:[~2017-03-05 21:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-05 21:45 Krzysztof Kozlowski [this message]
2017-03-05 21:45 ` [Qemu-devel] [PATCH 2/2] char: Remove confusing mix of assignment with local variables Krzysztof Kozlowski
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=20170305214530.19733-1-krzk@kernel.org \
--to=krzk@kernel.org \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--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).