All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: Constify data passed by pointer to blk_name
@ 2017-03-05 21:44 Krzysztof Kozlowski
  2017-03-05 21:58 ` Philippe Mathieu-Daudé
  2017-03-07 13:49 ` Kevin Wolf
  0 siblings, 2 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2017-03-05 21:44 UTC (permalink / raw)
  To: Kevin Wolf, Max Reitz, qemu-block, qemu-devel; +Cc: Krzysztof Kozlowski

blk_name() is not modifying data passed to it through pointer and it
returns also a pointer to const so the argument can be made const for
code safeness.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 block/block-backend.c          | 2 +-
 include/sysemu/block-backend.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/block-backend.c b/block/block-backend.c
index daa7908d0151..2d2169a5dfb0 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -409,7 +409,7 @@ void monitor_remove_blk(BlockBackend *blk)
  * Return @blk's name, a non-null string.
  * Returns an empty string iff @blk is not referenced by the monitor.
  */
-const char *blk_name(BlockBackend *blk)
+const char *blk_name(const BlockBackend *blk)
 {
     return blk->name ?: "";
 }
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 096c17fce064..d16c85d67b5c 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -91,7 +91,7 @@ int blk_get_refcnt(BlockBackend *blk);
 void blk_ref(BlockBackend *blk);
 void blk_unref(BlockBackend *blk);
 void blk_remove_all_bs(void);
-const char *blk_name(BlockBackend *blk);
+const char *blk_name(const BlockBackend *blk);
 BlockBackend *blk_by_name(const char *name);
 BlockBackend *blk_next(BlockBackend *blk);
 bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] block: Constify data passed by pointer to blk_name
  2017-03-05 21:44 [Qemu-devel] [PATCH] block: Constify data passed by pointer to blk_name Krzysztof Kozlowski
@ 2017-03-05 21:58 ` Philippe Mathieu-Daudé
  2017-03-07 13:49 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-03-05 21:58 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Kevin Wolf, Max Reitz, qemu-block, qemu-devel

On 03/05/2017 06:44 PM, Krzysztof Kozlowski wrote:
> blk_name() is not modifying data passed to it through pointer and it
> returns also a pointer to const so the argument can be made const for
> code safeness.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  block/block-backend.c          | 2 +-
>  include/sysemu/block-backend.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/block-backend.c b/block/block-backend.c
> index daa7908d0151..2d2169a5dfb0 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -409,7 +409,7 @@ void monitor_remove_blk(BlockBackend *blk)
>   * Return @blk's name, a non-null string.
>   * Returns an empty string iff @blk is not referenced by the monitor.
>   */
> -const char *blk_name(BlockBackend *blk)
> +const char *blk_name(const BlockBackend *blk)
>  {
>      return blk->name ?: "";
>  }
> diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
> index 096c17fce064..d16c85d67b5c 100644
> --- a/include/sysemu/block-backend.h
> +++ b/include/sysemu/block-backend.h
> @@ -91,7 +91,7 @@ int blk_get_refcnt(BlockBackend *blk);
>  void blk_ref(BlockBackend *blk);
>  void blk_unref(BlockBackend *blk);
>  void blk_remove_all_bs(void);
> -const char *blk_name(BlockBackend *blk);
> +const char *blk_name(const BlockBackend *blk);
>  BlockBackend *blk_by_name(const char *name);
>  BlockBackend *blk_next(BlockBackend *blk);
>  bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp);
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] block: Constify data passed by pointer to blk_name
  2017-03-05 21:44 [Qemu-devel] [PATCH] block: Constify data passed by pointer to blk_name Krzysztof Kozlowski
  2017-03-05 21:58 ` Philippe Mathieu-Daudé
@ 2017-03-07 13:49 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2017-03-07 13:49 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: Max Reitz, qemu-block, qemu-devel

Am 05.03.2017 um 22:44 hat Krzysztof Kozlowski geschrieben:
> blk_name() is not modifying data passed to it through pointer and it
> returns also a pointer to const so the argument can be made const for
> code safeness.
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

Thanks, applied to block-next for qemu 2.10.

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-07 13:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-05 21:44 [Qemu-devel] [PATCH] block: Constify data passed by pointer to blk_name Krzysztof Kozlowski
2017-03-05 21:58 ` Philippe Mathieu-Daudé
2017-03-07 13:49 ` Kevin Wolf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.