[Spice-devel] [PATCH 12/18] Remove warnings from reds_stat utility

Christophe Fergeau cfergeau at redhat.com
Tue Sep 27 12:49:50 UTC 2016


On Mon, Sep 26, 2016 at 09:12:45AM +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  tools/reds_stat.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/reds_stat.c b/tools/reds_stat.c
> index 5e9705c..07fd732 100644
> --- a/tools/reds_stat.c
> +++ b/tools/reds_stat.c
> @@ -24,6 +24,7 @@
>  #include <stdio.h>
>  #include <string.h>
>  #include <unistd.h>
> +#include <inttypes.h>
>  #include <spice/stats.h>
>  
>  #define TAB_LEN 4
> @@ -33,15 +34,18 @@
>  static SpiceStat *reds_stat = NULL;
>  static uint64_t *values = NULL;
>  
> -void print_stat_tree(int32_t node_index, int depth)
> +static inline void ignore_result(int res)
> +{
> +}

I'd drop the inline, and add a G_GNUC_UNUSED to 'int res'

> +
> +static void print_stat_tree(int32_t node_index, int depth)
>  {
>      SpiceStatNode *node = &reds_stat->nodes[node_index];
> -    int i;
>  
>      if ((node->flags & SPICE_STAT_NODE_MASK_SHOW) == SPICE_STAT_NODE_MASK_SHOW) {
>          printf("%*s%s", depth * TAB_LEN, "", node->name);
>          if (node->flags & SPICE_STAT_NODE_FLAG_VALUE) {
> -            printf(":%*s%llu (%llu)\n", (VALUE_TABS - depth) * TAB_LEN - strlen(node->name) - 1, "",
> +            printf(":%*s%"PRIu64" (%"PRIu64")\n", (int) ((VALUE_TABS - depth) * TAB_LEN - strlen(node->name) - 1), "",
>                     node->value, node->value - values[node_index]);
>              values[node_index] = node->value;
>          } else {
> @@ -60,7 +64,6 @@ int main(int argc, char **argv)
>  {
>      char *shm_name;
>      pid_t kvm_pid;
> -    uint64_t *val;
>      uint32_t num_of_nodes = 0;
>      size_t shm_size;
>      size_t shm_old_size;
> @@ -98,7 +101,7 @@ int main(int argc, char **argv)
>          goto error2;
>      }
>      while (1) {
> -        system("clear");
> +        ignore_result(system("clear"));

Dunno how robust it is wrt to future gcc versions. Could be assert(...)
too even though not being able to clear the screen shouldn't be that
critical.

Acked-by: Christophe Fergeau <cfergeau at redhat.com>

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160927/ffad9c1d/attachment.sig>


More information about the Spice-devel mailing list