* [Qemu-devel] [PATCH v2 0/2] qdev: Minor const improvements @ 2017-03-10 20:05 Krzysztof Kozlowski 2017-03-10 20:05 ` [Qemu-devel] [PATCH v2 1/2] qdev: Constify value passed to qdev_prop_set_macaddr Krzysztof Kozlowski 2017-03-10 20:05 ` [Qemu-devel] [PATCH v2 2/2] qdev: Constify local variable returned by blk_bs Krzysztof Kozlowski 0 siblings, 2 replies; 5+ messages in thread From: Krzysztof Kozlowski @ 2017-03-10 20:05 UTC (permalink / raw) To: Eduardo Habkost, qemu-devel Cc: Paolo Bonzini, qemu-trivial, Krzysztof Kozlowski Hi, Minor improvements. Changes since v1: 1. Follow suggestions from v1 discussion - drop other consts. Best regards, Krzysztof Krzysztof Kozlowski (2): qdev: Constify value passed to qdev_prop_set_macaddr qdev: Constify local variable returned by blk_bs hw/core/qdev-properties-system.c | 2 +- hw/core/qdev-properties.c | 3 ++- include/hw/qdev-properties.h | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) -- 2.9.3 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 1/2] qdev: Constify value passed to qdev_prop_set_macaddr 2017-03-10 20:05 [Qemu-devel] [PATCH v2 0/2] qdev: Minor const improvements Krzysztof Kozlowski @ 2017-03-10 20:05 ` Krzysztof Kozlowski 2017-03-13 18:07 ` Eduardo Habkost 2017-03-10 20:05 ` [Qemu-devel] [PATCH v2 2/2] qdev: Constify local variable returned by blk_bs Krzysztof Kozlowski 1 sibling, 1 reply; 5+ messages in thread From: Krzysztof Kozlowski @ 2017-03-10 20:05 UTC (permalink / raw) To: Eduardo Habkost, qemu-devel Cc: Paolo Bonzini, qemu-trivial, Krzysztof Kozlowski The 'value' argument is not modified so this can be made const for code safeness. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> --- hw/core/qdev-properties.c | 3 ++- include/hw/qdev-properties.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 6ab4265eb478..fa3617db2df1 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1010,7 +1010,8 @@ void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value) object_property_set_str(OBJECT(dev), value, name, &error_abort); } -void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value) +void qdev_prop_set_macaddr(DeviceState *dev, const char *name, + const uint8_t *value) { char str[2 * 6 + 5 + 1]; snprintf(str, sizeof(str), "%02x:%02x:%02x:%02x:%02x:%02x", diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 7ac315331aa0..1d69fa7a8f04 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -188,7 +188,8 @@ void qdev_prop_set_chr(DeviceState *dev, const char *name, Chardev *value); void qdev_prop_set_netdev(DeviceState *dev, const char *name, NetClientState *value); void qdev_prop_set_drive(DeviceState *dev, const char *name, BlockBackend *value, Error **errp); -void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value); +void qdev_prop_set_macaddr(DeviceState *dev, const char *name, + const uint8_t *value); void qdev_prop_set_enum(DeviceState *dev, const char *name, int value); /* FIXME: Remove opaque pointer properties. */ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value); -- 2.9.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/2] qdev: Constify value passed to qdev_prop_set_macaddr 2017-03-10 20:05 ` [Qemu-devel] [PATCH v2 1/2] qdev: Constify value passed to qdev_prop_set_macaddr Krzysztof Kozlowski @ 2017-03-13 18:07 ` Eduardo Habkost 0 siblings, 0 replies; 5+ messages in thread From: Eduardo Habkost @ 2017-03-13 18:07 UTC (permalink / raw) To: Krzysztof Kozlowski; +Cc: qemu-devel, Paolo Bonzini, qemu-trivial On Fri, Mar 10, 2017 at 10:05:49PM +0200, Krzysztof Kozlowski wrote: > The 'value' argument is not modified so this can be made const for code > safeness. > > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Unless another maintainer wants to take this, I am queueing it for 2.10 on my machine-next branch. > --- > hw/core/qdev-properties.c | 3 ++- > include/hw/qdev-properties.h | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c > index 6ab4265eb478..fa3617db2df1 100644 > --- a/hw/core/qdev-properties.c > +++ b/hw/core/qdev-properties.c > @@ -1010,7 +1010,8 @@ void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value) > object_property_set_str(OBJECT(dev), value, name, &error_abort); > } > > -void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value) > +void qdev_prop_set_macaddr(DeviceState *dev, const char *name, > + const uint8_t *value) > { > char str[2 * 6 + 5 + 1]; > snprintf(str, sizeof(str), "%02x:%02x:%02x:%02x:%02x:%02x", > diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h > index 7ac315331aa0..1d69fa7a8f04 100644 > --- a/include/hw/qdev-properties.h > +++ b/include/hw/qdev-properties.h > @@ -188,7 +188,8 @@ void qdev_prop_set_chr(DeviceState *dev, const char *name, Chardev *value); > void qdev_prop_set_netdev(DeviceState *dev, const char *name, NetClientState *value); > void qdev_prop_set_drive(DeviceState *dev, const char *name, > BlockBackend *value, Error **errp); > -void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value); > +void qdev_prop_set_macaddr(DeviceState *dev, const char *name, > + const uint8_t *value); > void qdev_prop_set_enum(DeviceState *dev, const char *name, int value); > /* FIXME: Remove opaque pointer properties. */ > void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value); > -- > 2.9.3 > -- Eduardo ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 2/2] qdev: Constify local variable returned by blk_bs 2017-03-10 20:05 [Qemu-devel] [PATCH v2 0/2] qdev: Minor const improvements Krzysztof Kozlowski 2017-03-10 20:05 ` [Qemu-devel] [PATCH v2 1/2] qdev: Constify value passed to qdev_prop_set_macaddr Krzysztof Kozlowski @ 2017-03-10 20:05 ` Krzysztof Kozlowski 2017-03-13 18:08 ` Eduardo Habkost 1 sibling, 1 reply; 5+ messages in thread From: Krzysztof Kozlowski @ 2017-03-10 20:05 UTC (permalink / raw) To: Eduardo Habkost, qemu-devel Cc: Paolo Bonzini, qemu-trivial, Krzysztof Kozlowski Inside qdev_prop_set_drive() the value returned by blk_bs() is passed only as pointer to const to bdrv_get_node_name() and pointed values is not modified in other places so this can be made const for code safeness. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> --- hw/core/qdev-properties-system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index c34be1c1bace..0d40ce682d05 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -405,7 +405,7 @@ void qdev_prop_set_drive(DeviceState *dev, const char *name, if (value) { ref = blk_name(value); if (!*ref) { - BlockDriverState *bs = blk_bs(value); + const BlockDriverState *bs = blk_bs(value); if (bs) { ref = bdrv_get_node_name(bs); } -- 2.9.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/2] qdev: Constify local variable returned by blk_bs 2017-03-10 20:05 ` [Qemu-devel] [PATCH v2 2/2] qdev: Constify local variable returned by blk_bs Krzysztof Kozlowski @ 2017-03-13 18:08 ` Eduardo Habkost 0 siblings, 0 replies; 5+ messages in thread From: Eduardo Habkost @ 2017-03-13 18:08 UTC (permalink / raw) To: Krzysztof Kozlowski; +Cc: qemu-devel, Paolo Bonzini, qemu-trivial On Fri, Mar 10, 2017 at 10:05:50PM +0200, Krzysztof Kozlowski wrote: > Inside qdev_prop_set_drive() the value returned by blk_bs() is passed > only as pointer to const to bdrv_get_node_name() and pointed values is > not modified in other places so this can be made const for code > safeness. > > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Unless another maintainer wants to take this, I am queueing it for 2.10 on my machine-next branch. > --- > hw/core/qdev-properties-system.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c > index c34be1c1bace..0d40ce682d05 100644 > --- a/hw/core/qdev-properties-system.c > +++ b/hw/core/qdev-properties-system.c > @@ -405,7 +405,7 @@ void qdev_prop_set_drive(DeviceState *dev, const char *name, > if (value) { > ref = blk_name(value); > if (!*ref) { > - BlockDriverState *bs = blk_bs(value); > + const BlockDriverState *bs = blk_bs(value); > if (bs) { > ref = bdrv_get_node_name(bs); > } > -- > 2.9.3 > -- Eduardo ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-03-13 18:09 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-03-10 20:05 [Qemu-devel] [PATCH v2 0/2] qdev: Minor const improvements Krzysztof Kozlowski 2017-03-10 20:05 ` [Qemu-devel] [PATCH v2 1/2] qdev: Constify value passed to qdev_prop_set_macaddr Krzysztof Kozlowski 2017-03-13 18:07 ` Eduardo Habkost 2017-03-10 20:05 ` [Qemu-devel] [PATCH v2 2/2] qdev: Constify local variable returned by blk_bs Krzysztof Kozlowski 2017-03-13 18:08 ` Eduardo Habkost
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).