[libvirt] [PATCH] examples: Resolve sign-compare warnings
Peter Krempa
pkrempa at redhat.com
Tue Dec 20 11:02:50 UTC 2016
On Tue, Dec 20, 2016 at 10:58:15 +0100, Michal Privoznik wrote:
> For instance:
>
> hellolibvirt/hellolibvirt.c: In function 'showDomains':
> hellolibvirt/hellolibvirt.c:100:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
I thought we disabled those in our build.
> for (i = 0; i < numNames; i++) {
> ^
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
Redundant sign-off is redundant.
> ---
> examples/admin/client_info.c | 2 +-
> examples/admin/client_limits.c | 2 +-
> examples/admin/list_clients.c | 2 +-
> examples/admin/list_servers.c | 2 +-
> examples/admin/threadpool_params.c | 2 +-
> examples/domsuspend/suspend.c | 2 +-
> examples/domtop/domtop.c | 7 +++----
> examples/hellolibvirt/hellolibvirt.c | 2 +-
> examples/openauth/openauth.c | 2 +-
> 9 files changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/examples/admin/client_info.c b/examples/admin/client_info.c
> index 314a0902b..57e9cd71e 100644
> --- a/examples/admin/client_info.c
> +++ b/examples/admin/client_info.c
> @@ -102,7 +102,7 @@ int main(int argc, char **argv)
> virAdmClientPtr clnt = NULL; /* which client get identity for */
> virTypedParameterPtr params = NULL; /* where to store identity info */
> int nparams = 0;
> - size_t i = 0;
> + ssize_t i = 0;
> char *timestr = NULL;
>
> if (argc != 3) {
> diff --git a/examples/admin/client_limits.c b/examples/admin/client_limits.c
> index 2d5b75489..2a1d6314c 100644
> --- a/examples/admin/client_limits.c
> +++ b/examples/admin/client_limits.c
> @@ -9,7 +9,7 @@ int main(int argc, char **argv)
> virAdmServerPtr srv = NULL; /* which server to work with */
> virTypedParameterPtr params = NULL;
> int nparams = 0;
> - size_t i;
> + ssize_t i;
>
> if (argc != 2) {
> fprintf(stderr, "One argument specifying the server which to work "
> diff --git a/examples/admin/list_clients.c b/examples/admin/list_clients.c
> index 3b4496e30..21ea4d818 100644
> --- a/examples/admin/list_clients.c
> +++ b/examples/admin/list_clients.c
> @@ -50,7 +50,7 @@ int main(int argc, char **argv)
> virAdmConnectPtr conn = NULL;
> virAdmServerPtr srv = NULL; /* which server list the clients from */
> virAdmClientPtr *clients = NULL; /* where to store the servers */
> - size_t i = 0;
> + ssize_t i = 0;
> int count = 0;
>
> if (argc != 2) {
> diff --git a/examples/admin/list_servers.c b/examples/admin/list_servers.c
> index 1f6f4c6cf..420fd5fb7 100644
> --- a/examples/admin/list_servers.c
> +++ b/examples/admin/list_servers.c
> @@ -8,7 +8,7 @@ int main(void)
> virAdmConnectPtr conn = NULL;
> virAdmServerPtr *servers = NULL; /* where to store the servers */
> virAdmServerPtr *tmp = NULL;
> - size_t i = 0;
> + ssize_t i = 0;
> int count = 0;
>
> /* first, open a connection to the daemon */
> diff --git a/examples/admin/threadpool_params.c b/examples/admin/threadpool_params.c
> index ee9ce83c1..43c71184a 100644
> --- a/examples/admin/threadpool_params.c
> +++ b/examples/admin/threadpool_params.c
> @@ -9,7 +9,7 @@ int main(int argc, char **argv)
> virAdmServerPtr srv = NULL; /* which server to work with */
> virTypedParameterPtr params = NULL;
> int nparams = 0;
> - size_t i;
> + ssize_t i;
>
> if (argc != 2) {
> fprintf(stderr, "One argument specifying the server which to work "
> diff --git a/examples/domsuspend/suspend.c b/examples/domsuspend/suspend.c
> index 3e3f70e23..493a4b7b2 100644
> --- a/examples/domsuspend/suspend.c
> +++ b/examples/domsuspend/suspend.c
> @@ -156,7 +156,7 @@ fetch_domains(virConnectPtr conn)
> {
> int num_domains, ret = -1;
> virDomainPtr *domains = NULL;
> - size_t i;
> + ssize_t i;
> const int list_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE;
>
> DEBUG("Fetching list of running domains");
> diff --git a/examples/domtop/domtop.c b/examples/domtop/domtop.c
> index 22839947d..5a798154a 100644
> --- a/examples/domtop/domtop.c
> +++ b/examples/domtop/domtop.c
> @@ -161,7 +161,7 @@ fetch_domains(virConnectPtr conn)
> {
> int num_domains, ret = -1;
> virDomainPtr *domains = NULL;
> - size_t i;
> + ssize_t i;
> const int list_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE;
>
> DEBUG("Fetching list of running domains");
> @@ -189,8 +189,7 @@ fetch_domains(virConnectPtr conn)
> }
>
> static void
> -print_cpu_usage(const char *dom_name,
> - size_t cpu,
> +print_cpu_usage(size_t cpu,
> size_t ncpus,
> unsigned long long then,
> virTypedParameterPtr then_params,
This does not fit the description in the commit message. This dropps an
unused parameter and does not change any sign issues.
> @@ -334,7 +333,7 @@ do_top(virConnectPtr conn,
> goto cleanup;
> }
>
> - print_cpu_usage(dom_name, 0, max_id,
> + print_cpu_usage(0, max_id,
> then.tv_sec * 1000000 + then.tv_usec,
> then_params, then_nparams,
> now.tv_sec * 1000000 + now.tv_usec,
ACK to the sign issues. The unused param can't be part of this patch
since it conflicts with the commit message.
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161220/1bc44553/attachment-0001.sig>
More information about the libvir-list
mailing list