From patchwork Mon Oct 29 18:01:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Patulea X-Patchwork-Id: 195098 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8B10A2C007D for ; Tue, 30 Oct 2012 05:01:31 +1100 (EST) Received: from localhost ([::1]:47155 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSteT-00085b-1w for incoming@patchwork.ozlabs.org; Mon, 29 Oct 2012 14:01:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSteG-00084C-Eh for qemu-devel@nongnu.org; Mon, 29 Oct 2012 14:01:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TSteE-0003fn-Mn for qemu-devel@nongnu.org; Mon, 29 Oct 2012 14:01:16 -0400 Received: from mail-ia0-f173.google.com ([209.85.210.173]:47214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSteE-0003ff-GZ for qemu-devel@nongnu.org; Mon, 29 Oct 2012 14:01:14 -0400 Received: by mail-ia0-f173.google.com with SMTP id m10so4327277iam.4 for ; Mon, 29 Oct 2012 11:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=Iv0nB+3dgtlGG0ogbC0Gb8U7y1YFP6S90gpXxPyeY4w=; b=PZ8NUjIrvs21OYcUVVXqkaNtkhy7xF95wd5JUA9b5hO93EAIRDV9RL8h5qXHI59GCf q8yawyZf+ESNkwnN69CV6DgsiEeNe/2dNZb7AHlB/jQ8d/CS9fEQOwOazbJIzayfxciG ybPLFmTXP5TeUl+wG+RUV60lcwGZaxdanwmKPuuNGKMvBQGASZO+xO0HqBHNGe0dcN+s IlwVX/8R+X4EkmGrSNkv4my6KCZ8z2E6WSntm3Tmw0q7HkD290R6AdRMhb4vOYuR4d00 cmk6G7cDGx9N0TP4YEfLTPxXHMTM7yw63dLmpUh6DVD8ldc6YZzy3H09v02QZ3O3leRY 4wWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=Iv0nB+3dgtlGG0ogbC0Gb8U7y1YFP6S90gpXxPyeY4w=; b=Mi81o2VnScS7cOO6c0PH73ImpNZbOxEhnfyAuzKSeg4mReHbJDpY80pCyosSeVFMbi MprNXyuw7OmEN9rahqueDcevu6DHNSA7g0Fvp7EX3jW9WEqi9lBUSt6wXgpnLateNzJE h9ob+qTsXGybv5Uy1/Du/U44kME1dGuc5QcwmRVUeNYQuPvR09kl+IhqVEgwn+Qa4PJ3 3UlOHcpxNMUE4ielrrumjZqGxEiMYGrG3wDL0t/NLAZ0NrVLKNwXXI2oRtQq8rUYX1Qu BSkHO66tcz4h9Bvj0ZDY7N7jFG1WwkJAMkKfXfClya4Rl5w1u++6ZwxOgJL7nDK7kgPw SqZA== Received: by 10.50.140.103 with SMTP id rf7mr10401910igb.56.1351533673488; Mon, 29 Oct 2012 11:01:13 -0700 (PDT) Received: from gibson.mon.corp.google.com (gibson.mon.corp.google.com [172.29.33.50]) by mx.google.com with ESMTPS id pq3sm6055545igc.8.2012.10.29.11.01.11 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 29 Oct 2012 11:01:12 -0700 (PDT) From: Catalin Patulea To: qemu-devel@nongnu.org Date: Mon, 29 Oct 2012 14:01:07 -0400 Message-Id: <1351533667-7669-1-git-send-email-catalinp@google.com> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: References: X-Gm-Message-State: ALoCoQl8QfWHXOFbuXpyBa1ke1hCs9pGq29Qy3SwjbJAjYtVsyGORUPhf7MOLReYTrHmqJae7hAO0cLdsPXhOSS+1VVKoGW1fus6zvrpGOKaCKX9p/G1bNXgX9Ydqn72mMiOTCoyUM0E3kqlAGohopUivGHTpQyK2VKocypBh2LOi83sqID1Ayf1Y3rLqxIEawLi8Q5z18Ws4I1KOgBER4ZMvJNo9XghvlM2yxuM4Ugk4IsizfJUUK4= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.173 Cc: Peter Maydell , Catalin Patulea Subject: [Qemu-devel] [PATCHv2] tests/tcg: fix unused result warnings X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org With i386-linux-user target on x86_64 host, this does not introduce any new test failures. Signed-off-by: Catalin Patulea --- v2: - Fixes style issues from checkpatch.pl - For some reason, the patch from the list wouldn't apply for me onto master on a different machine. This grabs a new master from git://git.qemu.org/qemu.git. Let me know if there are any issues. tests/tcg/test-mmap.c | 18 +++++++++++++----- tests/tcg/testthread.c | 11 +++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/tests/tcg/test-mmap.c b/tests/tcg/test-mmap.c index c418b67..3982fa2 100644 --- a/tests/tcg/test-mmap.c +++ b/tests/tcg/test-mmap.c @@ -429,6 +429,12 @@ void check_file_fixed_mmaps(void) fprintf (stderr, " passed\n"); } +void checked_write(int fd, const void *buf, size_t count) +{ + ssize_t rc = write(fd, buf, count); + fail_unless(rc == count); +} + int main(int argc, char **argv) { char tempname[] = "/tmp/.cmmapXXXXXX"; @@ -450,13 +456,15 @@ int main(int argc, char **argv) unlink(tempname); /* Fill the file with int's counting from zero and up. */ - for (i = 0; i < (pagesize * 4) / sizeof i; i++) - write (test_fd, &i, sizeof i); + for (i = 0; i < (pagesize * 4) / sizeof i; i++) { + checked_write(test_fd, &i, sizeof i); + } + /* Append a few extra writes to make the file end at non page boundary. */ - write (test_fd, &i, sizeof i); i++; - write (test_fd, &i, sizeof i); i++; - write (test_fd, &i, sizeof i); i++; + checked_write(test_fd, &i, sizeof i); i++; + checked_write(test_fd, &i, sizeof i); i++; + checked_write(test_fd, &i, sizeof i); i++; test_fsize = lseek(test_fd, 0, SEEK_CUR); diff --git a/tests/tcg/testthread.c b/tests/tcg/testthread.c index 27e4825..2679af1 100644 --- a/tests/tcg/testthread.c +++ b/tests/tcg/testthread.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -8,6 +9,12 @@ #include #include +void checked_write(int fd, const void *buf, size_t count) +{ + ssize_t rc = write(fd, buf, count); + assert(rc == count); +} + void *thread1_func(void *arg) { int i; @@ -15,7 +22,7 @@ void *thread1_func(void *arg) for(i=0;i<10;i++) { snprintf(buf, sizeof(buf), "thread1: %d %s\n", i, (char *)arg); - write(1, buf, strlen(buf)); + checked_write(1, buf, strlen(buf)); usleep(100 * 1000); } return NULL; @@ -27,7 +34,7 @@ void *thread2_func(void *arg) char buf[512]; for(i=0;i<20;i++) { snprintf(buf, sizeof(buf), "thread2: %d %s\n", i, (char *)arg); - write(1, buf, strlen(buf)); + checked_write(1, buf, strlen(buf)); usleep(150 * 1000); } return NULL;