RE: [PATCH 2/5] Tools: hv: remove unused bytes_written from kvp_update_file()

From: KY Srinivasan
Date: Wed Dec 10 2014 - 13:49:15 EST




> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:vkuznets@xxxxxxxxxx]
> Sent: Tuesday, December 9, 2014 7:48 AM
> To: KY Srinivasan
> Cc: Haiyang Zhang; devel@xxxxxxxxxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx; Dexuan Cui
> Subject: [PATCH 2/5] Tools: hv: remove unused bytes_written from
> kvp_update_file()
>
> fwrite() does not actually return the number of bytes written and this value
> is being ignored anyway and ferror() is being called to check for an error. As
> we assign to this variable and never use it we get the following compile-time
> warning:
> hv_kvp_daemon.c:149:9: warning: variable âbytes_writtenâ set but not used
> [-Wunused-but-set-variable]
>
> Remove bytes_written completely.
>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
Signed-off-by: K. Y. Srinivasan <kys@xxxxxxxxxxxxx>
> ---
> tools/hv/hv_kvp_daemon.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index
> 6a6432a..5a274ca 100644
> --- a/tools/hv/hv_kvp_daemon.c
> +++ b/tools/hv/hv_kvp_daemon.c
> @@ -147,7 +147,6 @@ static void kvp_release_lock(int pool) static void
> kvp_update_file(int pool) {
> FILE *filep;
> - size_t bytes_written;
>
> /*
> * We are going to write our in-memory registry out to @@ -163,8
> +162,7 @@ static void kvp_update_file(int pool)
> exit(EXIT_FAILURE);
> }
>
> - bytes_written = fwrite(kvp_file_info[pool].records,
> - sizeof(struct kvp_record),
> + fwrite(kvp_file_info[pool].records, sizeof(struct kvp_record),
> kvp_file_info[pool].num_records, filep);
>
> if (ferror(filep) || fclose(filep)) {
> --
> 1.9.3

N‹§²æ¸›yú²X¬¶ÇvØ–)Þ{.nlj·¥Š{±‘êX§¶›¡Ü}©ž²ÆzÚj:+v‰¨¾«‘êZ+€Êzf£¢·hšˆ§~†­†Ûÿû®w¥¢¸?™¨è&¢)ßf”ùy§m…á«a¶Úÿ 0¶ìå