From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiO3r-0003hh-Bg for qemu-devel@nongnu.org; Fri, 31 May 2013 08:04:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiO0f-0004z5-LE for qemu-devel@nongnu.org; Fri, 31 May 2013 08:01:23 -0400 Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 31 May 2013 14:00:27 +0200 Message-Id: <1370001627-11830-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] do not check pointers after dereferencing them List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, qemu-stable@nongnu.org Two instances, both spotted by Coverity. In one, two blocks were swapped. In the other, the check is not needed anymore. Cc: qemu-stable@nongnu.org Cc: qemu-trivial@nongnu.org Signed-off-by: Paolo Bonzini --- monitor.c | 2 +- savevm.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/monitor.c b/monitor.c index 6ce2a4e..eefc7f0 100644 --- a/monitor.c +++ b/monitor.c @@ -280,7 +280,7 @@ void monitor_flush(Monitor *mon) buf = qstring_get_str(mon->outbuf); len = qstring_get_length(mon->outbuf); - if (mon && len && !mon->mux_out) { + if (len && !mon->mux_out) { rc = qemu_chr_fe_write(mon->chr, (const uint8_t *) buf, len); if (rc == len) { /* all flushed */ diff --git a/savevm.c b/savevm.c index 31dcce9..4e0fab6 100644 --- a/savevm.c +++ b/savevm.c @@ -322,16 +322,16 @@ QEMUFile *qemu_popen_cmd(const char *command, const char *mode) FILE *stdio_file; QEMUFileStdio *s; - stdio_file = popen(command, mode); - if (stdio_file == NULL) { - return NULL; - } - if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) { fprintf(stderr, "qemu_popen: Argument validity check failed\n"); return NULL; } + stdio_file = popen(command, mode); + if (stdio_file == NULL) { + return NULL; + } + s = g_malloc0(sizeof(QEMUFileStdio)); s->stdio_file = stdio_file; -- 1.8.1.4