Patchwork monitor: assert monitor_puts()'s loop invariant

login
register
mail settings
Submitter Markus Armbruster
Date Jan. 10, 2013, 1:10 p.m.
Message ID <1357823422-30850-1-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/211001/
State New
Headers show

Comments

Markus Armbruster - Jan. 10, 2013, 1:10 p.m.
Chiefly to hush up Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 monitor.c | 1 +
 1 file changed, 1 insertion(+)
Luiz Capitulino - Jan. 10, 2013, 5:20 p.m.
On Thu, 10 Jan 2013 14:10:22 +0100
Markus Armbruster <armbru@redhat.com> wrote:

> Chiefly to hush up Coverity.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Applied to the qmp branch, thanks.

> ---
>  monitor.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/monitor.c b/monitor.c
> index 9cf419b..c6eac60 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -270,6 +270,7 @@ static void monitor_puts(Monitor *mon, const char *str)
>      char c;
>  
>      for(;;) {
> +        assert(mon->outbuf_index < sizeof(mon->outbuf) - 1);
>          c = *str++;
>          if (c == '\0')
>              break;

Patch

diff --git a/monitor.c b/monitor.c
index 9cf419b..c6eac60 100644
--- a/monitor.c
+++ b/monitor.c
@@ -270,6 +270,7 @@  static void monitor_puts(Monitor *mon, const char *str)
     char c;
 
     for(;;) {
+        assert(mon->outbuf_index < sizeof(mon->outbuf) - 1);
         c = *str++;
         if (c == '\0')
             break;