block: Constify data passed by pointer to blk_name
authorKrzysztof Kozlowski <krzk@kernel.org>
Sun, 5 Mar 2017 21:44:35 +0000 (23:44 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 27 Apr 2017 13:39:49 +0000 (15:39 +0200)
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>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/block-backend.c
include/sysemu/block-backend.h

index 7405024e08a438ffcf44cb79b162b0dfe0695b24..ae3d7713cea58e38e6fbda5f7033ebdf6aac7a73 100644 (file)
@@ -420,7 +420,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 ?: "";
 }
index 7462228ac1274ed789568ba603b4863b0d47083c..133e542f205aa1ae0e744038f0b4331259703271 100644 (file)
@@ -99,7 +99,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);