block: Constify data passed by pointer to blk_name
PATCH 1/1 block: Constify data passed by pointer to blk_name
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 <[email protected]>
--- block/block-backend.c | 2 +- include/sysemu/block-backend.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
block/block-backend.c +1 -1
@@ -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 ?:"" ; }
include/sysemu/block-backend.h +1 -1
@@ -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);
Signature · 1 line
2.9.3
Quoted 5 lines · 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 <[email protected]>
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 32 lines
--- block/block-backend.c | 2 +- include/sysemu/block-backend.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)block/block-backend.c +1
-1@@ -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 ?:"" ; }include/sysemu/block-backend.h +1
-1@@ -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);
Kevin Wolf
AppliedAm 05.03.2017 um 22:44 hat Krzysztof Kozlowski geschrieben:
Quoted 5 lines
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 <[email protected]>
Thanks, applied to block-next for qemu 2.10.
Kevin